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