bump release number
[pingofdeath.git] / pod.src
1 #! /bin/bash
2 #include INTEL_LICENSE.txt
3 #
4 ########################################################################
5 #
6 # PlanetLab Ping Of Death
7 #
8 ########################################################################
9 #
10 # DESCRIPTION
11 #
12 # This shell script takes care of starting and stopping Planetlab
13 # Ping-Of-Death.
14 #
15 # The Planetlab POD is a Linux kernel patch that creates the feature
16 # of resetting and rebooting a computer when a particularily
17 # formatted ICMP "ping" commmand is received.
18 #
19 # A PlanetLab node's kernel gets a host, mask and hash value through
20 # sysctl's that are performed on the node.  The node then looks
21 # for an ICMP packet from a host matching the host/mask and, if the
22 # packet payload is the hash value, the node forces an immediate
23 # reboot.
24 #
25 # HISTORY
26 #
27 # May 17, 2003    -   Paul Brett <paul.brett@intel.com>
28 #                     Initial version based on the work of 
29 #                     Robert Adams <robert.adams@intel.com> and EMULAB
30 #
31 # chkconfig: - 11 99
32 # description: enable Ping of Death
33
34 # Source function library.
35 . /etc/init.d/functions
36
37 # Source networking configuration.
38 . /etc/sysconfig/network
39
40 #include enable_pod.sh
41 #include disable_pod.sh
42 #include status_pod.sh
43
44 echo -n "PlanetLab Ping Of Death "
45
46 CONF=/etc/ipod.conf
47
48 if [[ -r $CONF ]]
49 then
50     # load the POD configuration file
51     . $CONF
52 else
53     # no POD configuration file - failed
54     echo
55     action $"Missing configuration file $CONF" /bin/false
56     exit 1
57 fi
58
59 # Check that networking is up.
60 if [[ ${NETWORKING} = "no" ]]
61 then
62     action $"" /bin/false
63     exit 1
64 fi
65
66 # Check the POD parameters
67 if [[ "$HASH" == "" ]]
68 then
69     echo 
70     action $"Missing HASH in $CONF" /bin/false
71     exit 1
72 fi
73
74 if [[ "$IP_SUBNET" == "" ]]
75 then
76     echo
77     action $"Missing IP_SUBNET in $CONF" /bin/false
78     exit 1
79 fi
80
81 if [[ "$IP_MASK" == "" ]]
82 then
83     echo
84     action $"Missing IP_MASK in $CONF" /bin/false
85     exit 1
86 fi
87
88 # See how we were called.
89 case "$1" in
90   start)
91         enable_pod $IP_SUBNET $IP_MASK $IP_HASH
92         RETVAL=$?
93         if [[ $RETVAL -eq 0 ]]
94         then
95             action $"" /bin/true
96         else
97             action $"" /bin/false
98         fi
99         ;;
100   stop)
101         disable_pod
102         RETVAL=$?
103         if [[ $RETVAL -eq 0 ]]
104         then
105             action $"" /bin/true
106         else
107             action $"" /bin/false
108         fi
109         ;;
110   status)
111         status_pod
112         RETVAL=$?
113         ;;
114   restart|reload)
115         disable_pod
116         enable_pod
117         RETVAL=$?
118         ;;
119   *)
120         echo $"Usage: $0 {start|stop|restart|status}"
121         exit 1
122 esac