Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 782 - (hide annotations) (download)
Mon Dec 22 22:08:32 2008 UTC (15 years, 4 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 4944 byte(s)
-moved udev functions to an extra initscript

1 niro 2 #!/bin/bash
2 niro 782 # $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 niro 2
4 niro 781 source /etc/conf.d/rc
5     source ${rc_functions}
6 niro 2
7 niro 782 # load udev helper functions
8     source ${rc_base}/init.d/udev
9    
10 niro 50 # get mage version
11     MAGEVER="$(< /etc/mageversion)"
12 niro 2
13 niro 150 # source kernel config if exists
14 niro 2 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
15    
16     trap "" INT QUIT TSTP
17    
18     [ "$1" != "" ] && runlevel=$1
19    
20 niro 150 if [[ $runlevel = sysinit ]]
21 niro 2 then
22     echo
23     echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
24 niro 643 echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net"
25 niro 2 echo
26    
27 niro 150 # mount proc filesystem, needed for bootsplash;
28     # no use of '/etc/rc.d/init.d/mountproc' anymore
29 niro 2 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 niro 150 # set default verbose level for kernel messages
37 niro 2 [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
38     echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
39    
40 niro 692 # mount sys file system before udev
41     if [ -d /sys ]
42 niro 2 then
43 niro 692 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 niro 2 fi
51    
52    
53 niro 692 #### load udev ####
54 niro 782 start_udev
55 niro 692 ## end udev ##
56 niro 318
57 niro 2
58     ## load devpts ##
59     # devfs/udev with 2.6 has no ptys, so devpts is also needed
60 niro 692 # check if we really have devpts support
61     if kernel_supports_fs devpts
62 niro 2 then
63 niro 692 # /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 niro 2 then
69 niro 692 mkdir -p /dev/pts &> /dev/null || \
70     echo "Could not create /dev/pts !"
71     fi
72 niro 71
73 niro 692 # 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 niro 2 fi
80 niro 692 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 niro 2 fi
91 niro 692 ## end devpts ##
92 niro 2
93 niro 692
94 niro 515 ## 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 niro 692 ## end usbfs ##
102 niro 515
103 niro 692 ## services state dir ##
104 niro 2 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 niro 150 # load bootsplash
109 niro 2 splash "rc_init" "${runlevel}"
110     fi
111    
112    
113 niro 150 if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
114 niro 2 then
115 niro 150 # load bootsplash
116 niro 2 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 niro 150 if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
122     [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
123 niro 2 then
124     echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
125 niro 150 ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
126 niro 694 mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
127 niro 2 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 niro 150
139 niro 2 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 *