Skip to content

Instantly share code, notes, and snippets.

@tommyvdv
Last active October 31, 2018 11:35
Show Gist options
  • Save tommyvdv/036cb4c98eb7487125c11bdb23cbc7c7 to your computer and use it in GitHub Desktop.
Save tommyvdv/036cb4c98eb7487125c11bdb23cbc7c7 to your computer and use it in GitHub Desktop.
quick sync & reboot
#!/bin/bash
# usage:
# $ ./sync.sh /home/user/tmp/A /home/user/tmp/B /home/user/tmp/C /home/user/script.py
source="$1"
temp="$2"
destination="$3"
scriptpath="$4"
rsync -avr "${source}/" "${temp}/" > /dev/null
diff "${temp}" "${destination}" > /dev/null
exitcode="$?"
if [[ "${exitcode}" -ne 0 ]]; then
echo "diff spotted"
rsync -avr "${temp}/" "${destination}" > /dev/null && \
pkill -f "${scriptpath}" && \
python3 "${scriptpath}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment