]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/rc.sysinit
88fc413ec449019ea2a22454070e3d899197e332
[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 # Remount the root filesystem read-write.
105 echo "Remounting root filesystem in read-write mode."
106 mount -n -o remount,rw /
107
108 # Clear mtab
109 >/etc/mtab
110
111 # Enter root and /proc into mtab.
112 mount -f /
113 mount -f /proc
114
115 if [ -f /proc/ksyms ]; then
116     USEMODULES=y
117 else
118     USEMODULES=
119 fi
120
121 # Set up kernel version-dependent symlinks.
122 rm -f /lib/modules/preferred
123 if [ -n "$USEMODULES" ]; then
124     ktag="`cat /proc/version`"
125     mtag=`grep -l "$ktag" /lib/modules/*/.rhkmvtag` 2> /dev/null
126     if [ -n "$mtag" ]; then
127         mver=`echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[       ].*$,,'`
128         ln -sf /lib/modules/$mver /lib/modules/preferred
129         ln -sf /boot/System.map-$mver /boot/System.map
130         ln -sf /boot/module-info-$mver /boot/module-info
131     fi
132 fi
133
134 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
135     # Get ready for kerneld if module support in the kernel
136     echo -n "Finding module dependencies... "
137     if [ -e /lib/modules/preferred ]; then
138         depmod -a preferred
139     else
140         depmod -a
141     fi
142     echo "done"
143 fi
144
145 # load sound modules
146 if ! grep -i nomodules /proc/cmdline >/dev/null ; then
147     if [ -n "$USEMODULES" ]; then
148         if grep -s "alias sound" /etc/conf.modules > /dev/null ; then
149             modprobe sound
150             if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
151                 modprobe midi
152             fi
153         fi
154     fi
155 fi
156
157 if [ -f /proc/sys/kernel/modprobe ]; then
158         # /proc/sys/kernel/modprobe indicates built-in kmod instead
159         echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
160 fi
161
162 # Add raid devices
163 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
164         echo "Starting up RAID devices."
165         raidadd -a
166
167         rc=$?
168
169         if [ $rc = 0 ]; then
170                 raidrun -a
171                 rc=$?
172         fi
173
174         # A non-zero return means there were problems.
175         if [ $rc -gt 0 ]; then
176                 echo
177                 echo
178                 echo "*** An error occurred during the RAID startup"
179                 echo "*** Dropping you to a shell; the system will reboot"
180                 echo "*** when you leave the shell."
181
182                 PS1="(RAID Repair) \#"; export PS1
183                 if [ "$RUN_SULOGIN_ON_ERR" = "yes"]; then
184                         sulogin
185                 else
186                         /bin/sh
187                 fi
188
189                 echo "Unmounting file systems"
190                 umount -a
191                 mount -n -o remount,ro /
192                 echo "Automatic reboot in progress."
193                 reboot
194         fi
195 fi
196
197 # Check filesystems
198 if [ ! -f /fastboot ]; then
199         echo "Checking filesystems."
200         fsck -R -A -V -a $fsckoptions
201
202         rc=$?
203
204         # A return of 2 or higher means there were serious problems.
205         if [ $rc -gt 1 ]; then
206                 echo
207                 echo
208                 echo "*** An error occurred during the file system check."
209                 echo "*** Dropping you to a shell; the system will reboot"
210                 echo "*** when you leave the shell."
211
212                 PS1="(Repair filesystem) \#"; export PS1
213                 if [ "$RUN_SULOGIN_ON_ERR" = "yes"]; then
214                         sulogin
215                 else
216                         /bin/sh
217                 fi
218
219                 echo "Unmounting file systems"
220                 umount -a
221                 mount -n -o remount,ro /
222                 echo "Automatic reboot in progress."
223                 reboot
224         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
225                 echo "Checking filesystem quotas"
226                 /sbin/quotacheck -v -R -a
227         fi
228 fi
229
230 # Mount all other filesystems (except for NFS and /proc, which is already
231 # mounted). Contrary to standard usage,
232 # filesystems are NOT unmounted in single user mode.
233 echo "Mounting local filesystems."
234 mount -a -t nonfs,proc
235
236 # set the console font
237 if [ -x /sbin/setsysfont ]; then
238     /sbin/setsysfont
239 fi
240
241 if [ -x /sbin/quotaon ]; then
242     echo "Turning on user and group quotas for local filesystems"
243     /sbin/quotaon -a
244 fi
245
246 # Clean out /etc.
247 rm -f /etc/mtab~ /fastboot /fsckoptions
248 >/var/run/utmp
249
250 # Delete UUCP lock files.
251 rm -f /var/lock/LCK*
252
253 # Delete stale subsystem files.
254 rm -f /var/lock/subsys/*
255
256 # Delete stale pid files
257 rm -f /var/run/*.pid
258 rm -f /var/spool/postoffice/.pid.*
259
260 # Delete X locks
261 rm -f /tmp/.X*-lock
262
263 # Delete Postgres sockets
264 rm -f /tmp/.s.PGSQL.*
265
266 # Set the system clock.
267 echo -n "Setting clock"
268
269 ARC=0
270 UTC=0
271 if [ -f /etc/sysconfig/clock ]; then
272     . /etc/sysconfig/clock
273
274     # convert old style clock config to new values
275     if [ "${CLOCKMODE}" = "GMT" ]; then
276             UTC=true
277     elif [ "${CLOCKMODE}" = "ARC" ]; then
278             ARC=true
279     fi
280 fi
281
282 if [ -x /sbin/hwclock ]; then
283     CLOCKFLAGS="--hctosys"
284     CLOCK=/sbin/hwclock
285 else
286     CLOCKFLAGS="-a"
287     CLOCK=/sbin/clock
288 fi
289
290 case "$UTC" in
291   yes|true)
292     CLOCKFLAGS="$CLOCKFLAGS -u";
293     echo -n " (utc)"
294   ;;
295 esac
296
297 case "$ARC" in
298   yes|true)
299     CLOCKFLAGS="$CLOCKFLAGS -A";
300     echo -n " (arc)"
301   ;;
302 esac
303
304 echo -n ": "
305 $CLOCK $CLOCKFLAGS
306
307 date
308
309 # Right, now turn on swap in case we swap to files.
310 echo "Enabling swap space."
311 swapon -a 2>&1 | grep -v "busy"
312
313 # Initialize the serial ports.
314 if [ -f /etc/rc.d/rc.serial ]; then
315         . /etc/rc.d/rc.serial
316 fi
317
318 # Load modules (for backward compatibility with VARs)
319 if [ -f /etc/rc.d/rc.modules ]; then
320         /etc/rc.d/rc.modules
321 fi
322
323 # If a SCSI tape has been detected, load the st module unconditionally
324 # since many SCSI tapes don't deal well with st being loaded and unloaded
325 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type:   Sequential-Access' 2>/dev/null ; then
326         if cat /proc/devices | grep -qv ' 9 st' ; then
327                 if [ -n "$USEMODULES" ] ; then
328                         # Try to load the module.  If it fails, ignore it...
329                         modprobe st 2>/dev/null
330                 fi
331         fi
332 fi
333
334 # Now that we have all of our basic modules loaded and the kernel going,
335 # let's dump the syslog ring somewhere so we can find it later
336 dmesg > /var/log/dmesg
337 chmod 640 /var/log/dmesg
338
339 # Feed entropy into the entropy pool
340 /etc/rc.d/init.d/random start
This page took 0.051074 seconds and 2 git commands to generate.