diff --git a/emulator-sync-scripts.sh b/emulator-sync-scripts.sh index de9fdb6..211b9b3 100755 --- a/emulator-sync-scripts.sh +++ b/emulator-sync-scripts.sh @@ -2,29 +2,39 @@ VERS='1.0.0-07152023' -ESFOLDER=${ESFOLDER} +source /opt/idssys/defaults/colors.inc +source /opt/idssys/defaults/default.inc +source /opt/idssys/emulator-sync/settings.conf +ESFOLDER=${ESFOLDER} +SYNC_FOLDER="${ESFOLDER}/._sync_nextcloud" +[ ! -d ${SYNC_FOLDER} ] && mkdir ${SYNC_FOLDER} + +SENDNOTICE(){ + [ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2} + +$(date)" "${1}" ${3} & + + [ "${EMAIL_NOTICE}" != "" ] && echo -e "${1}\n\n$(date)" | mail -s "${2}" ${EMAIL_NOTICE} + +} [ -f ${ESFOLDER}/nc-sync.running ] && [ $(expr $(date +%s) - $(stat -L --format %Y ${ESFOLDER}/nc-sync.running)) -gt 21600 ] && /bin/rm -f ${ESFOLDER}/nc-sync.running if [ ! -f ${ESFOLDER}/nc-sync.running ]; then - NC_PATH="/mnt/NC-Games" - SYNC_FOLDER="/mnt/NC-Games/._sync_nextcloud" - touch ${ESFOLDER}/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 + [ -f ${ESFOLDER}/mount.failure ] && /bin/rm -f ${ESFOLDER}/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 + SENDNOTICE "Nextcloud Sync Failure" "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" 1 /bin/rm -f ${ESFOLDER}/nc-sync.running exit 1 else @@ -37,19 +47,20 @@ if [ ! -f ${ESFOLDER}/nc-sync.running ]; then echo "Sync Finished" if [ -f ${SYNC_FOLDER}/failures2.txt ] && [ ! -f ${SYNC_FOLDER}/failures.txt ]; then echo "$(date): Fixed" >> ${NC_PATH}/sync.log + SENDNOTICE "Nextcloud Sync Fixed" "Sync is running again" /bin/rm -f ${SYNC_FOLDER}/failures* fi /bin/rm -f ${ESFOLDER}/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 + if [ -f ${ESFOLDER}/mount.failure ]; then + SENDNOTICE "Nextcloud Sync Unmounted" "The folder ${NC_PATH} Cannot be mounted" 1 /bin/rm -f ${ESFOLDER}/nc-sync.running exit 1 else /usr/bin/mount -a - touch /opt/mount.failure + touch ${ESFOLDER}/mount.failure /bin/rm -f ${ESFOLDER}/nc-sync.running exit 1 fi diff --git a/install.sh b/install.sh index 2d3d2d3..d72f68e 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)" echo -e "\n${idsCL[LightGreen]}Emulator-Nextcloud-Sync Installation Script${idsCL[Default]}" set -eu -git clone https://git.schroedercity.com/voltron/emulator-sync.git /opt/idssys/emulator-sync +git clone --recursive https://git.schroedercity.com/voltron/emulator-sync.git /opt/idssys/emulator-sync ln -s /opt/idssys/emulator-sync/run.sh /usr/local/bin/esync if [ ! -d "/opt/idssys/defaults" ]; then