Click to See Complete Forum and Search --> : change the --retry option from start-stop-daemon


ccc
03-15-2006, 10:22 AM
hi

I have following starup script and try to get it running under suse 10.0:

#!/bin/sh

# Buyer beware! This is really only useful if you have a
# MiniPCI or other permanent wireless device.

# However, the wpa_supplicant daemon will start, and sit waiting
# for the name interface to come up. Therefore, if you want to use
# this with pcmcia or other nonsense, it may be best to ifrename
# your wireless interface if it has an "ethX" name that is variable.

PATH=/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/local/sbin/wpa_supplicant
PIDFILE="/var/run/wpasupplicant.pid"
CONFIG="/etc/wpa_supplicant.conf"
PNAME="wpa_supplicant"

# insane defaults
OPTIONS="-Bw" # daemonize and wait for interface
ENABLED=0

[ -f /etc/default/wpasupplicant ] && . /etc/default/wpasupplicant

if [ "$ENABLED" = "0" ]; then
echo "wpasupplicant: disabled, see /etc/default/wpasupplicant"
exit 0;
fi

[ -f $CONFIG ] || ( echo "No configuration file found, not starting."; \
exit 1; )

[ -f $DAEMON ] || exit 0

set -e

case "$1" in
start)
echo -n "Starting wpasupplicant: "
start-stop-daemon --start --name $PNAME --oknodo --exec $DAEMON -- -B $OPTIONS -P $PIDFILE
echo "done."
;;
stop)
echo -n "Stopping wpasupplicant: "
start-stop-daemon --stop --name $PNAME \
--oknodo --exec $DAEMON
echo "done."
if [ -f $PIDFILE ]; then
rm -f $PIDFILE;
fi
;;
reload|force-reload)
echo -n "Reloading wpasupplicant: "
start-stop-daemon --stop --signal 1 --name $PNAME --exec $DAEMON
echo "done."
;;
restart)
echo -n "Restarting wpasupplicant: "
start-stop-daemon --stop --name $PNAME \
--retry 5 --oknodo --exec $DAEMON
if [ -f $PIDFILE ]; then
rm -f $PIDFILE;
fi
start-stop-daemon --start --name $PNAME --oknodo --exec $DAEMON -- -B $OPTIONS -P $PIDFILE
echo "done."
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac

exit 0


restart)
start-stop-daemon --stop --name $PNAME \
--retry 5 --oknodo --exec $DAEMON
if [ -f $PIDFILE ]; then
rm -f $PIDFILE;
fi
;;


but if I try restart option, then I get the following error :
linux:/home/scripts # ./script restart
Restarting script: start-stop-daemon: unrecognized option `--retry'
Try `start-stop-daemon --help' for more information.


linux:/home/scripts # start-stop-daemon --help
start-stop-daemon for Debian Linux - small and fast C version written by
Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.
version 0.3.1, 1996-07-19

Usage:
start-stop-daemon -S|--start options ... -- arguments ...
start-stop-daemon -K|--stop options ...
start-stop-daemon -H|--help
start-stop-daemon -V|--version

Options (at least one of --exec|--pidfile|--user is required):
-x|--exec <executable> program to start/check if it is running
-p|--pidfile <pid-file> pid file to check
-u|--user <username>|<uid> stop this user's processes
-n|--name <process-name> start/stop processes with this name
-s|--signal <signal> signal to send (default 15)
-t|--test test mode, don't do anything
-o|--oknodo exit status 0 (not 1) if nothing done
-q|--quiet | -v, --verbose

Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo) 2 = trouble
knows someone how shoud I change the --retry option ?

kind regards
ccc

bwkaz
03-15-2006, 07:45 PM
Yes: Rewrite start-stop-daemon. ;)

It's a C program. If it doesn't support --retry, then the only solution for you is to find its sources, add support for --retry, and recompile it. (Then hope it doesn't get overwritten the next time you upgrade whatever base Debian package it comes in.)

Every other init script I've seen (that I can remember anyway) has the restart target just do:

$0 stop
sleep 1
$0 start

That should work fine here too.