3 # $Id: rc.sysinit,v 1.18.2.36 2005/12/01 20:13:08 eoberlander Exp $
6 eval $
(/usr
/local
/bin
/readhash CONFIG_ROOT
/main
/settings
)
10 PATH
=/bin
:/sbin
:/usr
/bin
:/usr
/sbin
13 echo "Mounting /proc filesystem"
14 mount
-n -t proc
/proc
/proc
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
22 echo "Setting hostname"
23 if [ -z "$DOMAINNAME" ]; then
26 hostname
${HOSTNAME}.
${DOMAINNAME}
29 if [ "$KEYMAP" != "" ]; then
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
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
49 mount
-n -t usbdevfs usbdevfs
/proc
/bus
/usb
50 for alias in $aliases ; do
51 [ "$alias" != "off" ] && modprobe
$alias
54 echo "Initializing USB storage devices"
58 echo "Initializing USB keyboard"
62 echo "Initializing USB modems"
66 STRING
="Checking root filesystem"
71 if [ "$RC" = "0" ]; then
72 echo "$STRING: Success"
73 elif [ "$RC" = "1" ]; then
74 echo "$STRING: Passed"
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) \# # "
85 echo "Unmounting filesystems"
87 mount
-n -o remount
,ro
/
88 echo "Automatic reboot in progress."
92 echo "Mounting root read/write"
93 mount
-n -o remount
,rw
/
95 STRING
="Checking other filesystems"
99 if [ "$RC" = "0" ]; then
100 echo "$STRING: Success"
101 elif [ "$RC" = "1" ]; then
102 echo "$STRING: Passed"
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) \# # "
113 echo "Unmounting filesystems"
115 mount
-n -o remount
,ro
/
116 echo "Automatic reboot in progress."
120 echo "Mounting other filesystems"
123 if [ -e /swapfile
]; then
124 echo "Turning on swap"
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
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
138 echo "Updating /etc/fstab to reflect removable devices"
141 echo "Setting kernel settings"
142 /sbin
/sysctl
-e -p /etc
/sysctl.conf
>/dev
/null
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
151 echo "Setting locale"
155 echo "Setting consolefonts"
156 eval $
(/usr
/local
/bin
/readhash CONFIG_ROOT
/main
/settings
)
157 for i
in 2 3 4 5 6; do
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
171 /usr
/bin
/unicode_start lat0-16
174 echo "Update modules dependencies when necessary"
175 if [ -e /var
/run
/need-depmod-
`uname -r` ]; then
177 /bin
/rm -f /var
/run
/need-depmod-
`uname -r`
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
}
187 echo "Setting the clock"
188 /sbin
/hwclock --hctosys
190 # Cleaning up wtmp/utmp files
193 chgrp utmp
/var
/run
/utmp
/var
/log
/wtmp
194 chmod 0664 /var
/run
/utmp
/var
/log
/wtmp
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
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 ""
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 ""
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 ""
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
218 /usr
/local
/bin
/httpscert new
222 /usr
/sbin
/logrotate
/etc
/logrotate.conf
224 echo "Starting syslogd"
225 /usr
/sbin
/syslogd
-m 0
226 echo "Starting klogd"
227 /usr
/sbin
/klogd
-u klogd
-j /var
/empty
229 echo "Running /etc/rc.d/rc.network"
230 .
/etc
/rc.d
/rc.network
232 echo "Dumping boot messages"
233 dmesg
> /var
/log
/dmesg
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");'
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");'
242 if [ -e /var
/log
/rrd
/disk-hdb.rrd
]; then
243 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdb.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
245 if [ -e /var
/log
/rrd
/disk-hdc.rrd
]; then
246 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdc.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
248 if [ -e /var
/log
/rrd
/disk-hdd.rrd
]; then
249 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdd.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
251 if [ -e /var
/log
/rrd
/disk-hde.rrd
]; then
252 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hde.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
254 if [ -e /var
/log
/rrd
/disk-hdf.rrd
]; then
255 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdf.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
257 if [ -e /var
/log
/rrd
/disk-hdg.rrd
]; then
258 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdg.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
260 if [ -e /var
/log
/rrd
/disk-hdh.rrd
]; then
261 /usr
/bin
/perl
-e 'use RRDs;RRDs::update("/var/log/rrd/disk-hdh.rrd","-t","readsect:writesect:sleeping","N:U:U:U");'
263 if [ -e /tmp
/hddshutdown-stat
] ; then
264 rm /tmp
/hddshutdown-
*"
266 /usr/local/bin/hddshutdown
268 echo "Starting crond
"
270 echo "Starting Snort
(if enabled
)"
271 /usr/local/bin/restartsnort red blue orange green
272 echo "Starting httpd
"
274 echo "Starting dhcpd
(if enabled
)"
275 /usr/local/bin/restartdhcp
276 echo "Starting sshd
(if enabled
)"
277 /usr/local/bin/restartssh
278 echo "Starting ntpd
(if enabled
)"
279 /usr/local/bin/restartntpd
280 echo "Starting openvpn
(if enabled
)"
281 /usr/local/bin/openvpnctrl --start-daemon-only
283 if [ -e "CONFIG_ROOT
/proxy
/squid.conf
" ]; then
284 echo "Starting squid
(if enabled
)"
285 /usr/local/bin/restartsquid
288 echo "Running rc.
local"
291 logger -t ipfire "IPFire started.
"
293 # Send nice startup beep now
294 /usr/bin/beep -l 75 -f 500
295 /usr/bin/beep -l 75 -f 1000
296 /usr/bin/beep -l 75 -f 2000
297 /usr/bin/beep -l 75 -f 3000