updated on Thu Jan 12 08:01:00 UTC 2012
[aur-mirror.git] / inetsim / inetsim.rc
blob29f41e0949f61bc55a24988aba7c69f5cc2b9343
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: inetsim Internet Simulation
4 # Required-Start: $local_fs $remote_fs $syslog $network $time
5 # Required-Stop: $local_fs $remote_fs $syslog $network
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: start and stop the internet simulation
9 # Description: inetsim is a software suite for simulating common internet services
10 ### END INIT INFO
12 # Author inetsim: Matthias Eckert <me@inetsim.org>
13 # Author rc-file: Markus Blasl <markus.blasl (gmail)>
15 # PATH should only include /usr/* if it runs after the mountnfs.sh script
16 PATH=/sbin:/usr/sbin:/bin:/usr/bin
17 DESC="internet service simulation suite"
18 NAME=inetsim
19 DAEMON=/usr/bin/inetsim
20 DAEMON_ARGS=""
21 PIDFILE=/var/run/$NAME.pid
22 SCRIPTNAME=/etc/rc.d/$NAME
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
27 # Read configuration variable file if it is present
28 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
30 . /etc/rc.conf
31 . /etc/rc.d/functions
33 if [ ! x"$ENABLED" = x"1" -a ! "$1" = "stop" ]; then
34 printhl "Edit /etc/default/inetsim to start inetsim"
35 exit 0
38 if [ `echo "$DAEMON_ARGS" | grep -c '\-\-pidfile'` -ne 0 ] && [ ! -f $PIDFILE ]; then
39 PIDFILE=`echo "$DAEMON_ARGS" | sed s/=/\ /g | awk -F'--pidfile ' '{print $2}' | cut -d' ' -f1 | cut -f1`
43 # Function that starts the daemon/service
45 do_start()
47 # Return
48 # 0 if daemon has been started
49 # 1 if daemon was already running
50 # 2 if daemon could not be started
51 [ ! -f $PIDFILE ] || return 1
52 if [ x"$AUTO_CONF" = x"1" -a -x "/usr/share/inetsim/contrib/gen_config.pl" ]; then
53 /usr/share/inetsim/contrib/gen_config.pl
54 fi
55 perl $DAEMON &
56 # Add code here, if necessary, that waits for the process to be ready
57 # to handle requests from services started subsequently which depend
58 # on this one. As a last resort, sleep for some time.
59 sleep 3
63 # Function that stops the daemon/service
66 case "$1" in
67 start)
68 [ "$VERBOSE" != no ] && stat_busy "Starting $DESC: $NAME"
69 do_start
70 if [ $? -gt 0 ]; then
71 stat_fail
72 else
73 add_daemon $NAME
74 stat_done
77 stop)
78 [ "$VERBOSE" != no ] && stat_busy "Stopping $DESC: $NAME"
79 if [ -a $PIDFILE ]
80 then
81 PID=`cat $PIDFILE`
82 kill $PID > /dev/null
84 if [ $? -gt 0 ]; then
85 stat_fail
86 else
87 rm $PIDFILE
88 rm_daemon $NAME
89 stat_done
91 else
92 stat_done
95 restart|force-reload)
97 # If the "reload" option is implemented then remove the
98 # 'force-reload' alias
100 $0 stop
101 sleep 1
102 $0 start
105 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
106 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
107 exit 3
109 esac