Skip to content

Instantly share code, notes, and snippets.

@seangreen
Created June 30, 2015 09:15
Show Gist options
  • Save seangreen/6c56a0d157bf59ef6420 to your computer and use it in GitHub Desktop.
Save seangreen/6c56a0d157bf59ef6420 to your computer and use it in GitHub Desktop.
Shell Script to RSync Image Folder (joomla or so)
#!/bin/bash
# Variables
# LIVE PATH (relative to current path
LIVE_PATH=../htdocs
# USAGE
function usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
Version: 1.0
Author: Sean Gruenboeck / studio19.at
Changedate: 29.06.2015
Use this script to rsync live image folder
OPTIONS:
-s Sync
-h Show help/usage
EOF
}
# FUNCTIONS
# GET OPTIONS
while getopts ":sh" OPTION; do
case $OPTION in
h)
usage
exit 0
;;
*)
[[ "$OPTARG" == "" ]] && OPTARG='"-'$OPTION' 1"'
OPTION="OPT_$OPTION"
eval ${OPTION}=$OPTARG
;;
esac
done
# Check that options are set
[[ "$OPT_s" == "" ]] && usage && exit 1
if [[ ! "$OPT_s" == "" ]]; then
rsync -avzh $LIVE_PATH/images/ images/
fi
echo "RSYNC finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment