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