Skip to content

Instantly share code, notes, and snippets.

@0wnrepo
Forked from kehh/warsync.sh
Created June 29, 2016 10:06
Show Gist options
  • Save 0wnrepo/ee310a12624e251bb80bc87c285754b5 to your computer and use it in GitHub Desktop.
Save 0wnrepo/ee310a12624e251bb80bc87c285754b5 to your computer and use it in GitHub Desktop.
Warsync - a tool for speeding up rsync of war files by unzipping them on the source and target and then rsyncing the diffs
#!/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\" ./;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment