public
Created

Warsync - a tool for speeding up rsync of war files by unzipping them on the source and target and then rsyncing the diffs

  • Download Gist
warsync.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash
#Warsync - a tool for speeding up rsync of war files by unzipping them on the source and target and then rsyncing the diffs
echo "Usage: $0 source.war destinationserver"
CURRENTDIR=$PWD
WARFILE="$CURRENTDIR/$1"
REMOTEHOST=$2
CURRENTUSER=$USER
REMOTEHOME="/home/$CURRENTUSER"
WARFILENAME=`basename $1`
echo "source is $WARFILE target is $TARGET"
TEMPBASE="/tmp/warsync/"
TEMPDIR="$TEMPBASE/$WARFILENAME"
mkdir -p "$TEMPDIR"
cd "$TEMPDIR"
jar -xvf "$WARFILE"
ssh $REMOTEHOST "mkdir -p \"$TEMPDIR\";cd \"$TEMPDIR\";REMOTEDIR=\"$PWD\";pwd;jar -xvf \"$REMOTEHOME/$WARFILENAME\""rsync -avz --human-readable --progress --delete "$TEMPDIR" $REMOTEHOST:"$TEMPBASE"
ssh $REMOTEHOST "jar -cvf \"$WARFILENAME\" -C \"$TEMPDIR\" ./;"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.