Skip to content

Instantly share code, notes, and snippets.

@SalathielGenese
Created December 28, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SalathielGenese/bd7c74b970817b70afe35f4fb7e44390 to your computer and use it in GitHub Desktop.
Save SalathielGenese/bd7c74b970817b70afe35f4fb7e44390 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
help()
{
bel=`tput bel`
bold=`tput bold`
normal=`tput sgr0`
red=`tput setaf 2`
blue=`tput setaf 4`
underline=`tput smul`
cat << EOM
${bold}NAME${normal}
${red}./rsync${normal} - A script around the real ${blue}rsync${normal} utility
${bold}SYNOPSIS${normal}
${red}./rsync${normal} -h | --help
${red}./rsync${normal} ${underline}input${normal} ${underline}output${normal} [${underline}exclude${normal}]...
${bold}DESCRIPTION${normal}
This utility wraps ${blue}rsync${normal} utility to provide a straight-
forward shortcut and watches ${underline}input${normal} for changes (move,
attrib, modify, create, delete) using inotifywait.
${bold}-h${normal}, ${bold}--help${normal}
prints this help message
${bold}input${normal}
${blue}rsync${normal} source
${bold}output${normal}
${blue}rsync${normal} destination
${bold}exclude${normal}
${blue}rsync${normal} destination
${bold}LICENSE${normal}
MIT
${bold}AUTHOR${normal}
Written by :
- YIMGA YIMGA Salathiel Genèse
salathielgenese@gmail.com
EOM
printf "${bel}"
}
for arg in "$@"; do
[ "$arg" = "--help" -o "$arg" = "-h" ] && help && exit 0
done
output="$2"
input="$1"
shift 2
for i in `seq $# -1 1`; do
set -- "${@:1:$#-i}" "--exclude" "${@:$#-i+1}"
done
set -- "$@" "$input" "$output"
rsync -avzP --delete "$@"
while inotifywait -r -e move,attrib,modify,create,delete "$input"; do
rsync -avzP --delete "$@"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment