]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/rc.sysinit
- added initial main system configuration file with:
[projects/rc-scripts.git] / rc.d / rc.sysinit
CommitLineData
7742e157
AF
1#!/bin/bash
2#
3# /etc/rc.d/rc.sysinit - run once at boot time
4#
5# Taken in part from Miquel van Smoorenburg's bcheckrc.
6#
7
8# Set the path
9PATH=/bin:/sbin:/usr/bin:/usr/sbin
10export PATH
11
12# Read in config data.
13if [ -f /etc/sysconfig/network ]; then
14 . /etc/sysconfig/network
15else
16 NETWORKING=no
17 HOSTNAME=localhost
18fi
19
20# Start up swapping.
21echo "Activating swap partitions"
22swapon -a
23
24# Set the hostname.
25hostname ${HOSTNAME}
26echo hostname: `hostname`
27
28# Set the NIS domain name
29if [ -n "$NISDOMAIN" ]; then
30 domainname $NISDOMAIN
31else
32 domainname ""
33fi
34
35if [ -f /fsckoptions ]; then
36 fsckoptions=`cat /fsckoptions`
37 else
38 fsckoptions=''
39fi
40
41if [ ! -f /fastboot ]; then
42 echo "Checking root filesystems."
43 fsck -V -a $fsckoptions /
44
45 rc=$?
46
47 # A return of 2 or higher means there were serious problems.
48 if [ $rc -gt 1 ]; then
49 echo
50 echo
51 echo "*** An error occurred during the file system check."
52 echo "*** Dropping you to a shell; the system will reboot"
53 echo "*** when you leave the shell."
54
55 PS1="(Repair filesystem) #"; export PS1
56 sulogin
57
58 echo "Unmounting file systems"
59 umount -a
60 mount -n -o remount,ro /
61 echo "Automatic reboot in progress."
62 reboot
63 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
64 echo "Checking root filesystem quotas"
65 /sbin/quotacheck -v /
66 fi
67fi
68
69if [ -x /sbin/quotaon ]; then
70 echo "Turning on user and group quotas for root filesystem"
71 /sbin/quotaon /
72fi
73
74# check for arguments
75
76mount -t proc /proc /proc
77if grep -i nopnp /proc/cmdline >/dev/null ; then
78 PNP=
79else
80 PNP=yes
81fi
82
83# set up pnp
84if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
85 if [ -n "$PNP" ]; then
86 echo "Setting up ISA PNP devices"
87 /sbin/isapnp /etc/isapnp/isapnp.conf
88 else
89 echo "Skipping ISA PNP configuration at users request"
90 fi
91fi
92
93# Remount the root filesystem read-write.
94echo "Remounting root filesystem in read-write mode."
95mount -n -o remount,rw /
96
97if [ ! -f /etc/HOSTNAME ]; then
98 echo ${HOSTNAME} > /etc/HOSTNAME
99fi
100
101# Clear mtab
102>/etc/mtab
103
104# Enter root and /proc into mtab.
105mount -f /
106mount -f /proc
107
108if [ -f /proc/ksyms ]; then
109 USEMODULES=y
110else
111 USEMODULES=
112fi
113
114# Get the modules ready to go -- we use awk here as cut is in /usr/bin
115rm -f /lib/modules/preferred
116if [ -n $USEMODULES ]; then
117 set `cat /proc/cmdline`
118 while [ $# -gt 0 ]; do
119 if echo $1 | grep '^BOOT_IMAGE=' > /dev/null ; then
120 image=`echo $1 | awk -F= '{ print $2 }'`
121 kernelfile=`/sbin/lilo -I $image`
122 if [ -n "$kernelfile" ]; then
123 kernelname=`echo $kernelfile | awk -F- '{ print $1 }'`
124 versioninfo=`echo $kernelfile | sed "s|${kernelname}-||"`
125 if [ "$kernelname" = "/boot/vmlinuz" -a \
126 -d /lib/modules/$versioninfo -a \
127 $versioninfo != `uname -r` ]; then
128 ln -sf $versioninfo /lib/modules/preferred
129 fi
130 fi
131 fi
132 shift
133 done
134fi
135
136if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
137 # Get ready for kerneld if module support in the kernel
138 echo -n "Finding module dependencies... "
139 if [ -e /lib/modules/preferred ]; then
140 depmod -a preferred
141 else
142 depmod -a
143 fi
144 echo "done"
145fi
146
147# load sound modules
148if ! grep -i nomodules /proc/cmdline >/dev/null ; then
149 if [ -n "$USEMODULES" ]; then
150 if grep -s "alias sound" /etc/conf.modules > /dev/null ; then
151 modprobe sound
152 if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
153 modprobe midi
154 fi
155 fi
156 fi
157fi
158
159if [ -x /sbin/kerneld -a -n "$USEMODULES" ]; then
160 if [ -f /proc/sys/kernel/modprobe ]; then
161 # /proc/sys/kernel/modprobe indicates built-in kmod instead
162 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
163 else
164 /sbin/kerneld
165 KERNELD=yes
166 fi
167fi
168
169# Check filesystems
170if [ ! -f /fastboot ]; then
171 echo "Checking filesystems."
172 fsck -R -A -V -a $fsckoptions
173
174 # A return of 2 or higher means there were serious problems.
175 if [ $? -gt 1 ]; then
176 echo
177 echo
178 echo "*** An error occurred during the file system check."
179 echo "*** Dropping you to a shell; the system will reboot"
180 echo "*** when you leave the shell."
181
182 PS1="(Repair filesystem) #"; export PS1
183 sulogin
184
185 echo "Unmounting file systems"
186 umount -a
187 mount -n -o remount,ro /
188 echo "Automatic reboot in progress."
189 reboot
190 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
191 echo "Checking filesystem quotas"
192 /sbin/quotacheck -v -R -a
193 fi
194fi
195
196# Mount all other filesystems (except for NFS and /proc, which is already
197# mounted). Contrary to standard usage,
198# filesystems are NOT unmounted in single user mode.
199echo "Mounting local filesystems."
200mount -a -t nonfs,proc
201
202# set the console font
203if [ -x /sbin/setsysfont ]; then
204 /sbin/setsysfont
205fi
206
207if [ -x /sbin/quotaon ]; then
208 echo "Turning on user and group quotas for local filesystems"
209 /sbin/quotaon -a
210fi
211
212# Clean out /etc.
213rm -f /etc/mtab~ /fastboot /fsckoptions
214>/var/run/utmp
215
216# Delete UUCP lock files.
217rm -f /var/lock/LCK*
218
219# Delete stale subsystem files.
220rm -f /var/lock/subsys/*
221
222if [ -n "$KERNELD" ]; then
223 touch /var/lock/subsys/kerneld
224fi
225
226# Delete stale pid files
227rm -f /var/run/*.pid
228rm -f /var/spool/postoffice/.pid.*
229
230# Delete X locks
231rm -f /tmp/.X*-lock
232
233# Set the system clock.
234echo -n "Setting clock"
235
236ARC=0
237UTC=0
238if [ -f /etc/sysconfig/clock ]; then
239 . /etc/sysconfig/clock
240
241 # convert old style clock config to new values
242 if [ "${CLOCKMODE}" = "GMT" ]; then
243 UTC=true
244 elif [ "${CLOCKMODE}" = "ARC" ]; then
245 ARC=true
246 fi
247fi
248
249if [ -x /sbin/hwclock ]; then
250 CLOCKFLAGS="--hctosys"
251 CLOCK=/sbin/hwclock
252else
253 CLOCKFLAGS="-a"
254 CLOCK=/sbin/clock
255fi
256
257if [ $UTC = "true" ]; then
258 CLOCKFLAGS="$CLOCKFLAGS -u";
259 echo -n " (utc)"
260fi
261if [ $ARC = "true" ]; then
262 CLOCKFLAGS="$CLOCKFLAGS -A";
263 echo -n " (arc)"
264fi
265echo -n ": "
266$CLOCK $CLOCKFLAGS
267
268date
269
270# Right, now turn on swap in case we swap to files.
271echo "Enabling swap space."
272swapon -a 2>&1 | grep -v "busy"
273
274# Initialize the serial ports.
275if [ -f /etc/rc.d/rc.serial ]; then
276 . /etc/rc.d/rc.serial
277fi
278
279# Load modules (for backward compatibility with VARs)
280if [ -f /etc/rc.d/rc.modules ]; then
281 /etc/rc.d/rc.modules
282fi
283
284# If a SCSI tape has been detected, load the st module unconditionally
285# since many SCSI tapes don't deal well with st being loaded and unloaded
286if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
287 if cat /proc/devices | grep -qv ' 9 st' ; then
288 if [ -n "$USEMODULES" ] ; then
289 # Try to load the module. If it fails, ignore it...
290 modprobe st 2>/dev/null
291 fi
292 fi
293fi
294
295# Now that we have all of our basic modules loaded and the kernel going,
296# let's dump the syslog ring somewhere so we can find it later
297dmesg > /var/log/dmesg
298
299# Feed entropy into the entropy pool
300/etc/rc.d/init.d/random start
This page took 0.053135 seconds and 4 git commands to generate.