blob: 40f76ff5175707c45329650ad7318d618496de78 [file] [log] [blame]
#!/bin/sh
#
# netopeerguid.rc: netopeerguid init script
# Copyright (c) 2006-2015 CESNET, z.s.p.o.
# Author(s): David Kupka <dkupka@cesnet.cz>, Michal Vasko <mvasko@cesnet.cz>
#
# This script is written according to SysV init principles.
#
# To activate this script at the boot time simple copy this file (and
# rename it to 'netopeer' - without any suffix) into the /etc/rc.d/init.d
# directory. Then run chkconfig:
#
# chkconfig --add netopeerguid
#
# Output is logged in /var/log/netopeerguid file.
#
# Two lines below this clause are used by chkconfig(8) to set it to run
# in the boot time. The first of those two lines tells chkconfig what
# runlevels the service should be started in by default, as well as the
# start and stop priority levels. The second line contains a description
# for the service.
#
# chkconfig: 345 50 80
# description: netopeerguid startup script
BINDIR="@prefix@/bin/"
LOGFILE="/var/log/netopeerguid"
NPGUID=netopeerguid
case "$1" in
start )
echo "== Starting netopeerguid ==" >> $LOGFILE
date >> $LOGFILE
if [ `ps -C netopeerguid | wc -l` -eq 2 ]; then
echo "Failed: netopeerguid is already running." >> $LOGFILE;
echo "netopeerguid is already running.";
exit 1;
fi
$BINDIR$NPGUID -d
# for netopeerguid to start
sleep 1;
if [ `ps -C netopeerguid | wc -l` -lt 2 ]; then
echo "Failure: netopeerguid failed to start." >> $LOGFILE;
echo "netopeerguid failed to start.";
exit 1;
fi
echo "== netopeerguid start ==";
echo "Success: netopeerguid started ==" >> $LOGFILE;
;;
stop )
echo "== Stopping netopeerguid ==" >> $LOGFILE
date >> $LOGFILE
if [ `ps -C netopeerguid | wc -l` -lt 2 ]; then
echo "Failure: netopeerguid is not running." >> $LOGFILE;
echo "netopeerguid is not running.";
exit 1;
fi
killall -15 netopeerguid
sleep 2;
if [ `ps -C netopeerguid | wc -l` -eq 2 ]; then
killall -9 netopeerguid
sleep 1;
if [ `ps -C netopeerguid | wc -l` -eq 2 ]; then
echo "Failure: netopeerguid is still running." >> $LOGFILE;
echo "netopeerguid is still running.";
exit 1;
fi
fi
echo "== netopeerguid stop ==";
echo "Success: netopeerguid stopped ==" >> $LOGFILE;
;;
restart|reload )
$0 stop
$0 start
;;
status )
if [ `ps -C netopeerguid | wc -l` -eq 2 ]; then
echo "netopeerguid is running.";
else
echo "netopeerguid is stopped.";
fi
;;
* )
# Display usage of this script
echo "Usage: $0 {start|stop|restart|reload|status}"
;;
esac