summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-04-24 23:25:10 +0200
committerSebastien Luttringer <seblu@seblu.net>2011-04-24 23:25:10 +0200
commit69b4aac9d13d3c4a6c4604cfb763033aa0dab3d6 (patch)
tree02989ad6e4a3d1cb5e37186a84e62525eb521e05
parentcd0ec05a9682ccaaf8d288ab4685edf1c311ec8f (diff)
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>
-rwxr-xr-xrc8
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