54 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2016-03-31 18:44:22 -07:00
GITBUCKETPATH="/home/mollusk/.gitbucket"
WARFILE="gitbucket.war"
2016-03-31 18:44:22 -07:00
LIBNOTIFY="true"
LOGDIR="/tmp"
LOGFILE="gitbucket.log"
CheckNotify()
{
if [ "${LIBNOTIFY}" = "true" ];then
notify-send "$1"
elif [ "${LIBNOTIFY}" = "false" ];then
"$1" &> /dev/null
echo "$(date +"%T"): [INFO]: libnotify support disabled" >> ${LOGDIR}/${LOGFILE}
else
echo "[ATTENTION]: Please check the logs: /tmp/gitbucket.log"
echo "$(date +"%T"): [WARNING]: LIBNOTIFY setting is invalid" >> ${LOGDIR}/${LOGFILE}
fi
}
case "$1" in
start) nohup java -jar ${GITBUCKETPATH}/${WARFILE} &> /dev/null &
2016-03-31 18:44:22 -07:00
sleep 1
2016-03-31 18:44:22 -07:00
2016-03-30 21:17:15 -07:00
PID=$(pidof java)
2016-03-31 18:44:22 -07:00
if [ "${PID}" ];then
CheckNotify "Gitbucket started on PID: ${PID}"
echo "Gitbucket started on PID: ${PID}"
2016-03-30 21:17:15 -07:00
else
2016-03-31 18:44:22 -07:00
CheckNotify "Gitbucket Failed to start!"
2016-03-30 21:17:15 -07:00
echo "Gitbucket process failed to start!"
fi
;;
2016-03-31 18:44:22 -07:00
stop) killall java
2016-03-31 18:44:22 -07:00
sleep 1
if [ ! "${PID}" ];then
CheckNotify "Gitbucket was terminated"
2016-03-30 21:17:15 -07:00
echo "Gitbucket was terminated"
else
2016-03-31 18:44:22 -07:00
CheckNotify "There was a problem terminating Gitbucket"
2016-03-30 21:17:15 -07:00
echo "There was a problem terminating Gitbucket"
fi
;;
status) ps -fC java
;;
esac