/[baselayout]/trunk/bin/rc-status
Gentoo

Diff of /trunk/bin/rc-status

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 512 Revision 513
13# service's status is (running, stopped, etc.) # 13# service's status is (running, stopped, etc.) #
14# # 14# #
15# -a can be used to display all runlevels # 15# -a can be used to display all runlevels #
16# -d can be used to display service dependancies # 16# -d can be used to display service dependancies #
17# -u will display all unassigned services # 17# -u will display all unassigned services #
18# -s will display all services #
18# -h will display help # 19# -h will display help #
19# <runlevel> is used to choose the run level for which information is # 20# <runlevel> is used to choose the run level for which information is #
20# displayed # 21# displayed #
21# # 22# #
22# By default, rc-status only displays information about the current # 23# By default, rc-status only displays information about the current #
49 ;; 50 ;;
50 --list|-l) 51 --list|-l)
51 ls -1 ${runleveldir} 52 ls -1 ${runleveldir}
52 exit 0 53 exit 0
53 ;; 54 ;;
55 --servicelist|-s)
56 ALL=true
57 SERVICELIST=true
58 ;;
54 --help|-h|-*) 59 --help|-h|-*)
55 echo "USAGE: $0 [--all | --list | --unused | <runlevel>]" 60 echo "USAGE: $0 [--all | --list | --unused | --servicelist | <runlevel>]"
56 echo " --all -a Show services at all run levels" 61 echo " --all -a Show services at all run levels"
57 echo " --list -l Show list of run levels" 62 echo " --list -l Show list of run levels"
58 echo " --unused -u Show services not assigned to any run level" 63 echo " --unused -u Show services not assigned to any run level"
64 echo " --servicelist -s Show service list"
59 echo " <runlevel> Show services assigned to <runlevel>" 65 echo " <runlevel> Show services assigned to <runlevel>"
60 echo "If no arguments are supplied, shows services for current run level." 66 echo "If no arguments are supplied, shows services for current run level."
61 exit 0 67 exit 0
62 ;; 68 ;;
63 *) 69 *)
64 runlevel=$1 70 runlevel=$1
128 echo 0 134 echo 0
129 return 0 135 return 0
130} 136}
131if [ -n "${ALL}" ] ; then 137if [ -n "${ALL}" ] ; then
132 unassigned= 138 unassigned=
139 allservices=
133 for service in `ls -1 /etc/init.d | grep -v '\.sh$'` ; do 140 for service in `ls -1 /etc/init.d | grep -v '\.sh$'` ; do
134 if [ $(in_list "${runlevels[*]}" "${service}") -eq 0 ] ; then 141 if [ $(in_list "${runlevels[*]}" "${service}") -eq 0 ] ; then
135 unassigned="${unassigned} ${service}" 142 unassigned="${unassigned} ${service}"
136 fi 143 fi
144 allservices="${allservices} ${service}"
137 done 145 done
138 runlevelidxs="${runlevelidxs} UNASSIGNED" 146 runlevelidxs="${runlevelidxs} UNASSIGNED"
139 runlevels[${arridx}]="${unassigned}" 147 runlevels[${arridx}]="${unassigned}"
148 runlevels[${arridx}+1]="${allservices}"
140fi 149fi
141 150
142################################################################################ 151################################################################################
143# Now collect information about the status of the various services; whether # 152# Now collect information about the status of the various services; whether #
144# they're started, broken, or failed. Put all of this into arrays. # 153# they're started, broken, or failed. Put all of this into arrays. #
160} 169}
161 170
162# if --all wasnt specified, dont print everything 171# if --all wasnt specified, dont print everything
163[ -z "${ALL}" ] && runlevelidxs="${runlevel}" 172[ -z "${ALL}" ] && runlevelidxs="${runlevel}"
164if [ -z "${UNUSED}" ] ; then 173if [ -z "${UNUSED}" ] ; then
174 if [ -z "${SERVICELIST}" ] ; then
165 arridx=0 175 arridx=0
176 else
177 runlevelidxs="all"
178 let "arridx += 1"
179 fi
166else 180else
167 runlevelidxs="unused" 181 runlevelidxs="unused"
168fi 182fi
169 183
170for level in ${runlevelidxs} ; do 184for level in ${runlevelidxs} ; do

Legend:
Removed from v.512  
changed lines
  Added in v.513

  ViewVC Help
Powered by ViewVC 1.1.20