Debian Codegraph @

tests/probes/runlevel/runlevel_helper.sh

raw symbols SCIP
1 if [ -x "`which chkconfig`" ] ; then
2 HAVE_CHKCONFIG=y
3 else
4 HAVE_CHKCONFIG=n
5 fi
6
7 # Gets the chkconfig list with chkconfig direclty if HAVE_CHKCONFIG
8 # Otherwise produces the same information in another way
9 get_services_list() {
10 if [ "$HAVE_CHKCONFIG" = "y" ] ; then
11 chkconfig --list | awk '{print $1}' | sort | uniq
12 else
13 ls /etc/init.d/ | egrep -v "(README|PRESERVE)" | xargs
14 fi
15 }
16
17 # Gets the chkconfig level with chkconfig direclty if HAVE_CHKCONFIG
18 # Otherwise produces the same information in another way
19 get_service_runlevels() {
20
21 local SRV=$1
22
23 if [ "$HAVE_CHKCONFIG" = "y" ] ; then
24 chkconfig $SRV --list | awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8}'
25 else
26 for RC in 0 1 2 3 4 5 6; do
27 RCDIR=/etc/rc$RC.d
28 if [ -d $RCDIR ]; then
29 if [ -f $RCDIR/S[0-9][0-9]$SRV ] ; then
30 STATE="on"
31 else
32 STATE="off"
33 fi
34 echo "$RC:$STATE"
35 fi
36 done
37 fi
38 }
39
40 # Gets a list of services matching the given state at the given runlevel
41 get_services_matching() {
42 local RUNLEVEL=$1
43 local STATE=$2
44 for S in `get_services_list`; do
45 if get_service_runlevels $S | grep $RUNLEVEL:$STATE >/dev/null; then
46 echo $S
47 fi
48 done
49 }