Merging release-0.2.1
[backups/.git] / scripts / restore-header.sh
1 #!/bin/sh
2
3 export rundir=/tmp/restore-$(date +%Y%m%d%H%M%S)
4
5 if ! mkdir $rundir; then
6   echo >&2 "Cannot create temp dir"
7   exit 1
8 fi
9
10 unset CDPATH
11 if [ -z "$3" ]; then
12   export mountdir=$(cd $(dirname $0) && pwd -P)
13 fi
14
15 SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
16
17 # take the archive portion of this file and pipe it to tar
18 tail +$SKIP $0 | tar xzf - -C $rundir
19
20 cd $rundir
21 exec ./restore-script.sh ${1+"$@"}
22
23 __ARCHIVE_FOLLOWS__