4 _root="$(dirname "${0}")/.."; . "${_root}/lib/sh/env.sh"
12 log "Usage: $(basename "${0}") <command> [rcscript]"
14 log "<command> can be one of:"
15 log " list - List all available rcscripts"
16 log " status - Show status for all rcscripts"
20 log " on - List all currently running scripts"
23 log " off - List all currently stopped scripts"
25 log "You can also send a command to any rcscript with the following form:"
26 log " $(basename "${0}") <command> [rcscript]"
28 log "For example, the following is equivalent to running '/etc/rc.d/ppp stop':"
29 log " $(basename "${0}") stop ppp"
34 # List all available rc scripts
36 ls -1 /etc/rc.d/* "${local_startup}"/* | egrep -v '/(DAEMON|FILESYSTEMS|LOGIN|NETWORKING|SERVERS)$' | sort
39 # Get the status of one script
42 [ -x "${file}" ] && "${file}" status > /dev/null 2>&1
45 # Get the status of all scripts
51 list) rc_list | sed -e 's/^.*\///'; return ;;
52 started|running|on) want="1" ;;
53 stopped|off) want="0" ;;
58 rc_list | while read file
60 name="$(basename "${file}")"
61 if rc_status "${file}"
63 [ ! "${want}" -o "${want}" = "1" ] && log "${a_green}running${a_normal}: ${name}"
65 [ ! "${want}" -o "${want}" = "0" ] && log "${a_red}stopped${a_normal}: ${name}"
70 # Perform an action on the script
74 rc_list | grep "/${2}$" | while read rcd; do "${rcd}" "${1}"; done
78 1) rc_statii "${1}" ;;
79 2) rc_action "${1}" "${2}" ;;