Update emulator-sync-scripts.sh
This commit is contained in:
@@ -6,7 +6,7 @@ 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=${ESFOLDER}
|
ESFOLDER=/opt/idssys/emulator-sync
|
||||||
SYNC_FOLDER="${ESFOLDER}/._sync_nextcloud"
|
SYNC_FOLDER="${ESFOLDER}/._sync_nextcloud"
|
||||||
[ ! -d ${SYNC_FOLDER} ] && mkdir ${SYNC_FOLDER}
|
[ ! -d ${SYNC_FOLDER} ] && mkdir ${SYNC_FOLDER}
|
||||||
|
|
||||||
@@ -19,64 +19,66 @@ $(date)" "${1}" ${3} &
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -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
|
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
|
||||||
|
|
||||||
if [ ! -f ${ESFOLDER}/nc-sync.running ]; then
|
if [ ! -f ${ESFOLDER}/nc-sync.running ]; then
|
||||||
touch ${ESFOLDER}/nc-sync.running
|
touch ${ESFOLDER}/nc-sync.running
|
||||||
|
|
||||||
if [ ! -f ${NC_PATH}/mounted ]; then
|
if [ ! -f ${NC_PATH}/mounted ]; then
|
||||||
/usr/bin/mount -a
|
/usr/bin/mount -a
|
||||||
sleep 5s
|
sleep 5s
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
||||||
[ -f ${ESFOLDER}/mount.failure ] && /bin/rm -f ${ESFOLDER}/mount.failure
|
[ -f ${ESFOLDER}/mount.failure ] && /bin/rm -f ${ESFOLDER}/mount.failure
|
||||||
if [ -f ${SYNC_FOLDER}/failures.txt ]; then
|
if [ -f ${SYNC_FOLDER}/failures.txt ]; then
|
||||||
if [ -f ${SYNC_FOLDER}/failures2.txt ]; then
|
if [ -f ${SYNC_FOLDER}/failures2.txt ]; then
|
||||||
echo "Nextcloud sync failure, ${SYNC_FOLDER}/failures.txt exists."
|
echo "Nextcloud sync failure, ${SYNC_FOLDER}/failures.txt exists."
|
||||||
SENDNOTICE "Nextcloud Sync Failure" "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" 1
|
SENDNOTICE "Nextcloud Sync Failure" "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" 1
|
||||||
|
/bin/rm -f ${ESFOLDER}/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"
|
||||||
|
${ESFOLDER}/nextcloud-sync-cron/nextcloud-sync-cron.sh --verbose ${ESFOLDER}/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
|
||||||
|
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 ${ESFOLDER}/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 ${ESFOLDER}/nc-sync.running
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
/bin/mv ${SYNC_FOLDER}/failures.txt ${SYNC_FOLDER}/failures2.txt
|
/usr/bin/mount -a
|
||||||
|
touch ${ESFOLDER}/mount.failure
|
||||||
|
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -f ${SYNC_FOLDER}/failures.txt ]; then
|
|
||||||
echo "Sync Started"
|
|
||||||
${ESFOLDER}/nextcloud-sync-cron/nextcloud-sync-cron.sh --verbose ${ESFOLDER}/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
|
|
||||||
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 ${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 ${ESFOLDER}/mount.failure
|
|
||||||
/bin/rm -f ${ESFOLDER}/nc-sync.running
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "There is a sync in process"
|
echo "There is a sync in process"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${idsCL[LightGreen]} Emulator-Nextcloud-Sync ${idsCL[Default]} ${idsCL[DarkGray]}(ver-${VERS})${idsCL[Default]}"
|
echo -e "${idsCL[LightGreen]} Emulator-Nextcloud-Sync ${idsCL[Default]} ${idsCL[DarkGray]}(ver-${VERS})${idsCL[Default]}"
|
||||||
DIVIDER . lightGreen
|
DIVIDER . lightGreen
|
||||||
echo
|
echo
|
||||||
case ${1} in
|
case ${1} in
|
||||||
sync) NEWCERT ${2};;
|
sync) RUNSYNC ${2};;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user