Magellan Linux

Contents of /trunk/magellan-initscripts/etc/rc.d/init.d/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 782 - (show annotations) (download)
Mon Dec 22 22:08:32 2008 UTC (15 years, 4 months ago) by niro
File size: 4944 byte(s)
-moved udev functions to an extra initscript

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

Properties

Name Value
svn:executable *