]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/rc.sysinit
synced with 0.0.5
[projects/rc-scripts.git] / rc.d / rc.sysinit
1 #!/bin/sh
2 #
3 # /etc/rc.d/rc.sysinit - run once at boot time
4 #
5 # Taken in part from Miquel van Smoorenburg's bcheckrc.
6 #
7
8 # Set the path
9 PATH=/bin:/sbin:/usr/bin:/usr/sbin
10 export PATH
11
12 # Read network config data.
13 if [ -f /etc/sysconfig/network ]; then
14     . /etc/sysconfig/network
15 else
16     NETWORKING=no
17     HOSTNAME=localhost
18 fi
19
20 # Read system config data.
21 if [ -f /etc/sysconfig/system ]; then
22     . /etc/sysconfig/system
23 else
24     RUN_SULOGIN_ON_ERR=yes
25 fi
26
27 # Start up swapping.
28 echo "Activating swap partitions"
29 swapon -a
30
31 # Set the hostname.
32 hostname ${HOSTNAME}
33 echo hostname: `hostname`
34
35 # Set the NIS domain name
36 if [ -n "$NISDOMAIN" ]; then
37     domainname $NISDOMAIN
38 else
39     domainname ""
40 fi
41
42 if [ -f /fsckoptions ]; then
43         fsckoptions=`cat /fsckoptions`
44     else
45         fsckoptions=''
46 fi
47
48 if [ ! -f /fastboot ]; then
49         echo "Checking root filesystems."
50         fsck -V -a $fsckoptions /
51
52         rc=$?
53
54         # A return of 2 or higher means there were serious problems.
55         if [ $rc -gt 1 ]; then
56                 echo
57                 echo
58                 echo "*** An error occurred during the file system check."
59                 echo "*** Dropping you to a shell; the system will reboot"
60                 echo "*** when you leave the shell."
61
62                 PS1="(Repair filesystem) \#"; export PS1
63                 if [ "$RUN_SULOGIN_ON_ERR" = "yes"]; then
64                         sulogin
65                 else
66                         /bin/sh
67                 fi
68
69                 echo "Unmounting file systems"
70                 umount -a
71                 mount -n -o remount,ro /
72                 echo "Automatic reboot in progress."
73                 reboot
74         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
75                 echo "Checking root filesystem quotas"
76                 /sbin/quotacheck -v /
77         fi
78 fi
79
80 if [ -x /sbin/quotaon ]; then
81     echo "Turning on user and group quotas for root filesystem"
82     /sbin/quotaon /
83 fi
84
85 # check for arguments 
86
87 mount -t proc /proc /proc
88 if grep -i nopnp /proc/cmdline >/dev/null ; then
89     PNP=
90 else
91     PNP=yes
92 fi
93
94 # set up pnp 
95 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
96     if [ -n "$PNP" ]; then
97         echo "Setting up ISA PNP devices"
98         /sbin/isapnp /etc/isapnp/isapnp.conf
99     else
100         echo "Skipping ISA PNP configuration at users request"
101     fi
102 fi
103
104 # setup media type dependent parameters
105 if [ -f /etc/rc.d/rc.media ]; then
106         . /etc/rc.d/rc.media
107 fi
108
109 # Remount the root filesystem read-write.
110 echo "Remounting root filesystem in read-write mode."
111 mount -n -o remount,rw /
112
113 # Clear mtab
114 >/etc/mtab
115
116 # Enter root and /proc into mtab.
117 mount -f /
118 mount -f /proc
119
120 if [ -f /proc/ksyms ]; then
121     USEMODULES=y
122 else
123     USEMODULES=
124 fi
125
126 # Set up kernel version-dependent symlinks.
127 rm -f /lib/modules/preferred
128 if [ -n "$USEMODULES" ]; then
129     ktag="`cat /proc/version`"
130     mtag=`grep -l "$ktag" /lib/modules/*/.rhkmvtag` 2> /dev/null
131     if [ -n "$mtag" ]; then
132         mver=`echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[       ].*$,,'`
133         ln -sf /lib/modules/$mver /lib/modules/preferred
134         ln -sf /boot/System.map-$mver /boot/System.map
135         ln -sf /boot/module-info-$mver /boot/module-info
136     fi
137 fi
138
139 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
140     # Get ready for kerneld if module support in the kernel
141     echo -n "Finding module dependencies... "
142     if [ -e /lib/modules/preferred ]; then
143         depmod -a preferred
144     else
145         depmod -a
146     fi
147     echo "done"
148 fi
149
150 # load sound modules
151 if ! grep -i nomodules /proc/cmdline >/dev/null ; then
152     if [ -n "$USEMODULES" ]; then
153         if grep -s "alias sound" /etc/conf.modules > /dev/null ; then
154             modprobe sound
155             if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
156                 modprobe midi
157             fi
158         fi
159     fi
160 fi
161
162 if [ -f /proc/sys/kernel/modprobe ]; then
163         # /proc/sys/kernel/modprobe indicates built-in kmod instead
164         echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
165 fi
166
167 # Add raid devices
168 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
169         echo "Starting up RAID devices."
170         raidadd -a
171
172         rc=$?
173
174         if [ $rc = 0 ]; then
175                 raidrun -a
176                 rc=$?
177         fi
178
179         # A non-zero return means there were problems.
180         if [ $rc -gt 0 ]; then
181                 echo
182                 echo
183                 echo "*** An error occurred during the RAID startup"
184                 echo "*** Dropping you to a shell; the system will reboot"
185                 echo "*** when you leave the shell."
186
187                 PS1="(RAID Repair) \#"; export PS1
188                 if [ "$RUN_SULOGIN_ON_ERR" = "yes"]; then
189                         sulogin
190                 else
191                         /bin/sh
192                 fi
193
194                 echo "Unmounting file systems"
195                 umount -a
196                 mount -n -o remount,ro /
197                 echo "Automatic reboot in progress."
198                 reboot
199         fi
200 fi
201
202 # Check filesystems
203 if [ ! -f /fastboot ]; then
204         echo "Checking filesystems."
205         fsck -R -A -V -a $fsckoptions
206
207         rc=$?
208
209         # A return of 2 or higher means there were serious problems.
210         if [ $rc -gt 1 ]; then
211                 echo
212                 echo
213                 echo "*** An error occurred during the file system check."
214                 echo "*** Dropping you to a shell; the system will reboot"
215                 echo "*** when you leave the shell."
216
217                 PS1="(Repair filesystem) \#"; export PS1
218                 if [ "$RUN_SULOGIN_ON_ERR" = "yes"]; then
219                         sulogin
220                 else
221                         /bin/sh
222                 fi
223
224                 echo "Unmounting file systems"
225                 umount -a
226                 mount -n -o remount,ro /
227                 echo "Automatic reboot in progress."
228                 reboot
229         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
230                 echo "Checking filesystem quotas"
231                 /sbin/quotacheck -v -R -a
232         fi
233 fi
234
235 # Mount all other filesystems (except for NFS and /proc, which is already
236 # mounted). Contrary to standard usage,
237 # filesystems are NOT unmounted in single user mode.
238 echo "Mounting local filesystems."
239 mount -a -t nonfs,proc
240
241 # set the console font
242 if [ -x /sbin/setsysfont ]; then
243     /sbin/setsysfont
244 fi
245
246 if [ -x /sbin/quotaon ]; then
247     echo "Turning on user and group quotas for local filesystems"
248     /sbin/quotaon -a
249 fi
250
251 # Clean out /etc.
252 rm -f /etc/mtab~ /fastboot /fsckoptions
253 >/var/run/utmp
254
255 # Delete UUCP lock files.
256 rm -f /var/lock/LCK*
257
258 # Delete stale subsystem files.
259 rm -f /var/lock/subsys/*
260
261 # Delete stale pid files
262 rm -f /var/run/*.pid
263 rm -f /var/spool/postoffice/.pid.*
264
265 # Delete X locks
266 rm -f /tmp/.X*-lock
267
268 # Delete Postgres sockets
269 rm -f /tmp/.s.PGSQL.*
270
271 # Set the system clock.
272 echo -n "Setting clock"
273
274 ARC=0
275 UTC=0
276 if [ -f /etc/sysconfig/clock ]; then
277     . /etc/sysconfig/clock
278
279     # convert old style clock config to new values
280     if [ "${CLOCKMODE}" = "GMT" ]; then
281             UTC=true
282     elif [ "${CLOCKMODE}" = "ARC" ]; then
283             ARC=true
284     fi
285 fi
286
287 if [ -x /sbin/hwclock ]; then
288     CLOCKFLAGS="--hctosys"
289     CLOCK=/sbin/hwclock
290 else
291     CLOCKFLAGS="-a"
292     CLOCK=/sbin/clock
293 fi
294
295 case "$UTC" in
296   yes|true)
297     CLOCKFLAGS="$CLOCKFLAGS -u";
298     echo -n " (utc)"
299   ;;
300 esac
301
302 case "$ARC" in
303   yes|true)
304     CLOCKFLAGS="$CLOCKFLAGS -A";
305     echo -n " (arc)"
306   ;;
307 esac
308
309 echo -n ": "
310 $CLOCK $CLOCKFLAGS
311
312 date
313
314 # Right, now turn on swap in case we swap to files.
315 echo "Enabling swap space."
316 swapon -a 2>&1 | grep -v "busy"
317
318 # Initialize the serial ports.
319 if [ -f /etc/rc.d/rc.serial ]; then
320         . /etc/rc.d/rc.serial
321 fi
322
323 # Load modules (for backward compatibility with VARs)
324 if [ -f /etc/rc.d/rc.modules ]; then
325         /etc/rc.d/rc.modules
326 fi
327
328 # If a SCSI tape has been detected, load the st module unconditionally
329 # since many SCSI tapes don't deal well with st being loaded and unloaded
330 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type:   Sequential-Access' 2>/dev/null ; then
331         if cat /proc/devices | grep -qv ' 9 st' ; then
332                 if [ -n "$USEMODULES" ] ; then
333                         # Try to load the module.  If it fails, ignore it...
334                         modprobe st 2>/dev/null
335                 fi
336         fi
337 fi
338
339 # Now that we have all of our basic modules loaded and the kernel going,
340 # let's dump the syslog ring somewhere so we can find it later
341 dmesg > /var/log/dmesg
342 chmod 640 /var/log/dmesg
343
344 # Feed entropy into the entropy pool
345 /etc/rc.d/init.d/random start
This page took 0.05288 seconds and 3 git commands to generate.