diff --git a/upload b/upload index 3a7c012f6fccdd5105ed898426b6f4cbbefac5fd..1217c36542b97621b4ca6b2e2e507d043be3c61f 100755 --- a/upload +++ b/upload @@ -6,6 +6,14 @@ then fi export PASSWORD=$LFTP_PASSWORD +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $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 +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + USER=ok1kvk.cz-www-nove HOST=krios.blueboard.cz MAX_RETRIES=2 @@ -15,7 +23,7 @@ echo "======================================================================" echo "Uploading to $HOST" if [ "$1" == "ftp" ]; then echo "Using FTP" - time lftp -e "set cmd:fail-exit yes;\ + /usr/bin/time -f "Upload took %e" -- lftp -e "set cmd:fail-exit yes;\ set net:timeout 5;\ set net:reconnect-interval-base $RECONNECT_INTERVAL;\ set net:max-retries $MAX_RETRIES;\ @@ -27,7 +35,7 @@ if [ "$1" == "ftp" ]; then echo "LFTP finished with return code $RET" else echo "Using SFTP" - /usr/bin/time -f "Upload took %e" -- node sftp-sync.js --sourcedir build --server $HOST --user $USER --remotedir /test --port 2121 + /usr/bin/time -f "Upload took %e" -- node $DIR/sftp-sync.js --sourcedir build --server $HOST --user $USER --remotedir / --port 2121 fi exit 0