libnotify control and logs

This commit is contained in:
silvernode 2016-03-31 18:44:22 -07:00
parent 8e94958f4f
commit 0308311d51

View File

@ -1,26 +1,47 @@
#!/bin/bash
GITBUCKETPATH="/home/mollusk/Downloads"
GITBUCKETPATH="/home/mollusk/.gitbucket"
WARFILE="gitbucket.war"
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 &
sleep 1
PID=$(pidof java)
if [ ${PID} ];then
notify-send "Gitbucket started on PID: ${PID}"
if [ "${PID}" ];then
CheckNotify "Gitbucket started on PID: ${PID}"
echo "Gitbucket started on PID: ${PID}"
else
notify-send "Gitbucket Failed to start!"
CheckNotify "Gitbucket Failed to start!"
echo "Gitbucket process failed to start!"
fi
;;
stop) killall java
if [ ! ${PID} ];then
notify-send "Gitbucket was terminated"
sleep 1
if [ ! "${PID}" ];then
CheckNotify "Gitbucket was terminated"
echo "Gitbucket was terminated"
else
notify-send "There was a problem terminating Gitbucket"
CheckNotify "There was a problem terminating Gitbucket"
echo "There was a problem terminating Gitbucket"
fi