Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | #!/bin/bash |
2 | |||
3 | # Get the directory of this script (also works with symlinks) |
||
4 | # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in |
||
5 | SOURCE="${BASH_SOURCE[0]}" |
||
6 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
||
7 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
||
8 | SOURCE="$(readlink "$SOURCE")" |
||
9 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
||
10 | done |
||
11 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
||
12 | |||
13 | cd "$DIR" |
||
14 | dirname=$( basename "$( pwd )" ) |
||
15 | tmpfile=$( mktemp ) |
||
16 | |||
17 | FILENAME="stable.tar.gz" |
||
18 | |||
19 | cd .. |
||
20 | tar cvfz "$tmpfile" --exclude="$dirname"/"$FILENAME" --exclude ".svn" -- "$dirname" |
||
21 | |||
22 | # otherwise: "the file has changed while reading" |
||
23 | mv "$tmpfile" "$dirname"/"$FILENAME" |
||
24 | |||
25 | chmod 644 "$dirname"/"$FILENAME" |