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