Created
January 8, 2018 16:38
-
-
Save drandreaskrueger/4ba370787a2bc5bd9a107958d093b357 to your computer and use it in GitHub Desktop.
glances init.d script - does not work ... yet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: glances | |
# chkconfig: 2345 80 80 | |
# Short-Description: Start and stop the Glances server | |
### END INIT INFO | |
############## | |
######### from https://github.com/moumoul/scripting/blob/master/initd/glances | |
######### adapted a bit, e.g. to amazon default user path | |
############## | |
PATHNAME=/home/ec2-user/env/glances/bin | |
DESC="Glances server" | |
NAME=glances | |
DAEMON=$PATHNAME/$NAME | |
DAEMON_ARGS=" -s" | |
PIDFILE=/var/run/$NAME.pid | |
LOCKFILE=/var/lock/subsys/$NAME | |
# not needed, seemingly | |
# SCRIPTNAME=/etc/init.d/$NAME | |
# perhaps this helps. it was missing from the original script | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 0 | |
# Read configuration variable file if it is present | |
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME | |
# Source function library | |
INITD=/etc/rc.d/init.d | |
. $INITD/functions | |
start(){ | |
echo -n $"Starting $NAME: " | |
[ -x $DAEMON ] || exit 5 | |
daemon --pidfile ${PIDFILE} $DAEMON $DAEMON_ARGS & | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch ${LOCKFILE} && pgrep -f $NAME > ${PIDFILE} | |
} | |
stop(){ | |
echo -n $"Stopping $NAME: " | |
if [ -f $PIDFILE ] ; then | |
killall $NAME | |
RETVAL=$? | |
echo | |
else | |
RETVAL=2 | |
fi | |
if [ $RETVAL -eq 0 ]; then | |
rm -f ${PIDFILE} ${LOCKFILE} | |
fi | |
} | |
restart(){ | |
stop | |
start | |
} | |
_status(){ | |
status -p ${PIDFILE} ${NAME} | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
status) | |
_status | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|status}" | |
RETVAL=2 | |
;; | |
esac | |
exit $RETVAL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see nicolargo/glances#1215 for explanations