Prechádzať zdrojové kódy

fixing up init script exit codes

Haneysmith, Nathan 10 rokov pred
rodič
commit
77215182f7

+ 7 - 5
packaging/deb/init.d/grafana-server

@@ -38,7 +38,12 @@ DAEMON=/usr/sbin/$NAME
 
 if [ `id -u` -ne 0 ]; then
 	echo "You need root privileges to run this script"
-	exit 1
+	exit 4
+fi
+
+if [ ! -x $DAEMON ]; then
+  echo "Program not installed or not executable"
+  exit 5
 fi
 
 . /lib/lsb/init-functions
@@ -54,9 +59,6 @@ fi
 
 DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
 
-# Check DAEMON exists
-test -x $DAEMON || exit 0
-
 case "$1" in
   start)
 
@@ -137,7 +139,7 @@ case "$1" in
 	;;
   *)
 	log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
-	exit 1
+	exit 3
 	;;
 esac
 

+ 14 - 7
packaging/rpm/init.d/grafana-server

@@ -35,6 +35,16 @@ MAX_OPEN_FILES=10000
 PID_FILE=/var/run/$NAME.pid
 DAEMON=/usr/sbin/$NAME
 
+if [ `id -u` -ne 0 ]; then
+  echo "You need root privileges to run this script"
+  exit 4
+fi
+
+if [ ! -x $DAEMON ]; then
+  echo "Program not installed or not executable"
+  exit 5
+fi
+
 #
 # init.d / servicectl compatibility (openSUSE)
 #
@@ -55,9 +65,6 @@ fi
 
 DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
 
-# Check DAEMON exists
-test -x $DAEMON || exit 0
-
 function isRunning() {
   status -p $PID_FILE $NAME > /dev/null 2>&1
 }
@@ -69,7 +76,7 @@ case "$1" in
     isRunning
     if [ $? -eq 0 ]; then
       echo "Already running."
-      exit 2
+      exit 0
     fi
 
     # Prepare environment
@@ -90,7 +97,7 @@ case "$1" in
       # check if pid file has been written two
       if ! [[ -s $PID_FILE ]]; then
         echo "FAILED"
-        exit 3
+        exit 1
       fi
       i=0
       timeout=10
@@ -101,7 +108,7 @@ case "$1" in
         i=$(($i + 1))
         if [ $i -gt $timeout ]; then
           echo "FAILED"
-          exit 4
+          exit 1
         fi
       done
     fi
@@ -141,6 +148,6 @@ case "$1" in
     ;;
   *)
     echo -n "Usage: $0 {start|stop|restart|force-reload|status}"
-    exit 1
+    exit 3
     ;;
 esac