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/emulator-sync/settings.conf
|
||||
|
||||
ESFOLDER=${ESFOLDER}
|
||||
ESFOLDER=/opt/idssys/emulator-sync
|
||||
SYNC_FOLDER="${ESFOLDER}/._sync_nextcloud"
|
||||
[ ! -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
|
||||
touch ${ESFOLDER}/nc-sync.running
|
||||
if [ ! -f ${ESFOLDER}/nc-sync.running ]; then
|
||||
touch ${ESFOLDER}/nc-sync.running
|
||||
|
||||
if [ ! -f ${NC_PATH}/mounted ]; then
|
||||
/usr/bin/mount -a
|
||||
sleep 5s
|
||||
fi
|
||||
if [ ! -f ${NC_PATH}/mounted ]; then
|
||||
/usr/bin/mount -a
|
||||
sleep 5s
|
||||
fi
|
||||
|
||||
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
||||
[ -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."
|
||||
SENDNOTICE "Nextcloud Sync Failure" "${SYNC_FOLDER}/failures.txt Exists\n\n$(date)" 1
|
||||
if [ -f ${NC_PATH}/mounted ] || [ "${1}" == "skipmount" ]; then
|
||||
[ -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."
|
||||
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
|
||||
exit 1
|
||||
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
|
||||
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
|
||||
echo "There is a sync in process"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo "There is a sync in process"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
echo
|
||||
echo -e "${idsCL[LightGreen]} Emulator-Nextcloud-Sync ${idsCL[Default]} ${idsCL[DarkGray]}(ver-${VERS})${idsCL[Default]}"
|
||||
DIVIDER . lightGreen
|
||||
echo
|
||||
case ${1} in
|
||||
sync) NEWCERT ${2};;
|
||||
sync) RUNSYNC ${2};;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user