[arch-projects] [INITSCRIPTS][PATCH] rc cleaning run rc.d scripts
rc helper now call rc.d scripts in root directory with a clean environment. Chosen vars came from init man page. It allows to launch scripts from the command line, as if they had been launched by init Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- rc | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/rc b/rc index 1e64119..9889d1e 100755 --- a/rc +++ b/rc @@ -43,8 +43,14 @@ case $1 in *) action=$1 shift + # set same environment variables as init + runlevel=$(/sbin/runlevel) + ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'" + ENV+=" PREVLEVEL='${runlevel:0:1}'" + ENV+=" RUNLEVEL='${runlevel:2:1}'" + ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" for i; do - [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" (( ret += $? )) done esac -- Sebastien "Seblu" Luttringer
On Mon, Apr 25, 2011 at 12:03 AM, Sebastien Luttringer <seblu@seblu.net> wrote:
diff --git a/rc b/rc index 1e64119..9889d1e 100755 --- a/rc +++ b/rc @@ -43,8 +43,14 @@ case $1 in *) action=$1 shift + # set same environment variables as init + runlevel=$(/sbin/runlevel) + ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'"
I believe we already overwrite PATH in rc.sysinit, so I guess the two should match? -t
On Tue, Apr 26, 2011 at 12:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Mon, Apr 25, 2011 at 12:03 AM, Sebastien Luttringer <seblu@seblu.net> wrote:
diff --git a/rc b/rc index 1e64119..9889d1e 100755 --- a/rc +++ b/rc @@ -43,8 +43,14 @@ case $1 in *) action=$1 shift + # set same environment variables as init + runlevel=$(/sbin/runlevel) + ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'"
I believe we already overwrite PATH in rc.sysinit, so I guess the two should match?
daemons are executed in rc.multi, not rc.sysinit. PATH setted by init is not modified in this one. Cheers, -- Sébastien Luttringer www.seblu.net
On Tue, Apr 26, 2011 at 8:06 AM, Seblu <seblu@seblu.net> wrote:
On Tue, Apr 26, 2011 at 12:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Mon, Apr 25, 2011 at 12:03 AM, Sebastien Luttringer <seblu@seblu.net> wrote:
diff --git a/rc b/rc index 1e64119..9889d1e 100755 --- a/rc +++ b/rc @@ -43,8 +43,14 @@ case $1 in *) action=$1 shift + # set same environment variables as init + runlevel=$(/sbin/runlevel) + ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'"
I believe we already overwrite PATH in rc.sysinit, so I guess the two should match?
daemons are executed in rc.multi, not rc.sysinit. PATH setted by init is not modified in this one.
Ah, of course, you are right. I'll pull this one. -t
participants (3)
-
Sebastien Luttringer
-
Seblu
-
Tom Gundersen