]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/rc.sysinit
- Allow set /proc/sys/fs/file-max & inode-max
[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.51 2000/03/22 17:24:28 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 # Read functions
30 . /etc/rc.d/init.d/functions
31
32 # Read network config data.
33 if [ -f /etc/sysconfig/network ]; then
34         . /etc/sysconfig/network
35 else
36         NETWORKING=no
37         HOSTNAME=localhost
38 fi
39
40 # Read system config data.
41 if [ -f /etc/sysconfig/system ]; then
42         . /etc/sysconfig/system
43 else
44         RUN_SULOGIN_ON_ERR=yes
45         RUN_ISAPNP=yes
46         PANIC_REBOOT_TIME=0
47         DELAY_LOGIN=yes
48         CLEAN_TMP=no
49         CONSOLE_LOGLEVEL=1
50         LOAD_SOUND=yes
51         SET_SLINKS=yes
52         RUN_LDCONFIG=yes
53 fi
54
55 # Print welcome message
56 echo -e "\t\t\t`termput setaf 6`Powered by `termput setaf 2`PLD GNU/Linux`termput setaf 7`"
57 if [ "$PROMPT" != "no" ]; then
58         echo -en "\t\t`nls "Press"` '`termput setaf 1`I`termput setaf 7`' `nls "to enter interactive startup."`"
59         echo
60         sleep 1
61 fi
62    
63 # set up devfsd
64 if [ -x /sbin/devfsd -a -f /etc/devfsd.conf ]; then
65         if [ "$RUN_DEVFSD" = "yes" ]; then
66                 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
67         fi
68 fi
69
70 # Set console loglevel
71 /bin/dmesg -n $CONSOLE_LOGLEVEL
72
73 # Turn off sysrq
74 if [ -f /proc/sys/kernel/sysrq -a "$MAGIC_SYSRQ" = "no" ]; then
75         echo "0" > /proc/sys/kernel/sysrq
76         run_cmd "Turning off Magic SysRq key" /bin/true
77 fi
78
79 # Turn off Stop-A
80 if [ -f /proc/sys/kernel/stop-a -a "$STOP_A" = "no" ]; then
81         echo "0" > /proc/sys/kernel/stop-a
82         run_cmd "Turning off Stop-A/Break-A" /bin/true
83 fi
84                                 
85 # we need /proc mounted before starting fsck
86 mount -n -t proc /proc /proc
87
88 # Start up swapping.
89 run_cmd "`nls "Activating swap partitions"`" swapon -a
90
91 # Set the hostname.
92 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
93
94 # Set the NIS domain name
95 if [ -n "$NISDOMAIN" ]; then
96         run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
97 else
98         domainname ""
99 fi
100
101 if [ -f /fsckoptions ]; then
102         fsckoptions=`cat /fsckoptions`
103 else
104         fsckoptions=''
105 fi
106
107 if [ -f /forcefsck ]; then
108         fsckoptions="-f $fsckoptions"
109 fi
110
111 _RUN_QUOTACHECK=0
112 if [ ! -f /fastboot -o awk '{ if ($2 ~ /^\/$/ && ( $3 ~ /^(nfs|romfs)$/ || $6 ~ /^0$/ ) ) exit 0 ; else exit 1}' /etc/fstab ]; then
113         show "Checking root filesystems."; started
114         initlog -c "fsck -C -T -a $fsckoptions /"
115
116         rc=$?
117
118         # A return of 2 or higher means there were serious problems.
119         if [ $rc -gt 1 ]; then
120                 # don't use '\n' in nls macro !
121                 echo "\n\n"
122                 nls "*** An error occurred during the file system check."
123                 nls "*** Dropping you to a shell; the system will reboot"
124                 nls "*** when you leave the shell."
125                 echo
126
127                 PS1="`nls "(Repair filesystem)# "`"; export PS1
128                 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
129                         sulogin
130                 else
131                         /bin/sh
132                 fi
133
134                 run_cmd "Unmounting file systems" umount -a
135                 mount -n -o remount,ro /
136                 run_cmd "Automatic reboot in progress." reboot
137         elif [ "$rc" = "1" ]; then
138                 _RUN_QUOTACHECK=1
139         fi
140 fi
141
142 # check for arguments 
143 if grep -i nopnp /proc/cmdline >/dev/null ; then
144         PNP=
145 else
146         PNP=yes
147 fi
148
149 # set up pnp 
150 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
151         if [ -n "$PNP" -a "$RUN_ISAPNP" = "yes" ]; then
152                 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
153         fi
154 fi
155
156
157 # Remount the root filesystem read-write.
158 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
159
160 # Update quotas if fsck was run on /.
161 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ]; then
162         run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
163 fi
164
165 # /etc/nologin when starting system
166 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
167
168 if [ "$DELAY_LOGIN" = "yes" -a ! -f /etc/nologin ]; then
169         show "Enabling Delay Login"; busy
170         echo > /etc/nologin
171         nls "System bootup in progress  - please wait" >> /etc/nologin
172         echo >> /etc/nologin
173         chmod 644 /etc/nologin
174         cp -fp /etc/nologin /etc/nologin.boot
175         deltext; ok
176 fi
177
178 echo ${HOSTNAME} > /etc/HOSTNAME
179
180 # Clear mtab
181 >/etc/mtab
182
183 # Enter root and /proc into mtab.
184 mount -f /
185 mount -f /proc
186
187 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
188         USEMODULES=y
189 else
190         USEMODULES=
191 fi
192
193 # Kernel dependent links
194 rm -f /lib/modules/preferred
195 rm -f /lib/modules/default
196 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
197         if [ "$SET_SLINKS" != "no" ]; then
198         # Get ready for kmod if module support in the kernel
199                 if [ -z `uname -r | grep "-"` ]; then
200                 # we're using a new kernel, no preferred needed
201                         mver=`uname -r`
202                 else
203                         ktag="`cat /proc/version`"
204                         mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
205                         if [ -n "$mtag" ]; then
206                                 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's, \
207                                         /.rhkmvtag,,' -e 's,[       ].*$,,'
208                         fi
209                         if [ -n "$mver" ]; then
210                                 ln -sf /lib/modules/$mver /lib/modules/default
211                         fi
212                 fi
213         fi
214         [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
215                 ln -sf /boot/module-info-$mver /boot/module-info
216         [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
217                 ln -sf /boot/System.map-$mver /boot/System.map
218
219         # Run depmod if: a) user requested; b) modules.dep is missing
220         # c) modules.dep is older than /etc/modules.conf
221         if [ "$RUN_DEPMOD" != "no" ]; then
222                 if [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] || (find /lib/modules/$mver/ -name modules.dep ! -newer /etc/modules.conf -print 2>&1 | grep -q "modules.dep"); then
223                         run_cmd "Finding module dependencies" depmod -a
224                 fi
225         fi
226 fi
227
228 # load sound modules
229 if [ -n "$USEMODULES" -a "$LOAD_SOUND" = "yes" ]; then
230         if grep -s -q "^alias sound" /etc/modules.conf ; then
231                 run_cmd "Loading sound module" modprobe -s sound
232         fi
233         if grep -s -q "^alias midi" /etc/modules.conf ; then
234                 run_cmd "Loading midi module" modprobe -s midi
235         fi
236 fi
237
238 if [ -f /proc/sys/kernel/modprobe ]; then
239         # /proc/sys/kernel/modprobe indicates built-in kmod instead
240         echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
241 fi
242
243 # Load modules
244 if [ -f /etc/rc.d/rc.modules ]; then
245         /etc/rc.d/rc.modules
246 fi
247
248 # Add raid devices
249 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
250         show "Starting up RAID devices."; started
251
252         rc=0
253         
254         for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
255         do
256                 RAIDDEV=`basename $i`
257                 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
258                 if [ -z "$RAIDSTAT" ]; then
259                         # Try raidstart first...if that fails then
260                         # fall back to raid0run.
261                         RESULT=1
262                         if [ -x /sbin/raidstart ]; then
263                                 /sbin/raidstart $i
264                                 RESULT=$?
265                         fi
266                         if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
267                                 /sbin/raid0run $i
268                         fi
269                 fi
270         done
271
272         # A non-zero return means there were problems.
273         if [ $rc -gt 0 ]; then
274                 show "Starting up RAID devices."; fail
275                 echo "\n\n"
276                 nls "*** An error occurred during the RAID startup"
277                 nls "*** Dropping you to a shell; the system will reboot"
278                 nls "*** when you leave the shell."
279                 echo
280
281                 PS1="`nls "(RAID Repair)# "`"; export PS1
282                 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
283                         sulogin
284                 else
285                         /bin/sh
286                 fi
287
288                 run_cmd "Unmounting file systems" umount -a
289                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
290                 run_cmd "Automatic reboot in progress" reboot
291         fi
292         show "Starting up RAID devices."; ok
293 fi
294
295 # Check filesystems
296 if [ ! -f /fastboot ]; then
297         show "Checking filesystems."; started
298         initlog -c "fsck -C -T -R -A -a $fsckoptions"
299
300         rc=$?
301
302         # A return of 2 or higher means there were serious problems.
303         if [ $rc -gt 1 ]; then
304                 echo "\n\n"
305                 nls "*** An error occurred during the file system check."
306                 nls "*** Dropping you to a shell; the system will reboot"
307                 nls "*** when you leave the shell."
308                 echo
309
310                 PS1="`nls "(Repair filesystem)# "`"; export PS1
311                 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
312                         sulogin
313                 else
314                         /bin/sh
315                 fi
316
317                 run_cmd "Unmounting file systems" umount -a
318                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
319                 run_cmd "Automatic reboot in progress." reboot
320         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
321                 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
322         fi
323 fi
324
325 # Mount all other filesystems (except for NFS and /proc, which is already
326 # mounted). Contrary to standard usage,
327 # filesystems are NOT unmounted in single user mode.
328 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
329
330 # set the console font
331 #if [ -x /sbin/setsysfont ]; then
332 #       show "Loading default system font"; busy
333 #       if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
334 #fi
335
336 if [ -x /sbin/quotaon ]; then
337         run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
338 fi
339
340 {
341 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
342 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
343
344 # Clean up utmp/wtmp
345 :>/var/run/utmp
346 touch /var/log/wtmp
347 chown root.utmp /var/run/utmp /var/log/wtmp
348 chmod 0664 /var/run/utmp /var/log/wtmp
349 if [ -n "$NEED_XFILES" ]; then
350         :>/var/run/utmpx
351         touch /var/log/wtmpx
352         chown root.utmp /var/run/utmpx /var/log/wtmpx
353         chmod 0664 /var/run/utmpx /var/log/wtmpx
354 fi
355
356 # Clean /tmp
357 if [ "$CLEAN_TMP" = "yes" ]; then
358         rm -rf /tmp/*
359 fi
360
361 # Delete UUCP lock files.
362 rm -f /var/lock/LCK*
363
364 # Delete stale subsystem files.
365 rm -f /var/lock/subsys/*
366
367 # Delete stale pam_console locks.
368 rm -f /var/lock/console/*
369 rm -f /var/lock/console.lock
370
371 # Delete stale pid files
372 rm -f /var/run/*.pid
373 rm -f /var/spool/postoffice/.pid.*
374
375 # Delete X locks
376 rm -f /tmp/.X*-lock
377
378 # Delete Postgres sockets
379 rm -f /tmp/.s.PGSQL.*
380
381 # Set the system clock.
382 show "Setting clock"; busy
383
384 ARC=0
385 UTC=0
386 if [ -f /etc/sysconfig/clock ]; then
387         . /etc/sysconfig/clock
388
389         # convert old style clock config to new values
390         if [ "${CLOCKMODE}" = "GMT" ]; then
391                 UTC=true
392         elif [ "${CLOCKMODE}" = "ARC" ]; then
393             ARC=true
394         fi
395 fi
396
397 if [ -x /sbin/hwclock ]; then
398         CLOCKFLAGS="--hctosys"
399         CLOCK=/sbin/hwclock
400 else
401         CLOCKFLAGS="-a"
402         CLOCK=/sbin/clock
403 fi
404
405 case "$UTC" in
406   yes|true)
407         CLOCKFLAGS="$CLOCKFLAGS -u";
408 #       echo -n " (utc)"
409         ;;
410 esac
411
412 case "$ARC" in
413   yes|true)
414         CLOCKFLAGS="$CLOCKFLAGS -A";
415 #       echo -n " (arc)"
416         ;;
417 esac
418
419 #echo -n ": "
420 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
421
422 show "`nls "Date set to"` `date`"; ok
423
424 # Right, now turn on swap in case we swap to files.
425 swapon -a >/dev/null 2>&1
426 run_cmd "Enabling swap space" /bin/true
427 #show "Enabling swap space"; busy
428 #if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" = "" ]; then
429 #       deltext; ok
430 #else
431 #       deltext; fail
432 #fi
433
434 # Initialize the serial ports.
435 if [ -f /etc/rc.d/rc.serial ]; then
436         . /etc/rc.d/rc.serial
437 fi
438
439 # If a SCSI tape has been detected, load the st module unconditionally
440 # since many SCSI tapes don't deal well with st being loaded and unloaded
441 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type:   Sequential-Access' 2>/dev/null ; then
442         if cat /proc/devices | grep -qv ' 9 st' ; then
443                 if [ -n "$USEMODULES" ] ; then
444                         # Try to load the module.  If it fails, ignore it...
445                         insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
446                 fi
447         fi
448 fi
449
450 # there could be a new kernel version.  remove old psdevtab database
451 rm -f /etc/psdevtab
452
453 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
454 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
455 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
456 fi
457
458 # If needed increase number of available system files
459 # There are two versions of each setting, because file names
460 # changed between Linux 2.0 and 2.2
461 if [ -f /proc/sys/kernel/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
462         echo $VFS_FILE_MAX >/proc/sys/kernel/file-max
463 fi
464 if [ -f /proc/sys/fs/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
465         echo $VFS_FILE_MAX >/proc/sys/fs/file-max
466 fi
467 if [ -f /proc/sys/kernel/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
468         echo $VFS_INODE_MAX >/proc/sys/kernel/inode-max
469 fi
470 if [ -f /proc/sys/fs/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
471         echo $VFS_INODE_MAX >/proc/sys/fs/inode-max
472 fi
473
474
475 # Now that we have all of our basic modules loaded and the kernel going,
476 # let's dump the syslog ring somewhere so we can find it later
477 dmesg > /var/log/dmesg
478 chmod 640 /var/log/dmesg
479
480 # Now that we have all of our basic modules loaded and the kernel going,
481 # let's dump the syslog ring somewhere so we can find it later
482 kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1
483 } &
484 if [ "$PROMPT" != "no" ]; then
485    /sbin/getkey i && touch /var/run/confirm
486 fi
487 wait
488    
489 # Feed entropy into the entropy pool
490 /etc/rc.d/init.d/random start
This page took 0.091378 seconds and 4 git commands to generate.