Lines 1-7
Link Here
|
1 |
#!/bin/bash |
1 |
#!/bin/bash |
2 |
# Copyright 1999-2004 Gentoo Technologies, Inc. |
2 |
# Copyright 1999-2003 Gentoo Technologies, Inc. |
3 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# $Header: /home/cvsroot/gentoo-src/rc-scripts/sbin/rc-update,v 1.17 2004/04/21 17:09:18 vapier Exp $ |
4 |
# $Header: /home/cvsroot/gentoo-src/rc-scripts/sbin/rc-update,v 1.16 2003/08/04 21:39:17 azarah Exp $ |
5 |
|
5 |
|
6 |
source /sbin/functions.sh |
6 |
source /sbin/functions.sh |
7 |
if [ "${EUID}" -ne 0 ] |
7 |
if [ "${EUID}" -ne 0 ] |
Lines 12-22
Link Here
|
12 |
|
12 |
|
13 |
usage() { |
13 |
usage() { |
14 |
cat << FOO |
14 |
cat << FOO |
15 |
usage: rc-update -a|add script runlevel2 [runlevel2...] |
15 |
usage: rc-update -a|add script runlevel1 [runlevel2...] |
16 |
rc-update -d|del script [runlevel1...] |
16 |
rc-update -d|del script [runlevel1...] |
17 |
rc-update -s|show [runlevel1...] |
17 |
rc-update -s|show [runlevel1...] |
|
|
18 |
rc-update -c|current [runlevel] |
18 |
|
19 |
|
19 |
note: After rc-update executes, the script dependency cache is automatically |
20 |
note: |
|
|
21 |
After rc-update executes, the script dependency cache is automatically |
20 |
updated. |
22 |
updated. |
21 |
|
23 |
|
22 |
examples: |
24 |
examples: |
Lines 36-41
Link Here
|
36 |
rc-update show |
38 |
rc-update show |
37 |
Show all the available scripts and list at which runlevels they |
39 |
Show all the available scripts and list at which runlevels they |
38 |
will execute. |
40 |
will execute. |
|
|
41 |
|
42 |
rc-update current default |
43 |
Synchornize current running services with the "default" runlevel, |
44 |
creating "default" if it doesn't exist. |
45 |
use without any argument to sync to current runlevel. |
46 |
|
39 |
FOO |
47 |
FOO |
40 |
exit 1 |
48 |
exit 1 |
41 |
} |
49 |
} |
Lines 157-162
Link Here
|
157 |
done |
165 |
done |
158 |
} |
166 |
} |
159 |
|
167 |
|
|
|
168 |
current() { |
169 |
|
170 |
local x= |
171 |
local mylevel= |
172 |
|
173 |
shift |
174 |
if [ $# -eq 0 ] |
175 |
then |
176 |
mylevel=$(cat /var/lib/init.d/softlevel) |
177 |
ewarn "Using current runlevel: ${mylevel}" |
178 |
echo |
179 |
else |
180 |
mylevel=$1 |
181 |
fi |
182 |
|
183 |
if [ ! -e "/etc/runlevels/${mylevel}" ] |
184 |
then |
185 |
einfo Creating runlevel ${mylevel} |
186 |
echo |
187 |
mkdir "/etc/runlevels/${mylevel}" |
188 |
fi |
189 |
|
190 |
# Scan current started services and add them to current runlevel |
191 |
|
192 |
for x in $( cd /var/lib/init.d/started/ ; ls ) |
193 |
do |
194 |
if [ ! -L "/etc/runlevels/${mylevel}/${x}" ] |
195 |
then |
196 |
add shift ${x} ${mylevel} |
197 |
fi |
198 |
done |
199 |
|
200 |
# Scan current runlevel for non-running services, and remove them |
201 |
|
202 |
for x in $( cd /etc/runlevels/${mylevel} ; ls ) |
203 |
do |
204 |
if [ ! -L "/var/lib/init.d/started/${x}" ] |
205 |
then |
206 |
del shift ${x} ${mylevel} |
207 |
fi |
208 |
done |
209 |
|
210 |
} |
211 |
|
160 |
if [ $# -lt 1 ] |
212 |
if [ $# -lt 1 ] |
161 |
then |
213 |
then |
162 |
usage |
214 |
usage |
Lines 175-180
Link Here
|
175 |
show|-s) |
227 |
show|-s) |
176 |
show "$@" |
228 |
show "$@" |
177 |
;; |
229 |
;; |
|
|
230 |
current|-c) |
231 |
current "$@" |
232 |
;; |
178 |
*) |
233 |
*) |
179 |
usage |
234 |
usage |
180 |
exit 1 |
235 |
exit 1 |