This commit is contained in:
2023-07-15 15:18:43 -05:00
parent 1168cd222d
commit 55b6733968
3 changed files with 78 additions and 0 deletions

57
emulator-sync-scripts.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
[ -f /opt/nc-sync.running ] && [ $(expr $(date +%s) - $(stat -L --format %Y /opt/nc-sync.running)) -gt 21600 ] && /bin/rm -f /opt/nc-sync.running
if [ ! -f /opt/nc-sync.running ]; then
NC_PATH="/mnt/NC-Games"
SYNC_FOLDER="/mnt/NC-Games/._sync_nextcloud"
touch /opt/nc-sync.running
if [ ! -f ${NC_PATH}/mounted ]; then
/usr/bin/mount -a
sleep 5s
fi
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
[ -f /opt/mount.failure ] && /bin/rm -f /opt/mount.failure
if [ -f ${SYNC_FOLDER}/failures.txt ]; then
if [ -f ${SYNC_FOLDER}/failures2.txt ]; then
echo "Nextcloud sync failure, ${SYNC_FOLDER}/failures.txt exists."
echo -e "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" | mail -s "Nextcloud Sync Failure" 9208839613@mms.att.net
/bin/rm -f /opt/nc-sync.running
exit 1
else
/bin/mv ${SYNC_FOLDER}/failures.txt ${SYNC_FOLDER}/failures2.txt
fi
fi
if [ ! -f ${SYNC_FOLDER}/failures.txt ]; then
echo "Sync Started"
/opt/nextcloud-sync-cron/nextcloud-sync-cron.sh --verbose /opt/nextcloud-sync-cron/nextcloud-client.conf
echo "Sync Finished"
if [ -f ${SYNC_FOLDER}/failures2.txt ] && [ ! -f ${SYNC_FOLDER}/failures.txt ]; then
echo "$(date): Fixed" >> ${NC_PATH}/sync.log
/bin/rm -f ${SYNC_FOLDER}/failures*
fi
/bin/rm -f /opt/nc-sync.running
exit 0
fi
else
if [ -f /opt/mount.failure ]; then
echo -e "The folder ${NC_PATH} Cannot be mounted\n\n$(date)" | mail -s "Nextcloud Sync Unmounted" 9208839613@mms.att.net
/bin/rm -f /opt/nc-sync.running
exit 1
else
/usr/bin/mount -a
touch /opt/mount.failure
/bin/rm -f /opt/nc-sync.running
exit 1
fi
fi
else
echo "There is a sync in process"
exit 0
fi
exit 1