[arch-projects] [INITSCRIPTS][PATCH] rc cleaning run rc.d scripts
Sebastien Luttringer
seblu at seblu.net
Sun Apr 24 18:03:15 EDT 2011
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 at 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
More information about the arch-projects
mailing list