SysV integration
Example SysV job configuration file:
#!/bin/sh
#
# ntservice Napatech 3GD Service
#
# description: Napatech 3GD Service
#
# chkconfig: 235 98 2
# processname: ntservice
#
# This file contains a System V init script enabling the Napatech 3GD Service
# (ntservice) to be started and stopped by a System V compatible init
# process. This includes starting the ntservice at boot time.
#
# To use this System V init script, copy this file to /etc/init.d/
#
# To enable Napatech 3GD Service to start at boot time on Red Hat or SUSE
# based systems using System V call
# $ chkconfig --add ntservice
#
# To enable Napatech 3GD Service to start at boot time on Debian based
# systems using System V call
# $ update-rc.d ntservice defaults
#
# To disable Napatech 3GD Service to start at boot time on Red Hat or SUSE
# based systems using System V call
# $ chkconfig --del ntservice
#
# To enable Napatech 3GD Service to start at boot time on Debian based
# systems using System V call
# $ update-rc.d -f ntservice remove
#
# To start the Napatech 3GD Service call
# $ service ntservice start
# This will not return until the ntservice is operational.
#
# To stop the Napatech 3GD Service call
# $ service ntservice stop
#
# To restart the Napatech 3GD Service after ntservice.ini changes call
# $ service ntservice restart
### BEGIN INIT INFO
# Provides: ntservice
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop ntservice
# Description: Napatech 3GD Service
### END INIT INFO
# Source function library.
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
# Location where Napatech 3GD Software Suite is installed
NAPATECH3_ROOT=/opt/napatech3
# Get helper function for Napatech 3GD Software Suite
. ${NAPATECH3_ROOT}/bin/.bash_ntstartstop.sh >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error sourcing ${NAPATECH3_ROOT}/bin/.bash_ntstartstop.sh"
exit 1
fi
RETVAL=0
prog="ntservice"
if [ -d /var/lock/subsys/ ]; then
lockfile=/var/lock/subsys/$prog
else
lockfile=/var/lock/$prog
fi
fn_exists() {
type $1 2>&1 | grep -q 'shell function'
}
fn_exists success || success() {
echo -n "done"
}
fn_exists failure || failure() {
echo -n "failed"
}
start() {
echo -n "Starting ntservice: "
${NAPATECH3_ROOT}/bin/ntstart.sh --managed >/dev/null && success || failure "$prog start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}
stop() {
echo -n "Shutting down ntservice: "
${NAPATECH3_ROOT}/bin/ntstop.sh --managed >/dev/null && success || failure "$prog stop"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $lockfile
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
if service_running; then
# LSB defines exit code 0 as "program is running or service is OK"
echo "ntservice (pid $NTPIDS) is running..."
exit 0
else
# LSB defines exit code 3 as "program is not running"
echo "ntservice is stopped"
exit 3
fi
;;
restart|reload)
stop && start
;;
*)
echo "Usage: <servicename> {start|stop|status|reload|restart"
exit 1
;;
esac
exit $RETVAL