Magellan Linux

Annotation of /trunk/initscripts/sysvinit/rc/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1832 - (hide annotations) (download)
Tue Jun 26 16:42:54 2012 UTC (11 years, 10 months ago) by niro
File size: 5232 byte(s)
-fixed spelling
1 niro 2 #!/bin/bash
2 niro 935 # $Id$
3 niro 2
4 niro 781 source /etc/conf.d/rc
5     source ${rc_functions}
6 niro 2
7 niro 50 # get mage version
8 niro 1774 if [[ -f /etc/os-release ]]
9     then
10     MAGEVER="$(read_os_release version_id)"
11     elif [ -f /etc/mageversion ]
12     then
13     MAGEVER="$(< /etc/mageversion)"
14     else
15     MAGEVER="unkown"
16     fi
17 niro 2
18 niro 150 # source kernel config if exists
19 niro 2 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
20    
21 niro 1094 # override devicemanager helper functions
22 niro 1095 if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
23 niro 1094 then
24     source ${rc_base}/init.d/udev
25    
26 niro 1105 elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
27 niro 1094 then
28     source ${rc_base}/init.d/mdev
29     fi
30    
31 niro 2 trap "" INT QUIT TSTP
32    
33     [ "$1" != "" ] && runlevel=$1
34    
35 niro 150 if [[ $runlevel = sysinit ]]
36 niro 2 then
37 niro 1248 rc_echo
38     rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
39 niro 1664 rc_echo "Copyright 2001-2012 Niels Rogalla; http://magellan-linux.net"
40 niro 1248 rc_echo
41 niro 2
42 niro 150 # mount proc filesystem, needed for bootsplash;
43     # no use of '/etc/rc.d/init.d/mountproc' anymore
44 niro 2 if [ ! -e /proc/mounts ]
45     then
46 niro 1248 rc_print "Mounting proc file system ..."
47 niro 2 mount -n /proc
48     evaluate_retval
49     fi
50    
51 niro 150 # set default verbose level for kernel messages
52 niro 2 [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
53     echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
54    
55 niro 692 # mount sys file system before udev
56     if [ -d /sys ]
57 niro 2 then
58 niro 1789 if [ ! -e /sys/kernel/notes ]
59     then
60     rc_print "Mounting sysfs file system ..."
61     mount -n -t sysfs sysfs /sys
62     evaluate_retval
63     fi
64 niro 692 else
65 niro 1788 rc_echo -e ${COLRED}"Fatal: mountpoint /sys missing ..."
66 niro 1248 rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
67     rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
68 niro 2 fi
69    
70 niro 1248 # start device management
71 niro 1094 start_devicemanager
72 niro 318
73 niro 2 ## load devpts ##
74     # devfs/udev with 2.6 has no ptys, so devpts is also needed
75 niro 692 # check if we really have devpts support
76     if kernel_supports_fs devpts
77 niro 2 then
78 niro 692 # /dev/pts maybe not exists.
79     # We only create this directory only if devfs was mounted,
80     # or it will fail as / is still mounted readonly
81     # udev has this dir already, only a sanity check for devfs
82     if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
83 niro 2 then
84 niro 692 mkdir -p /dev/pts &> /dev/null || \
85 niro 1248 rc_echo "Could not create /dev/pts !"
86 niro 692 fi
87 niro 71
88 niro 692 # now mount devpts
89     if [ -d /dev/pts ]
90     then
91 niro 1248 rc_print "Mounting devpts at /dev/pts ..."
92 niro 692 mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
93     evaluate_retval
94 niro 2 fi
95 niro 692 else
96     # devpts is not supported, give a warning
97 niro 1248 rc_echo -e ${COLRED}"No devpts filesystem found ..."
98     rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
99     rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
100     rc_echo -e ${COLYELLOW}"or no pty's are available."
101     rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
102     rc_echo
103     rc_echo -e ${COLYELLOW}"Press any key to continue ..."
104 niro 692 read
105 niro 2 fi
106 niro 692 ## end devpts ##
107 niro 2
108 niro 692
109 niro 515 ## load usbfs ##
110     if kernel_supports_fs usbfs
111     then
112 niro 1248 rc_print "Mounting usbfs at /proc/bus/usb ..."
113 niro 515 mount -n -t usbfs usbfs /proc/bus/usb
114     evaluate_retval
115     fi
116 niro 692 ## end usbfs ##
117 niro 515
118 niro 692 ## services state dir ##
119 niro 1248 rc_print "Mounting tmpfs at ${svcdir} ..."
120 niro 2 mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k
121     evaluate_retval
122    
123 niro 150 # load bootsplash
124 niro 2 splash "rc_init" "${runlevel}"
125     fi
126    
127    
128 niro 150 if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
129 niro 2 then
130 niro 150 # load bootsplash
131 niro 2 splash "rc_init" "${runlevel}"
132    
133     # if requested save devices to a device tarball before halt
134     # only for kernels >=2.6 *and* udev
135 niro 1832 # make sure that udev is mounted but *not* devfs --> /dev/.devfsd
136 niro 150 if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
137     [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
138 niro 2 then
139 niro 1248 rc_print "Saving /dev device nodes ..."
140 niro 150 ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
141 niro 694 mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
142 niro 2 evaluate_retval
143     fi
144 niro 974
145 niro 1248 # stop device management
146 niro 1094 stop_devicemanager
147 niro 2 fi
148    
149    
150     if [ "$runlevel" = "" ]
151     then
152 niro 1248 rc_echo "Usage: $0 <runlevel>" >&2
153 niro 2 exit 1
154     fi
155    
156 niro 150
157 niro 2 previous=$PREVLEVEL
158     [ "$previous" = "" ] && previous=N
159    
160     if [ ! -d $rc_base/rc$runlevel.d ]
161     then
162 niro 1248 rc_echo "$rc_base/rc$runlevel.d does not exist"
163 niro 2 exit 1
164     fi
165    
166     if [ "$previous" != "N" ]
167     then
168     for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null)
169     do
170    
171     check_script_status
172    
173     suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
174     prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
175     sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
176    
177     if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
178     then
179     if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
180     then
181     $WARNING
182 niro 1248 rc_echo "$i can't be executed because it was"
183     rc_echo "not started in the previous runlevel ($previous)"
184 niro 2 $NORMAL
185     continue
186     fi
187     fi
188    
189     $i stop
190     error_value=$?
191    
192     if [ "$error_value" != "0" ]
193     then
194     print_error_msg
195     fi
196     done
197     fi
198    
199     for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null)
200     do
201     if [ "$previous" != "N" ]
202     then
203     suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
204     stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
205     prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
206    
207     [ -f $prev_start ] && [ ! -f $stop ] && continue
208     fi
209    
210     check_script_status
211    
212     $i start
213     error_value=$?
214    
215     if [ "$error_value" != "0" ]
216     then
217     print_error_msg
218     fi
219     done

Properties

Name Value
svn:executable *