Skip to content

Commit ac9c89b

Browse files
author
Oliver Cervera
authored
Small wording changes
Sync markers are not bold and spaced Minor tweaks to other messages Fix an issue (in dev) where forced sync would not run
1 parent 5e6214a commit ac9c89b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

snapraid-aio-script.sh

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#
44
# Project page: https://github.com/auanasgheps/snapraid-aio-script
55
#
6-
SNAPSCRIPTVERSION="2.7.0.1-DEV3"
76
########################################################################
87

98
######################
10-
# USER VARIABLES #
9+
# CONFIG VARIABLES #
1110
######################
11+
SNAPSCRIPTVERSION="2.7.0.1-DEV4"
1212

1313
# find the current path
1414
CURRENT_DIR="$(dirname "${0}")"
@@ -144,7 +144,7 @@ function main(){
144144
mklog "INFO: SnapRAID SYNC Job finished"
145145
JOBS_DONE="$JOBS_DONE + SYNC"
146146
# insert SYNC marker to 'Everything OK' or 'Nothing to do' string to differentiate it from SCRUB job later
147-
sed_me "s/^Everything OK/SYNC_JOB--Everything OK/g;s/^Nothing to do/SYNC_JOB--Nothing to do/g" "$TMP_OUTPUT"
147+
sed_me "s/^Everything OK/**SYNC JOB - Everything OK**/g;s/^Nothing to do/**SYNC JOB - Nothing to do**/g" "$TMP_OUTPUT"
148148
# Remove any warning flags if set previously. This is done in this step to take care of scenarios when user
149149
# has manually synced or restored deleted files and we will have missed it in the checks above.
150150
if [ -e $SYNC_WARN_FILE ]; then
@@ -163,8 +163,8 @@ function main(){
163163
mklog "INFO: Scrub job is cancelled as parity info is out of sync (deleted or changed files threshold has been breached)."
164164
else
165165
# NO, delete threshold has not been breached OR we forced a sync, but we have one last test -
166-
# let's make sure if sync ran, it completed successfully (by checking for our marker text "SYNC_JOB--" in the output).
167-
if [ $DO_SYNC -eq 1 -a -z "$(grep -w "SYNC_JOB-" $TMP_OUTPUT)" ]; then
166+
# let's make sure if sync ran, it completed successfully (by checking for our marker text "SYNC JOB -" in the output).
167+
if [ $DO_SYNC -eq 1 -a -z "$(grep -w "SYNC JOB -" $TMP_OUTPUT)" ]; then
168168
# Sync ran but did not complete successfully so lets not run scrub to be safe
169169
echo "**WARNING** - check output of SYNC job. Could not detect marker. Not proceeding with SCRUB job. [`date`]"
170170
mklog "WARN: Check output of SYNC job. Could not detect marker. Not proceeding with SCRUB job."
@@ -181,7 +181,7 @@ function main(){
181181
echo
182182
JOBS_DONE="$JOBS_DONE + SCRUB"
183183
# insert SCRUB marker to 'Everything OK' or 'Nothing to do' string to differentiate it from SYNC job above
184-
sed_me "s/^Everything OK/SCRUB_JOB--Everything OK/g;s/^Nothing to do/SCRUB_JOB--Nothing to do/g" "$TMP_OUTPUT"
184+
sed_me "s/^Everything OK/**SCRUB JOB - Everything OK**/g;s/^Nothing to do/**SCRUB JOB - Nothing to do**/g" "$TMP_OUTPUT"
185185
fi
186186
fi
187187
else
@@ -329,7 +329,7 @@ function chk_del(){
329329
echo "There are no deleted files, that's fine."
330330
DO_SYNC=1
331331
else
332-
echo "There are deleted files. The number of deleted files, ($DEL_COUNT), is below the threshold of ($DEL_THRESHOLD)."
332+
echo "There are deleted files. The number of deleted files ($DEL_COUNT) is below the threshold of ($DEL_THRESHOLD)."
333333
DO_SYNC=1
334334
fi
335335
else
@@ -345,7 +345,7 @@ function chk_updated(){
345345
echo "There are no updated files, that's fine."
346346
DO_SYNC=1
347347
else
348-
echo "There are updated files. The number of updated files, ($UPDATE_COUNT), is below the threshold of ($UP_THRESHOLD)."
348+
echo "There are updated files. The number of updated files ($UPDATE_COUNT) is below the threshold of ($UP_THRESHOLD)."
349349
DO_SYNC=1
350350
fi
351351
else
@@ -361,17 +361,19 @@ function chk_sync_warn(){
361361
echo "Forced sync is enabled. [`date`]"
362362
mklog "INFO: Forced sync is enabled."
363363
else
364-
echo "Sync with threshold warning(s) is enabled."
364+
echo "Sync after threshold warning(s) is enabled."
365+
mklog "INFO: Sync after threshold warning(s) is enabled."
366+
fi
365367
SYNC_WARN_COUNT=$(sed 'q;/^[0-9][0-9]*$/!d' $SYNC_WARN_FILE 2>/dev/null)
366368
SYNC_WARN_COUNT=${SYNC_WARN_COUNT:-0} #value is zero if file does not exist or does not contain what we are expecting
367-
fi
368369
if [ $SYNC_WARN_COUNT -ge $SYNC_WARN_THRESHOLD ]; then
369-
# if there are 0 warn counts do not output a message and force a sync job.
370+
# force a sync
371+
# if the warn count is zero it means the sync was already forced, do not output a dumb message and continue with the sync job.
370372
if [ $SYNC_WARN_COUNT -eq 0 ]; then
371373
echo
372374
DO_SYNC=1
373375
else
374-
# if there are more than one warn count, output a message and force a sync job. Do not need to remove warning marker here as it is automatically removed when the sync job is run by this script
376+
# if there is at least one warn count, output a message and force a sync job. Do not need to remove warning marker here as it is automatically removed when the sync job is run by this script
375377
echo "Number of threshold warning(s) ($SYNC_WARN_COUNT) has reached/exceeded threshold ($SYNC_WARN_THRESHOLD). Forcing a SYNC job to run. [`date`]"
376378
mklog "INFO: Number of threshold warning(s) ($SYNC_WARN_COUNT) has reached/exceeded threshold ($SYNC_WARN_THRESHOLD). Forcing a SYNC job to run."
377379
DO_SYNC=1
@@ -381,19 +383,19 @@ function chk_sync_warn(){
381383
((SYNC_WARN_COUNT += 1))
382384
echo $SYNC_WARN_COUNT > $SYNC_WARN_FILE
383385
if [ $SYNC_WARN_COUNT == $SYNC_WARN_THRESHOLD ]; then
384-
echo "This is the **last** warning left. NOT proceeding with SYNC job. [`date`]"
385-
mklog "This is the **last** warning left. NOT proceeding with SYNC job. [`date`]"
386+
echo "This is the **last** warning left. **NOT** proceeding with SYNC job. [`date`]"
387+
mklog "This is the **last** warning left. **NOT** proceeding with SYNC job. [`date`]"
386388
DO_SYNC=0
387389
else
388-
echo "$((SYNC_WARN_THRESHOLD - SYNC_WARN_COUNT)) threshold warning(s) until the next forced sync. NOT proceeding with SYNC job. [`date`]"
389-
mklog "INFO: $((SYNC_WARN_THRESHOLD - SYNC_WARN_COUNT)) threshold warning(s) until the next forced sync. NOT proceeding with SYNC job."
390+
echo "$((SYNC_WARN_THRESHOLD - SYNC_WARN_COUNT)) threshold warning(s) until the next forced sync. **NOT** proceeding with SYNC job. [`date`]"
391+
mklog "INFO: $((SYNC_WARN_THRESHOLD - SYNC_WARN_COUNT)) threshold warning(s) until the next forced sync. **NOT** proceeding with SYNC job."
390392
DO_SYNC=0
391393
fi
392394
fi
393395
else
394396
# NO, so let's skip SYNC
395-
echo "Forced sync is not enabled. Check $TMP_OUTPUT for details. NOT proceeding with SYNC job. [`date`]"
396-
mklog "INFO: Forced sync is not enabled. Check $TMP_OUTPUT for details. NOT proceeding with SYNC job."
397+
echo "Forced sync is not enabled. Check $TMP_OUTPUT for details. **NOT** proceeding with SYNC job. [`date`]"
398+
mklog "INFO: Forced sync is not enabled. Check $TMP_OUTPUT for details. **NOT** proceeding with SYNC job."
397399
DO_SYNC=0
398400
fi
399401
}
@@ -458,10 +460,10 @@ function prepare_mail() {
458460
MSG="Sync forced with multiple violations - Deleted files ($DEL_COUNT) / ($DEL_THRESHOLD) and changed files ($UPDATE_COUNT) / ($UP_THRESHOLD)"
459461
fi
460462
SUBJECT="[WARNING] $MSG $EMAIL_SUBJECT_PREFIX"
461-
elif [ -z "${JOBS_DONE##*"SYNC"*}" -a -z "$(grep -w "SYNC_JOB-" $TMP_OUTPUT)" ]; then
463+
elif [ -z "${JOBS_DONE##*"SYNC"*}" -a -z "$(grep -w "SYNC JOB -" $TMP_OUTPUT)" ]; then
462464
# Sync ran but did not complete successfully so lets warn the user
463465
SUBJECT="[WARNING] SYNC job ran but did not complete successfully $EMAIL_SUBJECT_PREFIX"
464-
elif [ -z "${JOBS_DONE##*"SCRUB"*}" -a -z "$(grep -w "SCRUB_JOB-" $TMP_OUTPUT)" ]; then
466+
elif [ -z "${JOBS_DONE##*"SCRUB"*}" -a -z "$(grep -w "SCRUB JOB -" $TMP_OUTPUT)" ]; then
465467
# Scrub ran but did not complete successfully so lets warn the user
466468
SUBJECT="[WARNING] SCRUB job ran but did not complete successfully $EMAIL_SUBJECT_PREFIX"
467469
else

0 commit comments

Comments
 (0)