mirror of
https://github.com/grafana/grafana.git
synced 2025-01-21 22:13:38 -06:00
Packaging: Remove sysvinit references / support from rhel packaging (#97068)
Remove sysvinit references / support from rhel packaging
This commit is contained in:
parent
53052def52
commit
3448384e0d
@ -5,24 +5,12 @@ set -e
|
||||
[ -f /etc/sysconfig/grafana-server ] && . /etc/sysconfig/grafana-server
|
||||
|
||||
startGrafana() {
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl daemon-reload
|
||||
/bin/systemctl start grafana-server.service
|
||||
elif [ -x /etc/init.d/grafana-server ] ; then
|
||||
/etc/init.d/grafana-server start
|
||||
elif [ -x /etc/rc.d/init.d/grafana-server ] ; then
|
||||
/etc/rc.d/init.d/grafana-server start
|
||||
fi
|
||||
/bin/systemctl daemon-reload
|
||||
/bin/systemctl start grafana-server.service
|
||||
}
|
||||
|
||||
stopGrafana() {
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl stop grafana-server.service > /dev/null 2>&1 || :
|
||||
elif [ -x /etc/init.d/grafana-service ] ; then
|
||||
/etc/init.d/grafana-service stop
|
||||
elif [ -x /etc/rc.d/init.d/grafana-service ] ; then
|
||||
/etc/rc.d/init.d/grafana-service stop
|
||||
fi
|
||||
/bin/systemctl stop grafana-server.service > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
|
||||
@ -77,18 +65,12 @@ if [ $1 -eq 1 ] ; then
|
||||
find /etc/grafana -type f -exec chmod 640 {} ';'
|
||||
find /etc/grafana -type d -exec chmod 755 {} ';'
|
||||
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
echo "### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd"
|
||||
echo " sudo /bin/systemctl daemon-reload"
|
||||
echo " sudo /bin/systemctl enable grafana-server.service"
|
||||
echo "### You can start grafana-server by executing"
|
||||
echo " sudo /bin/systemctl start grafana-server.service"
|
||||
elif [ -x /sbin/chkconfig ] ; then
|
||||
echo "### NOT starting grafana-server by default on bootup, please execute"
|
||||
echo " sudo /sbin/chkconfig --add grafana-server"
|
||||
echo "### In order to start grafana-server, execute"
|
||||
echo " sudo service grafana-server start"
|
||||
fi
|
||||
echo "### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd"
|
||||
echo " sudo /bin/systemctl daemon-reload"
|
||||
echo " sudo /bin/systemctl enable grafana-server.service"
|
||||
echo "### You can start grafana-server by executing"
|
||||
echo " sudo /bin/systemctl start grafana-server.service"
|
||||
|
||||
elif [ $1 -ge 2 ] ; then
|
||||
if [ "$RESTART_ON_UPGRADE" == "true" ]; then
|
||||
stopGrafana
|
||||
|
@ -1,160 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# chkconfig: 2345 80 05
|
||||
# description: Grafana web server & backend
|
||||
# processname: grafana
|
||||
# config: /etc/grafana/grafana.ini
|
||||
# pidfile: /var/run/grafana.pid
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: grafana
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start grafana at boot time
|
||||
### END INIT INFO
|
||||
|
||||
# tested on
|
||||
# 1. New lsb that define start-stop-daemon
|
||||
# 3. Centos with initscripts package installed
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
NAME=grafana-server
|
||||
DESC="Grafana Server"
|
||||
DEFAULT=/etc/sysconfig/$NAME
|
||||
|
||||
GRAFANA_USER=grafana
|
||||
GRAFANA_GROUP=grafana
|
||||
GRAFANA_HOME=/usr/share/grafana
|
||||
CONF_DIR=/etc/grafana
|
||||
WORK_DIR=$GRAFANA_HOME
|
||||
DATA_DIR=/var/lib/grafana
|
||||
PLUGINS_DIR=/var/lib/grafana/plugins
|
||||
LOG_DIR=/var/log/grafana
|
||||
CONF_FILE=$CONF_DIR/grafana.ini
|
||||
PROVISIONING_CFG_DIR=$CONF_DIR/provisioning
|
||||
MAX_OPEN_FILES=10000
|
||||
PID_FILE=/var/run/$NAME.pid
|
||||
DAEMON=$GRAFANA_HOME/bin/grafana
|
||||
|
||||
if [ ! -x $DAEMON ]; then
|
||||
echo "Program not installed or not executable"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
#
|
||||
# init.d / servicectl compatibility (openSUSE)
|
||||
#
|
||||
if [ -f /etc/rc.status ]; then
|
||||
. /etc/rc.status
|
||||
rc_reset
|
||||
fi
|
||||
|
||||
#
|
||||
# Source function library.
|
||||
#
|
||||
if [ -f /etc/rc.d/init.d/functions ]; then
|
||||
. /etc/rc.d/init.d/functions
|
||||
fi
|
||||
|
||||
# overwrite settings from default file
|
||||
if [ -f "$DEFAULT" ]; then
|
||||
. "$DEFAULT"
|
||||
fi
|
||||
|
||||
DAEMON_OPTS="server --pidfile=${PID_FILE} --config=${CONF_FILE} --packaging=rpm cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"
|
||||
|
||||
function isRunning() {
|
||||
status -p $PID_FILE $NAME > /dev/null 2>&1
|
||||
}
|
||||
|
||||
function checkUser() {
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
echo "You need root privileges to run this script"
|
||||
exit 4
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
checkUser
|
||||
isRunning
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Already running."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prepare environment
|
||||
mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$LOG_DIR" "$DATA_DIR"
|
||||
touch "$PID_FILE" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$PID_FILE"
|
||||
|
||||
if [ -n "$MAX_OPEN_FILES" ]; then
|
||||
ulimit -n $MAX_OPEN_FILES
|
||||
fi
|
||||
|
||||
# Start Daemon
|
||||
cd $GRAFANA_HOME
|
||||
action $"Starting $DESC: ..." su -s /bin/sh -c "nohup ${DAEMON} ${DAEMON_OPTS} >> /dev/null 3>&1 &" $GRAFANA_USER 2> /dev/null
|
||||
return=$?
|
||||
if [ $return -eq 0 ]
|
||||
then
|
||||
sleep 1
|
||||
# check if pid file has been written to
|
||||
if ! [[ -s $PID_FILE ]]; then
|
||||
echo "FAILED"
|
||||
exit 1
|
||||
fi
|
||||
i=0
|
||||
timeout=10
|
||||
# Wait for the process to be properly started before exiting
|
||||
until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1
|
||||
do
|
||||
sleep 1
|
||||
i=$(($i + 1))
|
||||
if [ $i -gt $timeout ]; then
|
||||
echo "FAILED"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exit $return
|
||||
;;
|
||||
stop)
|
||||
checkUser
|
||||
echo -n "Stopping $DESC: ..."
|
||||
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
killproc -p $PID_FILE -d 20 $NAME
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "$DESC is not running but pid file exists, cleaning up"
|
||||
elif [ $? -eq 3 ]; then
|
||||
PID="`cat $PID_FILE`"
|
||||
echo "Failed to stop $DESC (pid $PID)"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
echo ""
|
||||
exit 0
|
||||
else
|
||||
echo "(not running)"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
status)
|
||||
status -p $PID_FILE $NAME
|
||||
exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
$0 stop
|
||||
sleep 1
|
||||
fi
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|force-reload|status}"
|
||||
exit 3
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user