-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenrunlevel.in
More file actions
127 lines (110 loc) · 2.3 KB
/
genrunlevel.in
File metadata and controls
127 lines (110 loc) · 2.3 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Search for libgenrunlevel
#
LIB="@LIB_INSTALL_DIR@/libgenrunlevel"
if [ ! -e "${LIB}" ]; then
echo "ERROR: ${LIB} not found!"
exit 1
fi
. "${LIB}" # load libgenrunlevel
#
# Show the help
#
show_help() {
cat >&2 << EOF
USAGE:
${0} [options] [--all | runlevel1 runlevel2 ... runlevelN]
${0} --migrate
${0} --help
options:
--overwrite Overwrite files if they exist.
--path PATH Sets the search path for executables.
--destdir PATH Destination path prefix (default: /).
--confdir PATH Configuration directory (default: /etc/initng).
EOF
}
migrate=
[ ${#} -eq 0 ] && set -e -- --help
while [ ${#} -gt 0 ]; do
case "${1}" in
--all)
all=1
;;
--overwrite)
overwrite=1
;;
--dist)
shift
dist=${1}
;;
--path)
shift
search_path=${1}
;;
--destdir)
shift
DESTDIR=${1}
;;
--confdir)
shift
CONFDIR=${1}
;;
--help)
show_help
exit 0
;;
--migrate)
migrate=1
;;
--)
shift
break
;;
*)
break
;;
esac
shift
done
[ "${CONFDIR}" ] || CONFDIR="${DESTDIR}/etc/initng"
if [ -n "${migrate}" ]; then
RUNLEVELDIR="${CONFDIR}/runlevel"
[ -d "${RUNLEVELDIR}" ] ||
install -d -m 755 -o root -g root "${RUNLEVELDIR}"
[ -f "${RUNLEVELDIR}/system.virtual" ] && CONFDIR="${RUNLEVELDIR}"
for RUNLEVEL_FILE in "${CONFDIR}"/*.runlevel "${CONFDIR}"/*.virtual; do
mv "${RUNLEVEL_FILE}" "${RUNLEVEL_FILE}~"
while read SERVICE; do
if [ ! -f "${CONFDIR}/${SERVICE}.virtual" -a \
! -f "${CONFDIR}/${SERVICE}.runlevel" -a \
! -f "${CONFDIR}/${SERVICE}" -a ]; then
NSERVICE="$(find "${CONFDIR}" -name \
$(basename "${SERVICE}") |
sed -r "s:^${CONFDIR}/(.*)\.i\$:\1:; s:\s::g")"
if [ -n "${NSERVICE}" ]; then
SERVICE="${NSERVICE}"
else
SERVICE="#${SERVICE} (not found)"
fi
fi
echo "${SERVICE}"
done < "${RUNLEVEL_FILE}~" > "${RUNLEVEL_FILE}"
done
exit 0
fi
[ "${search_path}" ] || search_path=$(echo $(
for dir in $()/bin /sbin /usr/bin /usr/sbin /usr/kde/\*/bin \
/usr/kde/\*/sbin /opt/bin /opt/sbin /opt/\*/bin \
/opt/\*/sbin /usr/local/sbin /usr/local/bin
do [ "$(echo ${dir})" ] && echo ${dir}
done | grep -v '*')
)
[ "${all}" ] && set -- $(get_runlevels)
for l; do
create_list "${l}"
done
for rl in ${runlevels}; do
write_runlevel "${rl}" > "${CONFDIR}/${rl}"
done
echo "Done generating files."