Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
Created October 11, 2011 07:44
Show Gist options
  • Save DamianZaremba/1277511 to your computer and use it in GitHub Desktop.
Save DamianZaremba/1277511 to your computer and use it in GitHub Desktop.
Bytemark dns upload script
#!/bin/sh
# Config stuff
UPLOAD_HOST="upload.ns.bytemark.co.uk";
UPLOAD_USERNAME="";
UPLOAD_PASSWORD="";
# This stuff is required
cd `dirname $0`;
export RSYNC_PASSWORD=$UPLOAD_PASSWORD;
# Try and find the binaries we need
RSYNC_BINARY=`which rsync`;
PING_BINARY=`which ping`;
# Check that rsync actually exists
if [ "$RSYNC_BINARY" == "" ]; then
echo 'rsync could not be found on $PATH!';
exit 1;
fi
# Check that ping actually exists
if [ "$PING_BINARY" == "" ]; then
echo 'ping could not be found on $PATH!';
exit 1;
fi
# Check we can contact the upload host
$PING_BINARY -w 1 -c 1 $UPLOAD_HOST &>/dev/null
if [ $? != 0 ]; then
echo 'Could not contact'$UPLOAD_HOST'!';
exit 1;
fi
# Do the upload!
echo 'Doing upload'
$RSYNC_BINARY -r --delete data/ dns@${UPLOAD_HOST}::${UPLOAD_USERNAME}/
if [ $? != 0 ]; then
echo 'Upload appears to have failed';
exit 1;
else
echo 'Upload done!';
exit 0;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment