This commit is contained in:
2023-07-15 15:46:19 -05:00
parent a8229d2e16
commit 3dd5947d03
2 changed files with 22 additions and 11 deletions

View File

@@ -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

View File

@@ -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