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

Contents of /trunk/sbin/rc-update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 247 - (hide annotations) (download)
Sun Oct 13 19:20:23 2002 UTC (11 years, 9 months ago) by azarah
File size: 2535 byte(s)
misc form updates

1 drobbins 32 #!/bin/bash
2 azarah 85 # Copyright 1999-2002 Gentoo Technologies, Inc.
3     # Distributed under the terms of the GNU General Public License, v2 or later
4     # $Header$
5    
6 azarah 161 source /sbin/functions.sh
7 drobbins 32 if [ `id -u` -ne 0 ]
8     then
9 azarah 247 eerror "$0: must be root."
10 drobbins 32 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 azarah 247 eerror "$0: /etc/init.d/${myscript} not found; aborting."
56 drobbins 32 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 azarah 243 if [ ! -x /etc/init.d/${myscript} ]
72     then
73     ewarn "${myscript} not executable; skipping"
74     continue
75 azarah 244 fi
76     ln -sf /etc/init.d/${myscript} /etc/runlevels/${x}/${myscript}
77 azarah 245 if [ "$?" -ne 0 ]
78     then
79 azarah 247 eerror "$0: failed to add $1 to ${x}."
80 azarah 245 exit 1
81     fi
82 drobbins 32 ebegin "${myscript} added to runlevel ${x}"
83     done
84     elif [ "$1" = "del" ]
85     then
86     if [ $# -lt 2 ]
87     then
88 azarah 247 eerror "$0: at least one argument expected after \"del\"."
89 drobbins 32 exit 1
90     fi
91     shift
92     myscript=$1
93     shift
94     if [ $# -eq 0 ]
95     then
96     mylevels="`( cd /etc/runlevels; ls )`"
97     else
98     mylevels="$*"
99     fi
100 azarah 242 for x in ${mylevels}
101 drobbins 32 do
102     if [ -L /etc/runlevels/${x}/${myscript} ]
103     then
104     rm /etc/runlevels/${x}/${myscript}
105     ebegin "${myscript} removed from runlevel ${x}"
106     else
107     ewarn "${myscript} not found in runlevel ${x}; skipping"
108     fi
109     done
110     else
111     usage
112     exit 1
113     fi
114 azarah 161 /sbin/depscan.sh
115 drobbins 32 einfo "rc-update complete."
116 azarah 245
117 azarah 247
118     # vim:ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20