Skip to content

Commit 10abf61

Browse files
committed
Merge pull request grafana#2115 from tmonk42/exit_codes
fixing up init script exit codes
2 parents 8327960 + fcba628 commit 10abf61

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

packaging/deb/init.d/grafana-server

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ DAEMON=/usr/sbin/$NAME
3838

3939
if [ `id -u` -ne 0 ]; then
4040
echo "You need root privileges to run this script"
41-
exit 1
41+
exit 4
42+
fi
43+
44+
if [ ! -x $DAEMON ]; then
45+
echo "Program not installed or not executable"
46+
exit 5
4247
fi
4348

4449
. /lib/lsb/init-functions
@@ -54,9 +59,6 @@ fi
5459

5560
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
5661

57-
# Check DAEMON exists
58-
test -x $DAEMON || exit 0
59-
6062
case "$1" in
6163
start)
6264

@@ -137,8 +139,6 @@ case "$1" in
137139
;;
138140
*)
139141
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
140-
exit 1
142+
exit 3
141143
;;
142144
esac
143-
144-
exit 0

packaging/rpm/init.d/grafana-server

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ MAX_OPEN_FILES=10000
3535
PID_FILE=/var/run/$NAME.pid
3636
DAEMON=/usr/sbin/$NAME
3737

38+
if [ `id -u` -ne 0 ]; then
39+
echo "You need root privileges to run this script"
40+
exit 4
41+
fi
42+
43+
if [ ! -x $DAEMON ]; then
44+
echo "Program not installed or not executable"
45+
exit 5
46+
fi
47+
3848
#
3949
# init.d / servicectl compatibility (openSUSE)
4050
#
@@ -55,9 +65,6 @@ fi
5565

5666
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
5767

58-
# Check DAEMON exists
59-
test -x $DAEMON || exit 0
60-
6168
function isRunning() {
6269
status -p $PID_FILE $NAME > /dev/null 2>&1
6370
}
@@ -69,7 +76,7 @@ case "$1" in
6976
isRunning
7077
if [ $? -eq 0 ]; then
7178
echo "Already running."
72-
exit 2
79+
exit 0
7380
fi
7481

7582
# Prepare environment
@@ -90,7 +97,7 @@ case "$1" in
9097
# check if pid file has been written two
9198
if ! [[ -s $PID_FILE ]]; then
9299
echo "FAILED"
93-
exit 3
100+
exit 1
94101
fi
95102
i=0
96103
timeout=10
@@ -101,7 +108,7 @@ case "$1" in
101108
i=$(($i + 1))
102109
if [ $i -gt $timeout ]; then
103110
echo "FAILED"
104-
exit 4
111+
exit 1
105112
fi
106113
done
107114
fi
@@ -141,6 +148,6 @@ case "$1" in
141148
;;
142149
*)
143150
echo -n "Usage: $0 {start|stop|restart|force-reload|status}"
144-
exit 1
151+
exit 3
145152
;;
146153
esac

0 commit comments

Comments
 (0)