]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/bin/sh |
2 | # | |
3 | # $Id: rc.sysinit,v 1.18.2.36 2005/12/01 20:13:08 eoberlander Exp $ | |
4 | # | |
5 | ||
986e08d9 | 6 | eval $(/usr/local/bin/readhash /var/ipfire/main/settings) |
cd1a2927 MT |
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" | |
986e08d9 | 156 | eval $(/usr/local/bin/readhash /var/ipfire/main/settings) |
cd1a2927 MT |
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} | |
986e08d9 MT |
184 | rm -f /var/ipfire/dhcpc/{*.pid,*.cache,*.info} |
185 | rm -f /var/ipfire/red/{active,eciadsl-synch-done} | |
cd1a2927 MT |
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 | ||
986e08d9 | 196 | if [ -x /usr/sbin/isapnp -a -f /var/ipfire/isapnp/isapnp.conf -a ! -f /proc/isapnp ]; then |
cd1a2927 | 197 | echo "Running isapnp" |
986e08d9 | 198 | /usr/sbin/isapnp /var/ipfire/isapnp/isapnp.conf 2>/dev/null |
cd1a2927 MT |
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 | ||
986e08d9 MT |
235 | echo 7200 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established |
236 | ||
904a41b9 MT |
237 | if [ -e /var/log/rrd/disk.rrd ]; then echo "Adjusting graphs to compensate for boot"; \ |
238 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk.rrd","-t","readsect:writesect","N:U:U");'; fi | |
239 | if [ -e /var/log/rrd/disk-hda.rrd ]; then \ | |
240 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hda.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
241 | if [ -e /var/log/rrd/disk-hdb.rrd ]; then \ | |
242 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdb.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
243 | if [ -e /var/log/rrd/disk-hdc.rrd ]; then \ | |
244 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdc.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
245 | if [ -e /var/log/rrd/disk-hdd.rrd ]; then \ | |
246 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdd.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
247 | if [ -e /var/log/rrd/disk-hde.rrd ]; then \ | |
248 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hde.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
249 | if [ -e /var/log/rrd/disk-hdf.rrd ]; then \ | |
250 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdf.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
251 | if [ -e /var/log/rrd/disk-hdg.rrd ]; then \ | |
252 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdg.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
253 | if [ -e /var/log/rrd/disk-hdh.rrd ]; then \ | |
254 | /usr/bin/perl -e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdh.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'; fi | |
255 | rm -rf /tmp/hddshutdown-* | |
256 | /usr/local/bin/hddshutdown | |
cd1a2927 MT |
257 | |
258 | echo "Starting crond" | |
259 | /usr/sbin/fcron | |
260 | echo "Starting Snort (if enabled)" | |
261 | /usr/local/bin/restartsnort red blue orange green | |
262 | echo "Starting httpd" | |
263 | /usr/sbin/httpd | |
264 | echo "Starting dhcpd (if enabled)" | |
265 | /usr/local/bin/restartdhcp | |
266 | echo "Starting sshd (if enabled)" | |
267 | /usr/local/bin/restartssh | |
268 | echo "Starting ntpd (if enabled)" | |
269 | /usr/local/bin/restartntpd | |
6e13d0a5 | 270 | echo "Starting openvpn (if enabled)" |
904a41b9 | 271 | /usr/local/bin/openvpnctrl --start-daemon-only >& /dev/null |
cd1a2927 | 272 | |
986e08d9 | 273 | if [ -e "/var/ipfire/proxy/squid.conf" ]; then |
cd1a2927 MT |
274 | echo "Starting squid (if enabled)" |
275 | /usr/local/bin/restartsquid | |
276 | fi | |
277 | ||
278 | echo "Running rc.local" | |
279 | . /etc/rc.d/rc.local | |
280 | ||
5fcb6d5a | 281 | logger -t ipfire "IPFire started." |
cd1a2927 MT |
282 | |
283 | # Send nice startup beep now | |
284 | /usr/bin/beep -l 75 -f 500 | |
285 | /usr/bin/beep -l 75 -f 1000 | |
286 | /usr/bin/beep -l 75 -f 2000 | |
287 | /usr/bin/beep -l 75 -f 3000 |