summaryrefslogtreecommitdiff
path: root/rc.d
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-05-18 11:16:19 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-05-18 11:16:19 -0300
commit84a17ca62a9bcfcfaef320c38bb45add1f673afd (patch)
tree9e7789b4c6fd7536b5b00ba7b64d7dc4db0ed878 /rc.d
parent0363775a534e231ae1b906079ddf980a08a8de67 (diff)
parentc6b3853de29e5bb42adda4a2f62a08d87ea15740 (diff)
Merge branch 'master' of https://projects.archlinux.org/git/initscripts into parabola2011.05.2parabola
Diffstat (limited to 'rc.d')
-rwxr-xr-xrc.d61
1 files changed, 61 insertions, 0 deletions
diff --git a/rc.d b/rc.d
new file mode 100755
index 0000000..02c2b6c
--- /dev/null
+++ b/rc.d
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+usage() {
+ local name=${0##*/}
+ cat >&2 << EOF
+usage: $name action daemon ...
+
+e.g: $name list
+ $name help
+ $name 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_CLEAR}$d\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: