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