]> git.ipfire.org Git - ipfire-2.x.git/blame - src/rc.d/rc.sysinit
GeƤndert:
[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
6eval $(/usr/local/bin/readhash CONFIG_ROOT/main/settings)
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"
156eval $(/usr/local/bin/readhash CONFIG_ROOT/main/settings)
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}
184rm -f CONFIG_ROOT/dhcpc/{*.pid,*.cache,*.info}
185rm -f CONFIG_ROOT/red/{active,eciadsl-synch-done}
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
196if [ -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
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
235if [ -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");'
238fi
239
240echo "Starting crond"
241/usr/sbin/fcron
242echo "Starting Snort (if enabled)"
243/usr/local/bin/restartsnort red blue orange green
244echo "Starting httpd"
245/usr/sbin/httpd
246echo "Starting dhcpd (if enabled)"
247/usr/local/bin/restartdhcp
248echo "Starting sshd (if enabled)"
249/usr/local/bin/restartssh
250echo "Starting ntpd (if enabled)"
251/usr/local/bin/restartntpd
252
253if [ -e "CONFIG_ROOT/proxy/squid.conf" ]; then
254 echo "Starting squid (if enabled)"
255 /usr/local/bin/restartsquid
256fi
257
258echo "Running rc.local"
259. /etc/rc.d/rc.local
260
5fcb6d5a 261logger -t ipfire "IPFire started."
cd1a2927
MT
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