Added ncMaint sections with info messages.

Changed ncMaint fcn to condense code.
This commit is contained in:
Asif Bacchus 2018-10-03 15:01:10 -06:00
parent a4c8432882
commit 1a70bafdd8

View File

@ -69,23 +69,12 @@ function checkExist {
fi fi
} }
### ncMaint - perform NextCloud maintenance mode entry and exit ### ncMaint - pass requested mode change type to NextCloud occ
function ncMaint { function ncMaint {
if [ "$1" = "on" ]; then su -c "php ${ncRoot}/occ maintenance:mode --$1" - "${webUser}" \
echo -e "${info}${stamp} -- [INFO] Putting NextCloud in maintenance" \
"mode --${normal}" >> "$logFile"
su -c "php ${ncRoot}/occ maintenance:mode --on" - "${webUser}" \
>> "$logFile" 2>&1 >> "$logFile" 2>&1
maintResult="$?" maintResult="$?"
return "$maintResult" return "$maintResult"
elif [ "$1" = "off" ]; then
echo -e "${info}${stamp} -- [INFO] Exiting NextCloud maintenance" \
"mode --${normal}" >> "$logFile"
su -c "php ${ncRoot}/occ maintenance:mode --off" - "${webUser}" \
>> "$logFile" 2>&1
maintResult="$?"
return "$maintResult"
fi
} }
### cleanup - cleanup files and directories created by this script ### cleanup - cleanup files and directories created by this script
@ -160,7 +149,8 @@ warningExplain=()
### Error codes ### Error codes
errorExplain[100]="Could not put NextCloud into Maintenance mode" errorExplain[100]="Could not put NextCloud into maintenance mode"
errorExplain[101]="Could not exit NextCloud maintenance mode"
### Warning codes & messages ### Warning codes & messages
warningExplain[111]="Could not remove SQL dump file and directory, please remove manually" warningExplain[111]="Could not remove SQL dump file and directory, please remove manually"
@ -334,14 +324,28 @@ fi
### Put NextCloud in maintenance mode ### Put NextCloud in maintenance mode
#ncMaint on ncMaint on
# check if successful # check if successful
#if [ "$maintResult" = "0" ]; then if [ "$maintResult" = "0" ]; then
# echo -e "${bold}${cyan}${stamp}...done${normal}" >> "$logFile" echo -e "${info}${stamp} -- [INFO] NextCloud now in maintenance mode --" \
#else "${normal}" >> "$logFile"
# cleanup 503 else
# quit 100 cleanup 503
#fi quit 100
fi
### Exit NextCloud maintenance mode
ncMaint off
# check if successful
if [ "$maintResult" = "0" ]; then
echo -e "${info}${stamp} -- [INFO] NextCloud now in normal operating mode" \
"--${normal}" >> "$logFile"
else
cleanup 503
quit 101
fi
### Exit script ### Exit script
echo -e "${bold}${default}${stamp} ***Normal exit process***${normal}" \ echo -e "${bold}${default}${stamp} ***Normal exit process***${normal}" \