-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallservice
executable file
·84 lines (77 loc) · 1.04 KB
/
allservice
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
prefix="/usr/local"
cd /root
service_enabled_filtered()
{
service -e |
while read rc
do
if test -f "${prefix}/etc/allservice.txt"
then
if grep -q -x "${rc}" "${prefix}/etc/allservice.txt"
then
continue
fi
fi
if test "${filter}" != ""
then
case "${rc}" in
${filter})
;;
*)
continue
;;
esac
fi
echo "${rc}"
done
}
generate_allservice() {
if test ! -f "${prefix}/etc/allservice.txt"
then
touch "${prefix}/etc/allservice.txt"
fi
service -e |
while read rc
do
if test ! -e "${rc}"
then
continue
fi
usage=`"${rc}" 2>&1`
case "${usage}" in
*status*)
continue
;;
esac
if grep -q -x "${rc}" "${prefix}/etc/allservice.txt"
then
continue
fi
echo "${rc}" >> "${prefix}/etc/allservice.txt"
echo "ignored: ${rc}"
done
}
filter=""
case "${1}" in
local)
shift
filter="${prefix}/etc/*"
;;
gen)
generate_allservice
exit 0
;;
esac
if test $# -lt 1
then
service_enabled_filtered
exit 0
fi
service_enabled_filtered |
while read rc
do
${rc} "${@}"
done
exit 0
# eof