]> git.ipfire.org Git - ipfire-2.x.git/blob - src/rc.d/rc.sysinit
5cb0d474f3ed883211f3079d6eebd10c36b69f9b
[ipfire-2.x.git] / src / rc.d / rc.sysinit
1 #!/bin/sh
2 #
3 # $Id: rc.sysinit,v 1.18.2.36 2005/12/01 20:13:08 eoberlander Exp $
4 #
5
6 eval $(/usr/local/bin/readhash CONFIG_ROOT/main/settings)
7
8 umask 022
9
10 PATH=/bin:/sbin:/usr/bin:/usr/sbin
11 export PATH
12
13 echo "Mounting /proc filesystem"
14 mount -n -t proc /proc /proc
15
16 # Unmount the initrd, if necessary
17 if grep -q /initrd /proc/mounts && ! grep -q /initrd/loopfs /proc/mounts ; then
18 umount /initrd >/dev/null 2>&1
19 blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
20 fi
21
22 echo "Setting hostname"
23 if [ -z "$DOMAINNAME" ]; then
24 hostname $HOSTNAME
25 else
26 hostname ${HOSTNAME}.${DOMAINNAME}
27 fi
28
29 if [ "$KEYMAP" != "" ]; then
30 loadkeys $KEYMAP
31 fi
32
33 # Initializing Power Management ACPI first, then APM.
34 # APM won't load if ACPI is initialized anyway.
35 echo "Initializing Power Management"
36 modprobe ac > /dev/null 2>&1
37 modprobe battery > /dev/null 2>&1
38 modprobe button > /dev/null 2>&1
39 modprobe fan > /dev/null 2>&1
40 modprobe processor > /dev/null 2>&1
41 modprobe thermal > /dev/null 2>&1
42 modprobe apm > /dev/null 2>&1
43
44 # Initialize USB controllers
45 echo "Initializing USB controllers"
46 aliases=`/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }'`
47 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
48 modprobe usbcore
49 mount -n -t usbdevfs usbdevfs /proc/bus/usb
50 for alias in $aliases ; do
51 [ "$alias" != "off" ] && modprobe $alias
52 done
53
54 echo "Initializing USB storage devices"
55 modprobe usb-storage
56 modprobe sd_mod
57
58 echo "Initializing USB keyboard"
59 modprobe hid
60 modprobe keybdev
61
62 echo "Initializing USB modems"
63 modprobe acm
64 fi
65
66 STRING="Checking root filesystem"
67
68 fsck -R -T -a -C /
69 RC=$?
70
71 if [ "$RC" = "0" ]; then
72 echo "$STRING: Success"
73 elif [ "$RC" = "1" ]; then
74 echo "$STRING: Passed"
75 fi
76
77 # A return of 2 or higher means there were serious problems.
78 if [ $RC -gt 1 ]; then
79 echo "$STRING: Failed"
80 echo "*** An error occurred during the file system check."
81 echo "*** Dropping you to a shell; the system will reboot"
82 echo "*** when you leave the shell."
83 export PS1="(Repair filesystem) \# # "
84 sulogin
85 echo "Unmounting filesystems"
86 umount -a
87 mount -n -o remount,ro /
88 echo "Automatic reboot in progress."
89 reboot -f
90 fi
91
92 echo "Mounting root read/write"
93 mount -n -o remount,rw /
94
95 STRING="Checking other filesystems"
96 fsck -R -T -a -C -A
97 RC=$?
98
99 if [ "$RC" = "0" ]; then
100 echo "$STRING: Success"
101 elif [ "$RC" = "1" ]; then
102 echo "$STRING: Passed"
103 fi
104
105 # A return of 2 or higher means there were serious problems.
106 if [ $RC -gt 1 ]; then
107 echo "$STRING: Failed"
108 echo "*** An error occurred during the file system check."
109 echo "*** Dropping you to a shell; the system will reboot"
110 echo "*** when you leave the shell."
111 export PS1="(Repair filesystem) \# # "
112 sulogin
113 echo "Unmounting filesystems"
114 umount -n -a
115 mount -n -o remount,ro /
116 echo "Automatic reboot in progress."
117 reboot -f
118 fi
119
120 echo "Mounting other filesystems"
121 mount -a -n
122
123 if [ -e /swapfile ]; then
124 echo "Turning on swap"
125 chmod 600 /swapfile
126 swapon /swapfile
127 fi
128
129 echo "Updating System.map file location"
130 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` -a \
131 ! /boot/System.map -ef /boot/System.map-`uname -r` ]; then
132 ln -s -f System.map-`uname -r` /boot/System.map
133 fi
134 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ]; then
135 ln -s -f System.map-`uname -r` /boot/System.map
136 fi
137
138 echo "Updating /etc/fstab to reflect removable devices"
139 /usr/sbin/updfstab
140
141 echo "Setting kernel settings"
142 /sbin/sysctl -e -p /etc/sysctl.conf >/dev/null
143
144 if [ -e /etc/FLASH ]; then
145 if [ -e /etc/rc.d/rc.flash.up ]; then
146 echo "Decompressing Flash"
147 . /etc/rc.d/rc.flash.up
148 fi
149 fi
150
151 echo "Setting locale"
152 LANG=en_US.utf8
153 export LANG
154
155 echo "Setting consolefonts"
156 eval $(/usr/local/bin/readhash CONFIG_ROOT/main/settings)
157 for i in 2 3 4 5 6; do
158 > /dev/tty$i
159 done
160 if [ "$LANGUAGE" = "el" ]; then
161 /usr/bin/unicode_start iso07u-16
162 elif [ "$LANGUAGE" = "pt" -o "$LANGUAGE" = "bz" ]; then
163 /usr/bin/unicode_start lat1-16
164 elif [ "$LANGUAGE" = "cs" -o "$LANGUAGE" = "hu" -o "$LANGUAGE" = "pl" -o "$LANGUAGE" = "sk" ]; then
165 /usr/bin/unicode_start lat2-16
166 elif [ "$LANGUAGE" = "tr" ]; then
167 /usr/bin/unicode_start lat5-16
168 elif [ "$LANGUAGE" = "vi" ]; then
169 /usr/bin/unicode_start viscii10-8x16
170 else
171 /usr/bin/unicode_start lat0-16
172 fi
173
174 echo "Update modules dependencies when necessary"
175 if [ -e /var/run/need-depmod-`uname -r` ]; then
176 /sbin/depmod -a
177 /bin/rm -f /var/run/need-depmod-`uname -r`
178 fi
179
180 echo "Clearing old files"
181 rm -f /var/run/{*.pid,*.sem,*.tdb}
182 rm -f /var/run/dhcpcd-*.pid
183 rm -f /var/lock/{LCK..tty*,rc.updatered.lock}
184 rm -f CONFIG_ROOT/dhcpc/{*.pid,*.cache,*.info}
185 rm -f CONFIG_ROOT/red/{active,eciadsl-synch-done}
186
187 echo "Setting the clock"
188 /sbin/hwclock --hctosys
189
190 # Cleaning up wtmp/utmp files
191 >/var/run/utmp
192 touch /var/log/wtmp
193 chgrp utmp /var/run/utmp /var/log/wtmp
194 chmod 0664 /var/run/utmp /var/log/wtmp
195
196 if [ -x /usr/sbin/isapnp -a -f CONFIG_ROOT/isapnp/isapnp.conf -a ! -f /proc/isapnp ]; then
197 echo "Running isapnp"
198 /usr/sbin/isapnp CONFIG_ROOT/isapnp/isapnp.conf 2>/dev/null
199 fi
200
201 if [ ! -e /etc/ssh/ssh_host_key ]; then
202 echo "Generating SSH RSA1 key. This may take several minutes."
203 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
204 fi
205 if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
206 echo "Generating SSH RSA key. This may take several minutes."
207 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
208 fi
209 if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then
210 echo "Generating SSH DSA key. This may take several minutes."
211 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
212 fi
213
214 # https certificate
215 if [ -f /etc/httpd/server.key -a -f /etc/httpd/server.crt -a -f /etc/httpd/server.csr ]; then
216 /usr/local/bin/httpscert read
217 else
218 /usr/local/bin/httpscert new
219 fi
220
221 echo "Rotating logs"
222 /usr/sbin/logrotate /etc/logrotate.conf
223
224 echo "Starting syslogd"
225 /usr/sbin/syslogd -m 0
226 echo "Starting klogd"
227 /usr/sbin/klogd -u klogd -j /var/empty
228
229 echo "Running /etc/rc.d/rc.network"
230 . /etc/rc.d/rc.network
231
232 echo "Dumping boot messages"
233 dmesg > /var/log/dmesg
234
235 if [ -e /var/log/rrd/disk.rrd ]; then
236 echo "Adjusting graphs to compensate for boot"
237 /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk.rrd","-t","readsect:writesect","N:U:U");'
238 fi
239
240 echo "Starting crond"
241 /usr/sbin/fcron
242 echo "Starting Snort (if enabled)"
243 /usr/local/bin/restartsnort red blue orange green
244 echo "Starting httpd"
245 /usr/sbin/httpd
246 echo "Starting dhcpd (if enabled)"
247 /usr/local/bin/restartdhcp
248 echo "Starting sshd (if enabled)"
249 /usr/local/bin/restartssh
250 echo "Starting ntpd (if enabled)"
251 /usr/local/bin/restartntpd
252
253 if [ -e "CONFIG_ROOT/proxy/squid.conf" ]; then
254 echo "Starting squid (if enabled)"
255 /usr/local/bin/restartsquid
256 fi
257
258 echo "Running rc.local"
259 . /etc/rc.d/rc.local
260
261 logger -t ipcop "IPCop started."
262
263 # Send nice startup beep now
264 /usr/bin/beep -l 75 -f 500
265 /usr/bin/beep -l 75 -f 1000
266 /usr/bin/beep -l 75 -f 2000
267 /usr/bin/beep -l 75 -f 3000