aboutsummaryrefslogtreecommitdiff
path: root/rc.d
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-05-05 01:17:24 +0200
committerTom Gundersen <teg@jklm.no>2011-05-11 01:51:33 +0200
commit2acd4aaf8b84316e30b63ba1f785e2e15ddee4a3 (patch)
tree6b1625642d42b974bb7ac101f2be491a2960a47e /rc.d
parent8ffdc007c28346ba0a733dbcdba62f91d23ce353 (diff)
downloadinitscripts-2acd4aaf8b84316e30b63ba1f785e2e15ddee4a3.tar.xz
Rename rc into rc.d2011.05.1
To avoid conflict with plan9 rc shell we need to rename our rc. Original name come from debian invoke-rc.d, shortened into rc. Signed-off-by: Sebastien Luttringer <seblu@seblu.net> Signed-off-by: Tom Gundersen <teg@jklm.no>
Diffstat (limited to 'rc.d')
-rwxr-xr-xrc.d60
1 files changed, 60 insertions, 0 deletions
diff --git a/rc.d b/rc.d
new file mode 100755
index 0000000..743d86b
--- /dev/null
+++ b/rc.d
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+usage() {
+ cat >&2 << EOF
+usage: rc action daemon ...
+
+e.g: rc list
+ rc help
+ rc start sshd gpm
+EOF
+ exit 1
+}
+
+(( $# < 1 )) && usage
+
+declare -i ret=0
+case $1 in
+ help)
+ usage
+ ;;
+ list)
+ cd /etc/rc.d/
+ for d in *; do
+ have_daemon "$d" || continue
+ # print running / stopped satus
+ if ! ck_daemon "$d"; then
+ printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]"
+ else
+ printf "${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]"
+ fi
+ # print auto / manual status
+ if ! ck_autostart "$d"; then
+ printf "${C_OTHER}[${C_DONE}AUTO${C_OTHER}]"
+ else
+ printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]"
+ fi
+ printf " ${C_MAIN}$d${C_CLEAR}\n"
+ done
+ ;;
+ *)
+ 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" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action"
+ (( ret += !! $? )) # clamp exit value to 0/1
+ done
+esac
+
+exit $ret
+
+# vim: set ts=2 sw=2 noet: