You are not logged in.

#1 2007-08-14 12:55:00

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

/etc/rc.shutdown daemon question

Here a piece of /etc/rc.shutdown:

if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
    # Shutdown daemons
    let i=${#DAEMONS[@]}
    while [[ i -ge 0 ]]; do
        if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
            /etc/rc.d/${DAEMONS[$i]#@} stop
        fi
        let i=i-1
    done

    # find any leftover daemons and shut them down
    if [ -d /var/run/daemons ]; then
        for daemon in `ls /var/run/daemons`; do
            /etc/rc.d/$daemon stop
        done
    fi
fi

What does the first part `#Shutdown daemons' mean? Why the second is not enough?

I am asking since I think there is  a bug somewhere. In my home computer I use ADSL daemon started in background to automatically connect to internet when I turn on the computer. If the connection fails when I turn off the system tries anyway to stop it.
On the other hand, using my laptop if I connect manually (still using /etc/rc.d/adsl) it won't disconnect on shutdown...

Thanks!

Offline

#2 2007-08-14 14:39:25

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: /etc/rc.shutdown daemon question

The first part means "shut down all the daemons that are listed in DAEMONS in rc.conf".

The second part means "shut down any daemons that have a PID file".

It sounds like neither the ADSL daemon nor its initscript creates a PID file.

Offline

#3 2007-08-14 14:48:07

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: /etc/rc.shutdown daemon question

ataraxia wrote:

The first part means "shut down all the daemons that are listed in DAEMONS in rc.conf".

More specifically, shut them down in the reverse order they were started.

Offline

#4 2007-08-14 15:11:56

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: /etc/rc.shutdown daemon question

So it is normal it tries to shutdown daemons that failed to start?

Offline

#5 2007-08-14 15:25:23

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: /etc/rc.shutdown daemon question

I guess so - I don't have an Arch box handy right now, so I can't verify 100%, but I think you're right.  In general, though, the files in /etc/rc.d should guard against stopping a non-running service

Offline

#6 2007-08-14 15:32:15

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: /etc/rc.shutdown daemon question

What about changing it to something like:

if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
    # Shutdown daemons
    let i=${#DAEMONS[@]}
    while [[ i -ge 0 ]]; do
        if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 \
         && -a /var/run/${DAEMONS[$i]#@} ]]; then
            /etc/rc.d/${DAEMONS[$i]#@} stop
        fi
        let i=i-1
    done
 [...]
fi

So it would stop only working services...
Yet this does not explain why when I connect manually with my laptop it does not disconnect automatically when I turn off or reboot...

Offline

Board footer

Powered by FluxBB