Import version 1.8.3
[s390-tools.git] / etc / init.d / cpuplugd
blobe815b7ed669a59032cb12a726ecbac3a2cbdc59b
1 #!/bin/bash
2 ### BEGIN INIT INFO
3 # Provides: cpuplugd
4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Should-Start:
7 # Should-Stop:
8 # Default-Start: 2 3 4 5
9 # Default-Stop: 0 1 6
10 # Short-Description: Start the cpu hotplug daemon for Linux on System z
11 # Description: Starts the cpuplugd. It uses the configuration
12 # file /etc/sysconfig/cpuplugd
13 ### END INIT INFO
15 # chkconfig: 2345 01 99
17 DAEMON=cpuplugd
18 DAEMON_PATH=/usr/sbin/cpuplugd
19 CONFIG_FILE=/etc/sysconfig/cpuplugd
20 RUN_PID_FILE=/var/run/cpuplugd.pid
21 RETVAL=0
22 OPTIONS="-c $CONFIG_FILE"
24 # source function library
25 . /lib/lsb/init-functions
27 start()
29 if [ ! -f $RUN_PID_FILE ]; then
30 echo -n $"Starting $DAEMON:"
31 $DAEMON_PATH $OPTIONS
32 if [ $? == "0" ]; then
33 touch /var/lock/subsys/cpuplugd
34 log_success_msg
35 else
36 log_failure_msg
38 echo
39 else
40 echo "$DAEMON (pid $(cat $RUN_PID_FILE)) is already running..."
41 echo
45 stop()
47 echo -n $"Stopping $DAEMON:"
48 if [ -f $RUN_PID_FILE ]; then
49 killproc $DAEMON_PATH -TERM
50 log_success_msg
51 rm -f $RUN_PID_FILE
52 rm -f /var/lock/subsys/cpuplugd
53 else
54 log_failure_msg
56 echo
59 restart() {
60 stop
62 # We have to wait 2-3 seconds here. When the daemon is stopped it takes
63 # the time we sleep to reactivate cpus. If we restart to fast and
64 # cpuplugd wasn't able to restore some settings we may get a undesired
65 # online cpu count after cpuplugd shutdown
67 sleep 4
68 start
71 status()
73 if [ ! -f $RUN_PID_FILE ]; then
74 echo "$DAEMON is not running."
75 echo
76 else
77 echo "$DAEMON (pid $(cat $RUN_PID_FILE), options: $OPTIONS) is running."
78 echo
82 reload()
84 echo -n $"Reloading $DAEMON: "
85 if [ -f $RUN_PID_FILE ]; then
86 killproc $DAEMON_PATH -HUP
87 log_success_msg
88 else
89 log_failure_msg
91 RETVAL=$?
92 echo
96 # How are we called?
97 case "$1" in
98 start)
99 start
101 stop)
102 stop
104 status)
105 status
107 restart)
108 restart
110 reload)
111 reload
114 echo "Usage: $DAEMON {start|stop|status|restart|reload}"
115 RETVAL=1
116 esac
118 exit $RETVAL