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