func svcSeafile to start/stop services

This commit is contained in:
Asif Bacchus 2019-05-19 00:03:07 -06:00
parent c8fba00b7b
commit 4d7f697426
1 changed files with 52 additions and 0 deletions

View File

@ -176,6 +176,58 @@ function scriptHelp {
exit 1
}
### start and stop seafile services
function svcSeafile {
if [ "$1" = "start" ]; then
# start services
systemctl start seafile.service
statusSeaf=$?
systemctl start seahub.service
statusShub=$?
# check for errors
if [ $statusSeaf -eq 0 ] && [ $statusShub -eq 0 ]; then
echo -e "${info}[$(stamp)] -- [INFO] Seafile services started" \
"successfully --${normal}" >> "$logFile"
else
exitError+=("[$(stamp)] 100")
quit
fi
elif [ "$1" = "stop" ]; then
# stop services
systemctl stop seahub.service
statusShub=$?
systemctl stop seafile.service
statusSeaf=$?
# check for errors
if [ $statusSeaf -eq 0 ] && [ $statusShub -eq 0 ]; then
echo -e "${info}[$(stamp)] -- [INFO] Seafile services stopped" \
"successfully --${normal}" >> "$logFile"
else
# verify services are still actually running
pidShub=$(pgrep -f "seahub")
pidSeaf=$(pgrep -f seafile-controller)
# force stop seahub
if [ $pidShub ]; then
pkill -f "seahub"
echo -e "${warn}[$(stamp)] -- [WARN] Could NOT stop" \
"Seahub normally (forced stop) --${normal}" \
>> "$logFile"
exitWarn+=("[$(stamp)]_101")
fi
# force stop seafile
if [ $pidSeaf ]; then
pkill -f seafile-controller
echo -e "${warn}[$(stamp)] -- [WARN] Could NOT stop" \
"Seafile normally (forced stop) --${normal}" \
>> "$logFile"
exitWarn+=("[$(stamp)]_101")
fi
echo -e "${info}[$(stamp)] -- [INFO] Seafile services stopped" \
"successfully --${normal}" >> "$logFile"
fi
fi
}
### generate dynamic timestamps
function stamp {
(date +%F" "%T)