-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeployto
More file actions
executable file
·21 lines (17 loc) · 813 Bytes
/
deployto
File metadata and controls
executable file
·21 lines (17 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#/bin/sh
# install contents of this directory on remote directory
SERVER="$1"
[ -z "$SERVER" ] && echo -n "Enter server or user@server: " && read SERVER
USER="${SERVER%@*}"
[ "$USER" = "$SERVER" ] && USER="root"
[ -z "$USER" ] && USER=`whoami`
DEST="${SERVER#*:}"
SERVER="${SERVER#*@}"
SERVER="${SERVER%:*}"
# does target directory already exist ?
ssh $USER@$SERVER "[ ! -d $DEST ] && echo Destination $DEST does not exist && exit 1; exit 0" || exit 1
# are we copying to the same directory?
[ "${PWD##*/}" != "${DEST##*/}" ] && echo Destination directory $DEST does not match current directory $PWD && exit 2
echo "Deploying to $USER@$SERVER:$DEST..."
# note: does not use go switches to avoid breaking apache ownership of target
rsync -rlptvc --inplace . $USER@$SERVER:$DEST --exclude .svn --exclude .git