Skip to content

Instantly share code, notes, and snippets.

@nikushi
Created February 18, 2013 07:25
Show Gist options
  • Save nikushi/4975644 to your computer and use it in GitHub Desktop.
Save nikushi/4975644 to your computer and use it in GitHub Desktop.
smokeping start/stop script
#!/bin/sh
#
# chkconfig: - 86 14
# description: smokeping init script
# processname: smokeping
# config: /usr/local/smokeping/etc/smokeping.conf
# pidfile: /usr/local/var/smokeping.pid
# Source function library.
. /etc/rc.d/init.d/functions
# the path to your PID file
# path to smokeping script
smokeping=/usr/local/smokeping/bin/smokeping
smokeping_config=/usr/local/smokeping/etc/smokeping.conf
smokeping_logfile=/usr/local/smokeping/var/log/smokeping.log
pidfile=/usr/local/smokeping/var/smokeping.pid
lockfile=/var/lock/subsys/smokeping
smokeping_opts="--config=${smokeping_config} --logfile=${smokeping_logfile}"
prog=smokeping
run_user=smokeping
RETVAL=0
STOP_TIMEOUT=10
start() {
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} --user $run_user $smokeping $smokeping_opts
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $smokeping
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! $smokeping $smokeping_opts --check >&/dev/null; then
echo $"not reloading due to configuration syntax error"
failure $"not reloading $smokeping due to configuration syntax error"
else
$smokeping $smokeping_opts --reload
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure $"smokeping reloading"
fi
fi
echo
}
restart() {
echo -n $"Restarting $prog: "
if ! $smokeping $smokeping_opts --check >&/dev/null; then
echo $"not restarting due to configuration syntax error"
failure $"not restarting $smokeping due to configuration syntax error"
else
$smokeping $smokeping_opts --restart
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure $"smokeping restarting"
fi
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $smokeping
RETVAL=$?
;;
reload)
reload
;;
restart)
restart
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status}"
RETVAL=2
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment