Update emulator-sync-scripts.sh
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERS='1.0.2-08112023'
|
VERS='1.0.5-08112023'
|
||||||
|
|
||||||
source /opt/idssys/defaults/colors.inc
|
source /opt/idssys/defaults/colors.inc
|
||||||
source /opt/idssys/defaults/default.inc
|
source /opt/idssys/defaults/default.inc
|
||||||
source /opt/idssys/emulator-sync/settings.conf
|
source /opt/idssys/emulator-sync/settings.conf
|
||||||
|
|
||||||
ESFOLDER=/opt/idssys/emulator-sync
|
ES_FOLDER=/opt/idssys/emulator-sync
|
||||||
SYNC_FOLDER="${ESFOLDER}/._sync_nextcloud"
|
ES_LOGFOLDER="${ES_FOLDER}/logs"
|
||||||
[ ! -d ${SYNC_FOLDER} ] && mkdir ${SYNC_FOLDER}
|
[ ! -d ${ES_LOGFOLDER} ] && mkdir ${ES_LOGFOLDER}
|
||||||
|
|
||||||
SENDNOTICE(){
|
SENDNOTICE(){
|
||||||
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
||||||
@@ -20,10 +20,10 @@ $(date)" "${1}" ${3} &
|
|||||||
}
|
}
|
||||||
|
|
||||||
RUNSYNC(){
|
RUNSYNC(){
|
||||||
[ -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
|
[ -f ${ES_FOLDER}/nc-sync.running ] && [ $(expr $(date +%s) - $(stat -L --format %Y ${ES_FOLDER}/nc-sync.running)) -gt 21600 ] && /bin/rm -f ${ES_FOLDER}/nc-sync.running
|
||||||
|
|
||||||
if [ ! -f ${ESFOLDER}/nc-sync.running ]; then
|
if [ ! -f ${ES_FOLDER}/nc-sync.running ]; then
|
||||||
touch ${ESFOLDER}/nc-sync.running
|
touch ${ES_FOLDER}/nc-sync.running
|
||||||
|
|
||||||
if [ ! -f ${NC_PATH}/mounted ]; then
|
if [ ! -f ${NC_PATH}/mounted ]; then
|
||||||
/usr/bin/mount -a
|
/usr/bin/mount -a
|
||||||
@@ -33,38 +33,38 @@ RUNSYNC(){
|
|||||||
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
||||||
echo -en "${idsCL[LightCyan]}Sync Started : ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Sync Started : ${idsCL[Default]}"
|
||||||
|
|
||||||
[ -f ${ESFOLDER}/mount.failure ] && /bin/rm -f ${ESFOLDER}/mount.failure
|
[ -f ${ES_FOLDER}/mount.failure ] && /bin/rm -f ${ES_FOLDER}/mount.failure
|
||||||
if [ -f ${SYNC_FOLDER}/failures.txt ]; then
|
if [ -f ${ES_LOGFOLDER}/failures.txt ]; then
|
||||||
echo -e "${idsCL[Red]}Failed${idsCL[Default]}"
|
echo -e "${idsCL[Red]}Failed${idsCL[Default]}"
|
||||||
|
|
||||||
if [ -f ${SYNC_FOLDER}/failures2.txt ]; then
|
if [ -f ${ES_LOGFOLDER}/failures2.txt ]; then
|
||||||
echo "Nextcloud sync failure, ${SYNC_FOLDER}/failures.txt exists."
|
echo "Nextcloud sync failure, ${ES_LOGFOLDER}/failures.txt exists."
|
||||||
SENDNOTICE "Nextcloud Sync Failure" "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" 1
|
SENDNOTICE "Nextcloud Sync Failure" "${ES_LOGFOLDER}/failures.txt Exists\n\n$(date)" 1
|
||||||
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
/bin/rm -f ${ES_FOLDER}/nc-sync.running
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
/bin/mv ${SYNC_FOLDER}/failures.txt ${SYNC_FOLDER}/failures2.txt
|
/bin/mv ${ES_LOGFOLDER}/failures.txt ${ES_LOGFOLDER}/failures2.txt
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -f ${SYNC_FOLDER}/failures.txt ]; then
|
if [ ! -f ${ES_LOGFOLDER}/failures.txt ]; then
|
||||||
${ESFOLDER}/nextcloud-sync-cron/nextcloud-sync-cron.sh --verbose --logdir ${SYNC_FOLDER} ${ESFOLDER}/nextcloud-client.conf
|
${ES_FOLDER}/nextcloud-sync-cron/nextcloud-sync-cron.sh --verbose --logdir ${ES_LOGFOLDER} ${ES_FOLDER}/nextcloud-client.conf
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
if [ -f ${SYNC_FOLDER}/failures2.txt ] && [ ! -f ${SYNC_FOLDER}/failures.txt ]; then
|
if [ -f ${ES_LOGFOLDER}/failures2.txt ] && [ ! -f ${ES_LOGFOLDER}/failures.txt ]; then
|
||||||
echo "$(date): Fixed" >> ${NC_PATH}/sync.log
|
echo "$(date): Fixed" >> ${NC_PATH}/sync.log
|
||||||
SENDNOTICE "Nextcloud Sync Fixed" "Sync is running again"
|
SENDNOTICE "Nextcloud Sync Fixed" "Sync is running again"
|
||||||
/bin/rm -f ${SYNC_FOLDER}/failures*
|
/bin/rm -f ${ES_LOGFOLDER}/failures*
|
||||||
fi
|
fi
|
||||||
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
/bin/rm -f ${ES_FOLDER}/nc-sync.running
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -f ${ESFOLDER}/mount.failure ]; then
|
if [ -f ${ES_FOLDER}/mount.failure ]; then
|
||||||
SENDNOTICE "Nextcloud Sync Unmounted" "The folder ${NC_PATH} Cannot be mounted" 1
|
SENDNOTICE "Nextcloud Sync Unmounted" "The folder ${NC_PATH} Cannot be mounted" 1
|
||||||
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
/bin/rm -f ${ES_FOLDER}/nc-sync.running
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
/usr/bin/mount -a
|
/usr/bin/mount -a
|
||||||
touch ${ESFOLDER}/mount.failure
|
touch ${ES_FOLDER}/mount.failure
|
||||||
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
/bin/rm -f ${ES_FOLDER}/nc-sync.running
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user