mdserver-web/plugins/gogs/init.d/gogs.tpl

111 lines
2.2 KiB
Smarty
Raw Normal View History

2018-12-14 04:39:47 -05:00
#!/bin/sh
#
# /etc/rc.d/init.d/gogs
#
# Runs the Gogs
#
#
# chkconfig: - 85 15
#
### BEGIN INIT INFO
# Provides: gogs
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: mysql postgresql
# Should-Stop: mysql postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start gogs at boot time.
# Description: Control gogs.
### END INIT INFO
# Source function library.
if [ -f /etc/init.d/functions ];then
. /etc/init.d/functions
fi
2019-03-11 05:49:14 -04:00
if [ -f /etc/rc.d/init.d/functions ];then
. /etc/rc.d/init.d/functions
fi
2018-12-14 04:39:47 -05:00
# Default values
2019-03-15 05:15:06 -04:00
export HOME={$HOME_DIR}
2019-03-15 05:24:56 -04:00
export USER={$RUN_USER}
2018-12-14 04:39:47 -05:00
NAME=gogs
GOGS_HOME={$SERVER_PATH}/gogs
GOGS_PATH=${GOGS_HOME}/$NAME
2019-03-11 04:40:29 -04:00
GOGS_USER={$RUN_USER}
2018-12-14 04:39:47 -05:00
SERVICENAME="Gogs"
LOCKFILE=/tmp/gogs.lock
LOGPATH=${GOGS_HOME}/log
LOGFILE=${LOGPATH}/gogs.log
RETVAL=0
2019-03-11 05:30:22 -04:00
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
DAEMON_OPTS="--check $NAME"
[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}"
2018-12-14 04:39:47 -05:00
status(){
isStart=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'`
if [ "$isStart" == '' ];then
2019-03-11 05:30:22 -04:00
echo -e "${SERVICENAME} not running"
2018-12-14 04:39:47 -05:00
else
2019-03-11 05:30:22 -04:00
echo -e "${SERVICENAME}(pid $(echo $isStart)) already running"
2018-12-14 04:39:47 -05:00
fi
}
start() {
isStart=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'`
if [ "$isStart" != '' ];then
echo "${SERVICENAME}(pid $(echo $isStart)) already running"
return $RETVAL
fi
cd ${GOGS_HOME}
2019-03-11 05:30:22 -04:00
echo -e "Starting ${SERVICENAME}: \c"
2019-03-11 05:49:14 -04:00
${GOGS_PATH} web > ${LOGFILE} 2>&1 &
2018-12-14 04:39:47 -05:00
RETVAL=$?
2019-03-11 05:30:22 -04:00
[ $RETVAL = 0 ] && touch ${LOCKFILE} && echo -e "\033[32mdone\033[0m"
2018-12-14 04:39:47 -05:00
return $RETVAL
}
stop() {
2019-03-11 05:49:14 -04:00
pids=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'`
arr=($pids)
2019-03-11 05:51:16 -04:00
echo -e "Stopping gogs... \c"
for p in ${arr[@]}
2019-03-11 05:49:14 -04:00
do
kill -9 $p
done
echo -e "\033[32mdone\033[0m"
2018-12-14 04:39:47 -05:00
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
reload)
stop
start
;;
*)
echo "Usage: ${NAME} {start|stop|status|restart}"
exit 1
;;
esac
exit $RETVAL