func seafSvc to control services

This commit is contained in:
Asif Bacchus 2019-05-22 22:58:07 -06:00
parent 415f329229
commit 1f5f201d93

View File

@ -18,6 +18,29 @@ mag="\e[95m"
### functions ### functions
# control seafile services (systemd)
seafSvc () {
if [ "$1" = "start" ]; then
if ! systemctl start "${seafSvc}" >> "$logFile" 2>&1; then
echo "error starting seafile service"
exit 100
fi
if ! systemctl start "${seafHub}" >> "$logFile" 2>&1; then
echo "error starting seahub service"
exit 101
fi
elif [ "$1" = "stop" ]; then
if ! systemctl stop "${seafHub}" >> "$logFile" 2>&1; then
echo "error stopping seahub service"
exit 103
fi
if ! systemctl stop "${seafSvc}" >> "$logFile" 2>&1; then
echo "error stopping seafile service"
exit 102
fi
fi
}
# generate dynamic timestamps # generate dynamic timestamps
stamp () { stamp () {
(date +%F" "%T) (date +%F" "%T)
@ -34,6 +57,14 @@ scriptPath="$( CDPATH= cd -- "$( dirname -- "$0" )" && pwd -P )"
scriptName="$( basename "$0" )" scriptName="$( basename "$0" )"
logFile="$scriptPath/${scriptName%.*}.log" logFile="$scriptPath/${scriptName%.*}.log"
# seafile service
offlineBackup=0
seafSvc="seafile.service"
seafHub="seahub.service"
# seafile directories
seafDir="/opt/seafile"
dataDir="/var/seafile"
### start logging ### start logging
printf "${mag}[%s] --- Start %s execution ---${norm}\n" \ printf "${mag}[%s] --- Start %s execution ---${norm}\n" \
@ -42,6 +73,9 @@ printf "${cyan}[%s] -- [INFO] Log located at ${yellow}%s${cyan} --${norm}\n" \
"$(stamp)" "$logFile" >> "$logFile" "$(stamp)" "$logFile" >> "$logFile"
### stop seahub and sefile service