From 2800e50847f3217b60eb07138c7f6fda05467616 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 2 Apr 2011 12:39:05 +0200 Subject: Add an rc helper This is allow a quick calling to /etc/rc.d scripts by calling a shell command. By example, starting sshd and gpm can be done by typing: rc start sshd gpm rc can also list available scripts and show which is started/stopped in DAEMONS [tomegun: fixed detection of autostart of background services] Signed-off-by: Sebastien Luttringer Signed-off-by: Tom Gundersen --- rc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 rc (limited to 'rc') diff --git a/rc b/rc new file mode 100755 index 0000000..4bb9730 --- /dev/null +++ b/rc @@ -0,0 +1,51 @@ +#!/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 +} + +(( $# < 1 )) && usage && exit 1 + +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 + for i; do + [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + done +esac + +true + +# vim: set ts=2 sw=2 noet: -- cgit v1.2.3