RFC: lnst-slave init script

Jan Tluka jtluka at redhat.com
Mon Feb 4 16:53:16 UTC 2013


Hello everyone,

since some of the testing we do is targeted at RHEL releases that does not
have systemd I've created an initscript that seems to work with the current
RHEL6 release. See it attached.

Radek, should I put it under dist directory? If so, I'll post a patch.

Any comments welcome!

-Jan
-------------- next part --------------
#!/bin/bash
#
# lnst		Starts up the LNST slave daemon
#
# chkconfig: - 20 80 
# description: LNST is a framework to automate network configuration and
#              testing. This service starts up the LNST slave daemon.
#
# processname: lnst
# pidfile: /var/run/lnst-slave.pid

### BEGIN INIT INFO
# Provides: lnst
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Short-Description: Starts up the LNST slave daemon
# Description:       LNST is a framework to automate network configuration and
#		     testing. This service starts up the LNST slave daemon.
### END INIT INFO

# source function library
. /etc/rc.d/init.d/functions

RETVAL=0
prog="lnst-slave"
lockfile=/var/lock/subsys/$prog

# Some functions to make the below more readable
LNST=/usr/bin/lnst-slave
PID_FILE=/var/run/lnst-slave.pid
OPTIONS="--daemonize"

start()
{
	[ -x $LNST ] || exit 5

	echo -n $"Starting $prog: "
	$LNST $OPTIONS && success || failure
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $lockfile
	echo
	return $RETVAL
}

stop()
{
	echo -n $"Stopping $prog: "
        killproc lnst-slave
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f $lockfile
	echo
}

reload() {
	restart
}

restart() {
	stop
	start
}

force_reload() {
	restart
}

rh_status() {
	status lnst-slave
}

rh_status_q() {
	rh_status >/dev/null 2>&1
}

case "$1" in
	start)
		rh_status_q && exit 0
		$1
		;;
	stop)
		rh_status_q || exit 0
		$1
		;;
	restart)
		$1
		;;
	reload)
		rh_status_q || exit 7
		$1
		;;
	force-reload)
		$1
		;;
	condrestart|try-restart)
		rh_status_q || exit 0
		restart
		;;
	status)
		rh_status
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
		RETVAL=2
esac
exit $RETVAL


More information about the LNST-developers mailing list