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