Last active
October 31, 2018 11:35
-
-
Save tommyvdv/036cb4c98eb7487125c11bdb23cbc7c7 to your computer and use it in GitHub Desktop.
quick sync & reboot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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