From 6185d6e4930342de18d7f44ec3aebd611c53bfba Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 18 Jun 2014 10:41:14 +0200 Subject: Add init.d script for centos. --- etc/Makefile.am | 8 ++++- etc/miavd.in | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 etc/miavd.in (limited to 'etc') diff --git a/etc/Makefile.am b/etc/Makefile.am index 507c8e1..60845db 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -1,12 +1,15 @@ EXTRA_DIST = \ + miavd.in \ miav.conf \ miavd.conf \ multicast.conf sysconfdir=${prefix}/etc/miav - dist_sysconf_DATA = +initddir=${prefix}/etc/init.d +dist_initd_DATA = + if WITH_CLIENT dist_sysconf_DATA += \ miav.conf @@ -16,4 +19,7 @@ if WITH_SERVER dist_sysconf_DATA += \ miavd.conf \ multicast.conf + +dist_initd_DATA += \ + miavd endif diff --git a/etc/miavd.in b/etc/miavd.in new file mode 100644 index 0000000..f36330b --- /dev/null +++ b/etc/miavd.in @@ -0,0 +1,103 @@ +#!/bin/bash +# +# chkconfig: - 65 34 +# description: Start MIaV server + +### BEGIN INIT INFO +# Provides: miavd +# Required-Start: $network +# Should-Start: $syslog $named +# Short-Description: start miav server +# Description: starts the miav server +### END INIT INFO + +# Source function library. +. /etc/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +prog=miavd +lockfile="@prefix@/var/lock/subsys/$prog" +_CONF="@prefix@/etc/miav.conf" +_BIN="@exec_prefix@/bin/$prog" +_LOG="@prefix@/var/log/$prog/$prog.log" +_PID="@prefix@/var/run/$prog.pid" + +start() { +# [ "$EUID" != "0" ] && exit 4 + [ "$NETWORKING" = "no" ] && exit 1 + [ -x "$_BIN" ] || exit 5 + + echo -n $"$prog: Starting miavd server: " + + if [ -f $lockfile ] + then + echo -n "Already started" + failure + echo + return 4 + fi + + export LD_LIBRARY_PATH=$_PREFIX/lib +# $_BIN --pidfile ${_PID} --config ${_CONF} -D +all --logfile ${_LOG} &> /dev/null + $_BIN --config ${_CONF} -D +all &> /dev/null + RETVAL=$? + [ $RETVAL -eq 0 ] && success || failure + echo + if [ $RETVAL -eq 0 ]; then + touch $lockfile + fi + return $RETVAL +} + +#status() { +# [ -f $lockfile ] || return 3 +# status -p ${_PID} miavd +# status miavd +#} + +stop() { + echo -n $"$prog: Stopping miav server: " + if [ ! -f $lockfile ] + then + echo -n "Not started" + failure + echo + exit 4 + fi +# [ "$EUID" != "0" ] && exit 4 +# kill -s INT $(cat ${_PID}) + killall -9 miavd + RETVAL=$? + if [ $RETVAL -eq 0 ] + then + rm -f $lockfile + success + else + failure + fi + echo + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status miavd + ;; + restart|force-reload) + stop + start + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|force-reload}" + exit 2 +esac + -- cgit v1.2.3