2 # Copyright (c) 1995-2001 SuSE GmbH Nuernberg, Germany.
4 # Author: Hannes Reinecke <feedback@suse.de>
10 # Required-Start: $syslog
11 # Required-Stop: $syslog
13 # Default-Stop: 0 1 2 4 6
14 # Short-Description: Starts multipath daemon
15 # Description: Starts the multipath daemon
18 PATH=/bin:/usr/bin:/sbin:/usr/sbin
19 DAEMON=/sbin/multipathd
20 PIDFILE=/var/run/multipathd.pid
24 # Set the maximum number of open files
27 # Set to enable asynchronous daemon startup
30 test -x $DAEMON || exit 5
34 # First reset status of this service
39 echo -n "Starting multipathd"
41 if $DAEMON -k"show daemon" > /dev/null 2>&1 ; then
42 echo -n " (multipathd running)"
49 # Set the maximum number of open files
50 if [ -n "$MAX_OPEN_FDS" ] ; then
51 ulimit -n $MAX_OPEN_FDS
56 if [ -n "$DAEMON_ASYNC_STARTUP" ] ; then
60 # Wait for the daemon to start up
61 status=$($DAEMON -k'show daemon' 2> /dev/null)
62 timeout=$MPATH_INIT_TIMEOUT
63 while [ $timeout -gt 0 ] ; do
64 if [ -n "$status" ] ; then
67 # Configuration might be taking some time,
68 # so don't increase the timeout here
69 [ "$STATUS" != "configure" ] && timeout=$(( $timeout - 1 ))
71 [ "$STATUS" == "running" ] && break
73 timeout=$(( $timeout - 1 ))
76 status=$($DAEMON -k'show daemon' 2> /dev/null)
78 if [ -z "$status" ] ; then
81 if [ $timeout -le 0 ] ; then
84 # Remember status and be verbose
88 echo -n "Shutting down multipathd"
90 # Try to get PID from daemon
91 status=$($DAEMON -k'show daemon' 2> /dev/null)
92 if [ -n "$status" ] ; then
97 # Fallback to PID file for older versions
98 if [ -z "$PID" ] || [ "$PID" == "multipath-tools" ] ; then
99 if [ -f $PIDFILE ]; then
100 PID="$(cat $PIDFILE)"
108 # Shutdown the daemon via CLI
109 if [ "$STATUS" = "running" ] ; then
110 status=$($DAEMON -k'shutdown' 2> /dev/null)
111 if [ "$status" = "ok" ] ; then
112 timeout=$MPATH_INIT_TIMEOUT
113 while [ $timeout -gt 0 ] ; do
114 PROCNAME="$(ps -p $PID -o comm=)"
115 if [ "$PROCNAME" != "multipathd" ] &&
116 [ "$PROCNAME" != "multipathd <defunct>" ] ; then
121 timeout=$(( $timeout - 1 ))
125 # Kill the daemon if the above failed
126 if [ -n "$PID" -a "$STATUS" != "shutdown" ] ; then
128 timeout=$MPATH_INIT_TIMEOUT
129 while [ $timeout -gt 0 ] ; do
130 PROCNAME="$(ps -p $PID -o comm=)"
131 if [ "$PROCNAME" != "multipathd" ] &&
132 [ "$PROCNAME" != "multipathd <defunct>" ] ; then
137 timeout=$(( $timeout - 1 ))
140 if [ $STATUS != "shutdown" ] ; then
141 echo -n " (still running)"
145 # Remember status and be verbose
149 ## Stop the service and if this succeeds (i.e. the
150 ## service was running before), start it again.
151 $0 status >/dev/null && $0 restart
153 # Remember status and be quiet
156 restart|force-reload)
157 ## Stop the service and regardless of whether it was
158 ## running or not, start it again.
162 # Remember status and be quiet
166 ## Like force-reload, but if daemon does not support
167 ## signalling, do nothing (!)
169 $DAEMON -k"reconfigure" > /dev/null 2>&1
171 # Remember status and be quiet
175 echo -n "Checking for multipathd: "
177 # Status has a slightly different for the status command:
178 # 0 - service running
179 # 1 - service dead, but /var/run/ pid file exists
180 # 2 - service dead, but /var/lock/ lock file exists
181 # 3 - service not running
183 status=$($DAEMON -k'show daemon' 2> /dev/null)
184 if [ -n "$status" ]; then
192 ## Optional: Probe for the necessity of a reload,
193 ## give out the argument which is required for a reload.
196 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"