Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit d09fca3

Browse files
Corben78unknwon
authored andcommitted
Add a (Open)SuSE init script (#3558)
1 parent dadd35b commit d09fca3

File tree

1 file changed

+115
-0
lines changed
  • scripts/init/suse

1 file changed

+115
-0
lines changed

scripts/init/suse/gogs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/sh
2+
#
3+
# /etc/init.d/gogs
4+
#
5+
# Runs the Gogs Go Git Service.
6+
#
7+
8+
### BEGIN INIT INFO
9+
# Provides: gogs
10+
# Required-Start: $remote_fs
11+
# Required-Stop: $remote_fs
12+
# Default-Start: 2 3 4 5
13+
# Default-Stop: 0 1 6
14+
# Short-Description: Start gogs at boot time.
15+
# Description: Control gogs.
16+
### END INIT INFO
17+
18+
# Default values
19+
20+
NAME=gogs
21+
GOGS_HOME=/home/git/gogs
22+
GOGS_PATH=${GOGS_HOME}/$NAME
23+
GOGS_USER=git
24+
SERVICENAME="Go Git Service"
25+
LOCKFILE=/var/lock/subsys/gogs
26+
LOGPATH=${GOGS_HOME}/log
27+
LOGFILE=${LOGPATH}/error.log
28+
# gogs creates its own gogs.log from stdout
29+
RETVAL=0
30+
31+
# Read configuration from /etc/sysconfig/gogs to override defaults
32+
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
33+
34+
# Don't do anything if nothing is installed
35+
test -x ${GOGS_PATH} || { echo "$NAME not installed";
36+
if [ "$1" = "stop" ]; then exit 0;
37+
else exit 5; fi; }
38+
39+
# exit if logpath dir is not created.
40+
test -r ${LOGPATH} || { echo "$LOGPATH not existing";
41+
if [ "$1" = "stop" ]; then exit 0;
42+
else exit 6; fi; }
43+
44+
# Source function library.
45+
. /etc/rc.status
46+
47+
# Reset status of this service
48+
rc_reset
49+
50+
51+
case "$1" in
52+
start)
53+
echo -n "Starting ${SERVICENAME} "
54+
55+
# As we can't use startproc, we have to check ourselves if the service is already running
56+
/sbin/checkproc ${GOGS_PATH}
57+
if [ $? -eq 0 ]; then
58+
# return skipped as service is already running
59+
(exit 5)
60+
else
61+
su - ${GOGS_USER} -c "USER=${GOGS_USER} ${GOGS_PATH} web 2>&1 >>${LOGFILE} &"
62+
fi
63+
64+
# Remember status and be verbose
65+
rc_status -v
66+
;;
67+
68+
stop)
69+
echo -n "Shutting down ${SERVICENAME} "
70+
71+
## Stop daemon with killproc(8) and if this fails
72+
## killproc sets the return value according to LSB.
73+
/sbin/killproc ${GOGS_PATH}
74+
75+
# Remember status and be verbose
76+
rc_status -v
77+
;;
78+
79+
restart)
80+
## Stop the service and regardless of whether it was
81+
## running or not, start it again.
82+
$0 stop
83+
$0 start
84+
85+
# Remember status and be quiet
86+
rc_status
87+
;;
88+
89+
status)
90+
echo -n "Checking for ${SERVICENAME} "
91+
## Check status with checkproc(8), if process is running
92+
## checkproc will return with exit status 0.
93+
94+
# Return value is slightly different for the status command:
95+
# 0 - service up and running
96+
# 1 - service dead, but /var/run/ pid file exists
97+
# 2 - service dead, but /var/lock/ lock file exists
98+
# 3 - service not running (unused)
99+
# 4 - service status unknown :-(
100+
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
101+
102+
# NOTE: checkproc returns LSB compliant status values.
103+
/sbin/checkproc ${GOGS_PATH}
104+
# NOTE: rc_status knows that we called this init script with
105+
# "status" option and adapts its messages accordingly.
106+
rc_status -v
107+
;;
108+
109+
*)
110+
echo "Usage: $0 {start|stop|status|restart}"
111+
exit 1
112+
;;
113+
114+
esac
115+
rc_exit

0 commit comments

Comments
 (0)