#!/usr/bin/env bash SCRIPT="$0" # SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. while [ -h "$SCRIPT" ] ; do ls=`ls -ld "$SCRIPT"` # Drop everything prior to -> link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then SCRIPT="$link" else SCRIPT=`dirname "$SCRIPT"`/"$link" fi done APP_HOME=`dirname "$SCRIPT"` export APP_HOME=`cd "$APP_HOME"; pwd` NODE_USER=$1 TO_PATH=$2 if [ $NODE_USER = ""]; then echo "Use: rsync_local.sh user@host /path/dir" exit 2 fi if [ $TO_PATH = ""]; then echo "Use: rsync_local.sh user@host /path/dir" exit 2 fi echo "APP_HOME=$APP_HOME" echo "NODE_USER=$NODE_USER" echo "TO_PATH=$TO_PATH" echo "sync node: $NODE_USER" echo rsync -vazu --progress $APP_HOME/* $NODE_USER:$TO_PATH rsync -vazu --progress $APP_HOME/* "$NODE_USER":$TO_PATH