sapphrc/usr/bin/sapphrc_updown
2024-03-31 19:51:36 -06:00

24 lines
592 B
Bash
Executable file

#!/bin/bash
source /lib/sapphrc/sapphrc-functions
source /lib/sapphrc/sapphrc-font
validate_backupdir
cd "$HOME/.config/sapphrc/backups"
sapphrc_backup
gs="$(git status | grep -i 'modified')"
git fetch origin
reslog=$(git log HEAD..origin/main --oneline)
if [[ "${gs}" == *"modified"* && "${reslog}" != "" ]];then
#local AND remote changes exist
echo "local backup reposity conflict with remote - please manually fix this!"
exit 1
elif [[ $gs == *"modified"* ]];then
#local changes exist
sapphrc_push
elif [[ "${reslog}" == "" ]];then
#remote changes exist
sapphrc_restore
fi
exit