]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/rc.sysinit
- logging errors from depmod and modprobe via syslog
[projects/rc-scripts.git] / rc.d / rc.sysinit
1 #!/bin/sh
2 #
3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.24 1999/09/02 12:16:15 misiek Exp $
5 #
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes:      Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
8 #
9
10 # Set the path
11 PATH=/bin:/sbin:/usr/bin:/usr/sbin
12 export PATH
13
14 # NLS
15 if [ -f /etc/sysconfig/i18n ]; then
16         . /etc/sysconfig/i18n
17         [ -n "$LANG" ] && export LANG || unset LANG
18         [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
19         [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
20         [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
21         [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
22         [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
23         [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
24         [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
25         [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
26         [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
27 fi
28
29
30 # Read functions
31 . /etc/rc.d/init.d/functions
32
33 # Read network config data.
34 if [ -f /etc/sysconfig/network ]; then
35         . /etc/sysconfig/network
36 else
37         NETWORKING=no
38         HOSTNAME=localhost
39 fi
40
41 # Read system config data.
42 if [ -f /etc/sysconfig/system ]; then
43         . /etc/sysconfig/system
44 else
45         RUN_SULOGIN_ON_ERR=yes
46         RUN_ISAPNP=yes
47         PANIC_REBOOT_TIME=0
48         DELAY_LOGIN=yes
49         CLEAN_TMP=no
50         CONSOLE_LOGLEVEL=1
51         LOAD_SOUND=yes
52         SET_SLINKS=yes
53 fi
54
55 # Set console loglevel
56 /sbin/loglevel $CONSOLE_LOGLEVEL
57
58 # Start up swapping.
59 run_cmd "`nls "Activating swap partitions"`" swapon -a
60
61 # Set the hostname.
62 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
63
64 # Set the NIS domain name
65 if [ -n "$NISDOMAIN" ]; then
66         run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
67 else
68         domainname ""
69 fi
70
71 if [ -f /fsckoptions ]; then
72         fsckoptions=`cat /fsckoptions`
73 else
74         fsckoptions=''
75 fi
76
77 if [ -f /forcefsck ]; then
78         fsckoptions="-f $fsckoptions"
79 fi
80
81 # we need /proc mounted before starting fsck
82 mount -t proc /proc /proc
83
84 _RUN_QUOTACHECK=0
85 if [ ! -f /fastboot ]; then
86         show "Checking root filesystems."; started
87         initlog -c "fsck -T -a $fsckoptions /"
88
89         rc=$?
90
91         # A return of 2 or higher means there were serious problems.
92         if [ $rc -gt 1 ]; then
93                 echo
94                 echo
95                 nls "*** An error occurred during the file system check."
96                 nls "*** Dropping you to a shell; the system will reboot"
97                 nls "*** when you leave the shell."
98
99                 PS1="`nls '(Repair filesystem) #'`"; export PS1
100                 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
101                         sulogin
102                 else
103                         /bin/sh
104                 fi
105
106                 run_cmd "Unmounting file systems" umount -a
107                 mount -n -o remount,ro /
108                 run_cmd "Automatic reboot in progress." reboot
109         elif [ "$rc" == "1" ]; then
110                 _RUN_QUOTACHECK=1
111         fi
112 fi
113
114 # check for arguments 
115 if grep -i nopnp /proc/cmdline >/dev/null ; then
116         PNP=
117 else
118         PNP=yes
119 fi
120
121 # set up pnp 
122 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
123         if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
124                 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
125         fi
126 fi
127
128 # Remount the root filesystem read-write.
129 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
130
131 # Update quotas if fsck was run on /.
132 if [ X"$_RUN_QUOTACHECK" == "X1" -a -x /sbin/quotacheck ]; then
133         run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
134 fi
135
136 # /etc/nologin when starting system
137 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
138
139 if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
140         show "Enabling Delay Login"; busy
141         echo > /etc/nologin
142         nls "System bootup in progress  - please wait" >> /etc/nologin
143         echo >> /etc/nologin
144         chmod 644 /etc/nologin
145         cp -fp /etc/nologin /etc/nologin.boot
146         deltext; ok
147 fi
148
149
150 # Clear mtab
151 >/etc/mtab
152
153 # Enter root and /proc into mtab.
154 mount -f /
155 mount -f /proc
156
157 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
158         USEMODULES=y
159 else
160         USEMODULES=
161 fi
162
163 # Kernel dependent links
164 rm -f /lib/modules/preferred
165 rm -f /lib/modules/default
166 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
167  if [ "$SET_SLINKS" != "no" ]; then
168     # Get ready for kmod if module support in the kernel
169     if [ -z `uname -r | grep "-"` ]; then
170        # we're using a new kernel, no preferred needed
171        mver=`uname -r`
172     else
173        ktag="`cat /proc/version`"
174        mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
175        if [ -n "$mtag" ]; then
176           mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[       ].*$,,'
177        fi
178        if [ -n "$mver" ]; then
179          ln -sf /lib/modules/$mver /lib/modules/default
180        fi
181     fi
182  fi
183     [ -n "$mver" -a -f "/boot/module-info-$mver" ] && ln -sf /boot/module-info-$mver /boot/module-info
184     [ -n "$mver" -a -f "/boot/System.map-$mver" ] && ln -sf /boot/System.map-$mver /boot/System.map
185     run_cmd "Finding module dependencies" depmod -a -s
186 fi
187
188 # load sound modules
189 if [ -n "$USEMODULES" ] && [ "$LOAD_SOUND" == "yes" ]; then
190    if grep -s -q "^alias sound" /etc/conf.modules ; then
191       run_cmd "Loading sound module" modprobe -s sound
192    fi
193    if grep -s -q "^alias midi" /etc/conf.modules ; then
194       run_cmd "Loading midi module" modprobe -s midi
195    fi
196 fi
197
198 if [ -f /proc/sys/kernel/modprobe ]; then
199         # /proc/sys/kernel/modprobe indicates built-in kmod instead
200         echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
201 fi
202
203 # Add raid devices
204 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
205         show "Starting up RAID devices."; started
206         initlog -c 'raidadd -a'
207
208         rc=$?
209         if [ $rc = 0 ]; then
210                 raidrun -a
211                 rc=$?
212         fi
213
214         # A non-zero return means there were problems.
215         if [ $rc -gt 0 ]; then
216                 echo
217                 echo
218                 nls "*** An error occurred during the RAID startup"
219                 nls "*** Dropping you to a shell; the system will reboot"
220                 nls "*** when you leave the shell."
221
222                 PS1='(RAID Repair) #'; export PS1
223                 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
224                         sulogin
225                 else
226                         /bin/sh
227                 fi
228
229                 run_cmd "Unmounting file systems" umount -a
230                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
231                 run_cmd "Automatic reboot in progress" reboot
232         fi
233 fi
234
235 # Check filesystems
236 if [ ! -f /fastboot ]; then
237         show "Checking filesystems."; started
238         initlog -c "fsck -T -R -A -a $fsckoptions"
239
240         rc=$?
241
242         # A return of 2 or higher means there were serious problems.
243         if [ $rc -gt 1 ]; then
244                 echo
245                 echo
246                 nls "*** An error occurred during the file system check."
247                 nls "*** Dropping you to a shell; the system will reboot"
248                 nls "*** when you leave the shell."
249
250                 PS1="`nls '(Repair filesystem) #'`"; export PS1
251                 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
252                         sulogin
253                 else
254                         /bin/sh
255                 fi
256
257                 run_cmd "Unmounting file systems" umount -a
258                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
259                 run_cmd "Automatic reboot in progress." reboot
260         elif [ "$rc" == "1" -a -x /sbin/quotacheck ]; then
261                 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
262         fi
263 fi
264
265 # Mount all other filesystems (except for NFS and /proc, which is already
266 # mounted). Contrary to standard usage,
267 # filesystems are NOT unmounted in single user mode.
268 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
269
270 # set the console font
271 if [ -x /sbin/setsysfont ]; then
272         show "Loading default system font"; busy
273         if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
274 fi
275
276 if [ -x /sbin/quotaon ]; then
277         run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
278 fi
279
280 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
281 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
282 rm -f /var/run/utmp  
283 :>/var/run/utmpx
284 chown root.utmp /var/run/utmpx
285 chmod 0664 /var/run/utmpx /var/log/wtmpx
286
287 # Clean /tmp
288 if [ "$CLEAN_TMP" == "yes" ]; then
289         rm -rf /tmp/*
290 fi
291
292 # Delete UUCP lock files.
293 rm -f /var/lock/LCK*
294
295 # Delete stale subsystem files.
296 rm -f /var/lock/subsys/*
297
298 # Delete stale pam_console locks.
299 rm -f /var/lock/console/*
300 rm -f /var/lock/console.lock
301
302 # Delete stale pid files
303 rm -f /var/run/*.pid
304 rm -f /var/spool/postoffice/.pid.*
305
306 # Delete X locks
307 rm -f /tmp/.X*-lock
308
309 # Delete Postgres sockets
310 rm -f /tmp/.s.PGSQL.*
311
312 # Set the system clock.
313 show "Setting clock"; busy
314
315 ARC=0
316 UTC=0
317 if [ -f /etc/sysconfig/clock ]; then
318         . /etc/sysconfig/clock
319
320         # convert old style clock config to new values
321         if [ "${CLOCKMODE}" == "GMT" ]; then
322                 UTC=true
323         elif [ "${CLOCKMODE}" == "ARC" ]; then
324             ARC=true
325         fi
326 fi
327
328 if [ -x /sbin/hwclock ]; then
329         CLOCKFLAGS="--hctosys"
330         CLOCK=/sbin/hwclock
331 else
332         CLOCKFLAGS="-a"
333         CLOCK=/sbin/clock
334 fi
335
336 case "$UTC" in
337   yes|true)
338         CLOCKFLAGS="$CLOCKFLAGS -u";
339 #       echo -n " (utc)"
340         ;;
341 esac
342
343 case "$ARC" in
344   yes|true)
345         CLOCKFLAGS="$CLOCKFLAGS -A";
346 #       echo -n " (arc)"
347         ;;
348 esac
349
350 #echo -n ": "
351 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
352
353 show "`nls "Date set to"` `date`"; ok
354
355 # Right, now turn on swap in case we swap to files.
356 show "Enabling swap space"; busy
357 if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
358         deltext; ok
359 else
360         deltext; fail
361 fi
362
363 # Initialize the serial ports.
364 if [ -f /etc/rc.d/rc.serial ]; then
365         . /etc/rc.d/rc.serial
366 fi
367
368 # If a SCSI tape has been detected, load the st module unconditionally
369 # since many SCSI tapes don't deal well with st being loaded and unloaded
370 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type:   Sequential-Access' 2>/dev/null ; then
371         if cat /proc/devices | grep -qv ' 9 st' ; then
372                 if [ -n "$USEMODULES" ] ; then
373                         # Try to load the module.  If it fails, ignore it...
374                         insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
375                 fi
376         fi
377 fi
378
379 # there could be a new kernel version.  reinit /etc/psdevtab, to be sure.
380 rm -f /etc/psdevtab
381 #if [ -x /bin/ps ]; then
382 #show "Rebuilding /etc/psdevtab database"; busy
383 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
384 #fi
385
386 if [ -x /sbin/ldconfig ]; then
387 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
388 fi
389
390 if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
391 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
392 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
393 fi
394
395 # Now that we have all of our basic modules loaded and the kernel going,
396 # let's dump the syslog ring somewhere so we can find it later
397 dmesg > /var/log/dmesg
398 chmod 640 /var/log/dmesg
399
400 # Feed entropy into the entropy pool
401 /etc/rc.d/init.d/random start
This page took 0.053275 seconds and 4 git commands to generate.