]> git.ipfire.org Git - ipfire-2.x.git/blame - src/rc.d/rc.sysinit
HinzugefĆ¼gt:
[ipfire-2.x.git] / src / rc.d / rc.sysinit
CommitLineData
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 6eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
cd1a2927
MT
7
8umask 022
9
10PATH=/bin:/sbin:/usr/bin:/usr/sbin
11export PATH
12
13echo "Mounting /proc filesystem"
14mount -n -t proc /proc /proc
15
16# Unmount the initrd, if necessary
17if 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
20fi
21
22echo "Setting hostname"
23if [ -z "$DOMAINNAME" ]; then
24 hostname $HOSTNAME
25else
26 hostname ${HOSTNAME}.${DOMAINNAME}
27fi
28
29if [ "$KEYMAP" != "" ]; then
30 loadkeys $KEYMAP
31fi
32
33# Initializing Power Management ACPI first, then APM.
34# APM won't load if ACPI is initialized anyway.
35echo "Initializing Power Management"
36modprobe ac > /dev/null 2>&1
37modprobe battery > /dev/null 2>&1
38modprobe button > /dev/null 2>&1
39modprobe fan > /dev/null 2>&1
40modprobe processor > /dev/null 2>&1
41modprobe thermal > /dev/null 2>&1
42modprobe apm > /dev/null 2>&1
43
44# Initialize USB controllers
45echo "Initializing USB controllers"
46aliases=`/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }'`
47if [ -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
64fi
65
66STRING="Checking root filesystem"
67
68fsck -R -T -a -C /
69RC=$?
70
71if [ "$RC" = "0" ]; then
72 echo "$STRING: Success"
73elif [ "$RC" = "1" ]; then
74 echo "$STRING: Passed"
75fi
76
77# A return of 2 or higher means there were serious problems.
78if [ $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
90fi
91
92echo "Mounting root read/write"
93mount -n -o remount,rw /
94
95STRING="Checking other filesystems"
96fsck -R -T -a -C -A
97RC=$?
98
99if [ "$RC" = "0" ]; then
100 echo "$STRING: Success"
101elif [ "$RC" = "1" ]; then
102 echo "$STRING: Passed"
103fi
104
105# A return of 2 or higher means there were serious problems.
106if [ $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
118fi
119
120echo "Mounting other filesystems"
121mount -a -n
122
123if [ -e /swapfile ]; then
124 echo "Turning on swap"
125 chmod 600 /swapfile
126 swapon /swapfile
127fi
128
129echo "Updating System.map file location"
130if [ -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
133fi
134if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ]; then
135 ln -s -f System.map-`uname -r` /boot/System.map
136fi
137
138echo "Updating /etc/fstab to reflect removable devices"
139/usr/sbin/updfstab
140
141echo "Setting kernel settings"
142/sbin/sysctl -e -p /etc/sysctl.conf >/dev/null
143
144if [ -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
149fi
150
151echo "Setting locale"
152LANG=en_US.utf8
153export LANG
154
155echo "Setting consolefonts"
986e08d9 156eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
cd1a2927
MT
157for i in 2 3 4 5 6; do
158 > /dev/tty$i
159done
160if [ "$LANGUAGE" = "el" ]; then
161 /usr/bin/unicode_start iso07u-16
162elif [ "$LANGUAGE" = "pt" -o "$LANGUAGE" = "bz" ]; then
163 /usr/bin/unicode_start lat1-16
164elif [ "$LANGUAGE" = "cs" -o "$LANGUAGE" = "hu" -o "$LANGUAGE" = "pl" -o "$LANGUAGE" = "sk" ]; then
165 /usr/bin/unicode_start lat2-16
166elif [ "$LANGUAGE" = "tr" ]; then
167 /usr/bin/unicode_start lat5-16
168elif [ "$LANGUAGE" = "vi" ]; then
169 /usr/bin/unicode_start viscii10-8x16
170else
171 /usr/bin/unicode_start lat0-16
172fi
173
174echo "Update modules dependencies when necessary"
175if [ -e /var/run/need-depmod-`uname -r` ]; then
176 /sbin/depmod -a
177 /bin/rm -f /var/run/need-depmod-`uname -r`
178fi
179
180echo "Clearing old files"
181rm -f /var/run/{*.pid,*.sem,*.tdb}
182rm -f /var/run/dhcpcd-*.pid
183rm -f /var/lock/{LCK..tty*,rc.updatered.lock}
986e08d9
MT
184rm -f /var/ipfire/dhcpc/{*.pid,*.cache,*.info}
185rm -f /var/ipfire/red/{active,eciadsl-synch-done}
cd1a2927
MT
186
187echo "Setting the clock"
188/sbin/hwclock --hctosys
189
190# Cleaning up wtmp/utmp files
191>/var/run/utmp
192touch /var/log/wtmp
193chgrp utmp /var/run/utmp /var/log/wtmp
194chmod 0664 /var/run/utmp /var/log/wtmp
195
986e08d9 196if [ -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
199fi
200
201if [ ! -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 ""
204fi
205if [ ! -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 ""
208fi
209if [ ! -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 ""
212fi
213
214# https certificate
215if [ -f /etc/httpd/server.key -a -f /etc/httpd/server.crt -a -f /etc/httpd/server.csr ]; then
216 /usr/local/bin/httpscert read
217else
218 /usr/local/bin/httpscert new
219fi
220
221echo "Rotating logs"
222/usr/sbin/logrotate /etc/logrotate.conf
223
224echo "Starting syslogd"
225/usr/sbin/syslogd -m 0
226echo "Starting klogd"
227/usr/sbin/klogd -u klogd -j /var/empty
228
229echo "Running /etc/rc.d/rc.network"
230. /etc/rc.d/rc.network
231
232echo "Dumping boot messages"
233dmesg > /var/log/dmesg
234
986e08d9
MT
235echo 7200 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established
236
904a41b9
MT
237if [ -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
239if [ -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
241if [ -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
243if [ -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
245if [ -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
247if [ -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
249if [ -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
251if [ -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
253if [ -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
255rm -rf /tmp/hddshutdown-*
256/usr/local/bin/hddshutdown
cd1a2927
MT
257
258echo "Starting crond"
259/usr/sbin/fcron
260echo "Starting Snort (if enabled)"
261/usr/local/bin/restartsnort red blue orange green
262echo "Starting httpd"
263/usr/sbin/httpd
264echo "Starting dhcpd (if enabled)"
265/usr/local/bin/restartdhcp
266echo "Starting sshd (if enabled)"
267/usr/local/bin/restartssh
268echo "Starting ntpd (if enabled)"
269/usr/local/bin/restartntpd
6e13d0a5 270echo "Starting openvpn (if enabled)"
904a41b9 271/usr/local/bin/openvpnctrl --start-daemon-only >& /dev/null
cd1a2927 272
986e08d9 273if [ -e "/var/ipfire/proxy/squid.conf" ]; then
cd1a2927
MT
274 echo "Starting squid (if enabled)"
275 /usr/local/bin/restartsquid
276fi
277
278echo "Running rc.local"
279. /etc/rc.d/rc.local
280
5fcb6d5a 281logger -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