I don't know Mandriva. But...
If this is like Fedora/Redhat then you need a need to create a "lock file" at startup in order to have the KNNyyyyyy rc script driven at shutdown.
If you do a 'grep touch /etc/rc5.d/*' and it gives you a lot of hits that would confirm it, I think.
If so (and I'm assuming your init.d script is named 'setwebpage'), a cheap fix would be to change your start routine in /etc/rc.d/init.d/setwebpage (or /etc/init.d/setwebpage) to
Code:
start() {
touch /var/lock/subsys/setwebpage
$NAME start
}
and your stop routine to
Code:
stop() {
/bin/rm -f /var/lock/subsys/setwebpage
$NAME stop
}
You could make it a little more elegant by checking for the existence of the lock file with
[ -f /var/lock/subsys/setwebpage ] and conditionally start or stop based on the existence or absence of the lock file.
If you are curious, in Fedora there is a script, /etc/rc, that is executed when the runlevel changes. You're going from runlevel '5' to runlevel '0' or '6', so /etc/rc0.d/Kxxsetwebpage or /etc/rc6.d/Kxxsetwebpage will be executed unless you run afoul of the following line in /etc/rc in the "kill" section.
Quote:
[ -f /var/lock/subsys/$subsys ] || [ -f /var/lock/subsys/$subsys.init ] || continue
|
where $subsys is the name of your init.d shell script.
The complete 'kill' and 'start' routines from /etc/rc in Fedora. Mandriva may differ.
Code:
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
# Check if the subsystem is already up. #[ed. long standing typo... I think it should read 'down']
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys ] || [ -f /var/lock/subsys/$subsys.init ] || continue
check_runlevel "$i" || continue
# Bring the subsystem down.
[ -n "$UPSTART" ] && initctl emit --quiet stopping JOB=$subsys
$i stop
[ -n "$UPSTART" ] && initctl emit --quiet stopped JOB=$subsys
done
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/S??}
[ -f /var/lock/subsys/$subsys ] && continue
[ -f /var/lock/subsys/$subsys.init ] && continue
check_runlevel "$i" || continue
# If we're in confirmation mode, get user confirmation
if [ "$do_confirm" = "yes" ]; then
confirm $subsys
rc=$?
if [ "$rc" = "1" ]; then
continue
elif [ "$rc" = "2" ]; then
do_confirm="no"
fi
fi
update_boot_stage "$subsys"
# Bring the subsystem up.
[ -n "$UPSTART" ] && initctl emit --quiet starting JOB=$subsys
if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
export LC_ALL=C
exec $i start
fi
$i start
[ -n "$UPSTART" ] && initctl emit --quiet started JOB=$subsys
done