Hi,
On Wed, Jun 24, 2009 at 17:50, Alan McKinnon<[email protected]> wrote:
> On Wednesday 24 June 2009 03:28:55 Mike Mazur wrote:
>> Still one issue remains -- why are my RC states not automatically
>> switched between default and battery even though my acpid setup is
>> right and works (according to the log messages)?
>
> The simplest answer (usually the right one) is that you are probably grepping
> for the wrong string. These things are subject to change and there's no easy
> way for you to find out when it happens.
You mean grepping for the wrong string in syslog? I don't think that's
an issue, since pmg_switch_runlevel.sh is being called (as can be seen
by the log messages).
I looked inside /sbin/rc and discovered that control flow ends up at
the elsif statement on line 607. This is because $RUNLEVEL is "S" and
$argv1 is "battery". The relevant code is:
elif [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} != "single" ]]
then
level=$(awk -v level="${argv1}" '
$2 == level {
split($0, fields, ":")
print fields[2]
exit
}' /etc/inittab 2>/dev/null)
[[ -z ${level} ]] && level=3
/sbin/telinit "${level}"
exit 0
fi
AFAICT, this code looks for the desired runlevel in /etc/inittab and
if that runlevel is there, we change to runlevel 3 (aka default). The
battery runlevel does not exist in /etc/inittab (and I'm pretty sure
it never did before), so the runlevel is never changed to battery.
What is interesting, though, is if I run `/sbin/rc battery` manually
from the command line, there are no problems and I find myself in the
battery runlevel. So I guess something has changed in /sbin/rc which
causes it to function differently when called from a script.
Does anyone know what's the proper way of calling /sbin/rc from a
script? Perhaps there are some parameters I should pass it to get the
runlevels to switch? I'm running sys-apps/baselayout-1.12.11.1 and it
doesn't seem to have a man page.
Thanks,
Mike