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