/[baselayout]/trunk/sbin/rc-update
Gentoo

Contents of /trunk/sbin/rc-update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 161 - (show annotations) (download)
Fri Apr 5 23:18:27 2002 UTC (11 years, 2 months ago) by azarah
File size: 2332 byte(s)
move to /sbin

1 #!/bin/bash
2 # Copyright 1999-2002 Gentoo Technologies, Inc.
3 # Distributed under the terms of the GNU General Public License, v2 or later
4 # $Header$
5
6 source /sbin/functions.sh
7 if [ `id -u` -ne 0 ]
8 then
9 eerror "${0}: must be root."
10 exit 1
11 fi
12
13 usage() {
14 cat << FOO
15 usage: rc-update add script runlevel2 [runlevel2...]
16 rc-update del script [runlevel1...]
17
18 note:
19 After rc-update executes, the script dependency cache is automatically
20 updated.
21
22 examples:
23 rc-update add net.eth0 default
24 Adds the net.eth0 script (in /etc/init.d) to the "default" runlevel.
25
26 rc-update del sysklogd
27 Deletes the sysklogd script from all runlevels. The original script
28 is not deleted, just any symlinks to the script in /etc/runlevels/*.
29
30 rc-update del net.eth2 default wumpus
31 Delete the net.eth2 script from the default and wumpus runlevels.
32 All other runlevels are unaffected. Again, the net.eth2 script
33 residing in /etc/init.d is not deleted, just any symlinks in
34 /etc/runlevels/default and /etc/runlevels wumpus.
35
36 FOO
37 exit 1
38 }
39
40 if [ $# -lt 1 ]
41 then
42 usage
43 fi
44 if [ "$1" = "add" ]
45 then
46 if [ $# -lt 3 ]
47 then
48 eerror "${0}: at least two arguments expected after \"add\"."
49 exit 1
50 fi
51 shift
52 myscript=$1
53 if [ ! -e /etc/init.d/${myscript} ]
54 then
55 eerror "${0}: /etc/init.d/${myscript} not found; aborting."
56 exit 1
57 fi
58 shift
59 for x in $*
60 do
61 if [ ! -e /etc/runlevels/${x} ]
62 then
63 ewarn "runlevel ${x} not found; skipping"
64 continue
65 fi
66 if [ -L /etc/runlevels/${x}/${myscript} ]
67 then
68 ewarn "${myscript} already installed in runlevel ${x}; skipping"
69 continue
70 fi
71 ln -sf /etc/init.d/${myscript} /etc/runlevels/${x}/${myscript}
72 ebegin "${myscript} added to runlevel ${x}"
73 done
74 elif [ "$1" = "del" ]
75 then
76 if [ $# -lt 2 ]
77 then
78 eerror "${0}: at least one argument expected after \"del\"."
79 exit 1
80 fi
81 shift
82 myscript=$1
83 shift
84 if [ $# -eq 0 ]
85 then
86 mylevels="`( cd /etc/runlevels; ls )`"
87 else
88 mylevels="$*"
89 fi
90 for x in $mylevels
91 do
92 if [ -L /etc/runlevels/${x}/${myscript} ]
93 then
94 rm /etc/runlevels/${x}/${myscript}
95 ebegin "${myscript} removed from runlevel ${x}"
96 else
97 ewarn "${myscript} not found in runlevel ${x}; skipping"
98 fi
99 done
100 else
101 usage
102 exit 1
103 fi
104 /sbin/depscan.sh
105 einfo "rc-update complete."

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20