Project

General

Profile

Download (6.57 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/bin/sh
2
3 e5cd29a0 Scott Ullrich
# /etc/rc - master bootup script, invokes php setup
4
# part of pfSense by Scott Ullrich
5
# Copyright (C) 2004 Scott Ullrich, All rights reserved.
6
# originally based on m0n0wall (http://neon1.net/m0n0wall)
7 5b237745 Scott Ullrich
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
# All rights reserved.
9 d8a2ce2c Scott Ullrich
10
#/bin/stty status '^T'
11
#/bin/stty susp '^-' intr '^-' quit '^-'
12
13
#trap : 2
14
#trap : 3
15 5b237745 Scott Ullrich
16 31849b90 Scott Ullrich
# Set our operating platform
17
PLATFORM=`cat /etc/platform`
18 c0819d14 Jeb Campbell
19 5b237745 Scott Ullrich
HOME=/
20 ce823053 Scott Ullrich
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
21 5b237745 Scott Ullrich
export HOME PATH
22
23 d4556e07 Scott Ullrich
# Set our current version
24 3f38f066 Scott Ullrich
version=`cat /etc/version`
25
26 e5cd29a0 Scott Ullrich
echo
27 25d3fbd5 Scott Ullrich
cat /etc/ascii-art/pfsense-logo-small.txt
28
echo
29 d67c6097 Scott Ullrich
echo
30
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
31
echo
32 e5cd29a0 Scott Ullrich
33 31540677 Colin Smith
if [ "$PLATFORM" = "cdrom" ]; then
34
	/etc/rc.cdrom
35
fi
36
37 16469df3 Scott Ullrich
if [ "$PLATFORM" = "embedded" ]; then
38 c613b74f Scott Ullrich
	/etc/rc.embedded
39
fi
40
41 c1688281 Seth Mos
if [ "$PLATFORM" = "pfSense" ]; then
42
	mdmfs -S -M -s 2m md /var/run
43
fi
44
45 d5f60dba Scott Ullrich
# Enable console output if its muted.
46
/sbin/conscontrol mute off >/dev/null
47
48 16469df3 Scott Ullrich
# Mount memory file system if it exists
49 ebe6a739 Scott Ullrich
echo -n "Mounting filesystems..."
50 16469df3 Scott Ullrich
/sbin/mount -a
51
52 3311566f Scott Ullrich
# Mount /. If it fails run a fsck.
53 625dda09 Scott Ullrich
if [ ! "$PLATFORM" = "cdrom" ] ; then
54 581daddc Scott Ullrich
	/sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /)
55 fac17748 Scott Ullrich
56
	# If /conf is a directory, convert it to a symlink
57
	# to /cf/conf
58
	if [ -d "/conf" ]; then
59
		rm -rf /conf
60
		ln -s /cf/conf /conf
61
	fi
62 625dda09 Scott Ullrich
fi
63 fe1936d1 Scott Ullrich
64 3311566f Scott Ullrich
# Check to see if a compact flash mountpoint exists
65 581daddc Scott Ullrich
# If it fails to mount then run a fsck -fy
66 16469df3 Scott Ullrich
if grep -q cf /etc/fstab; then
67 faaa6942 Scott Ullrich
    /sbin/mount -uw /cf || \
68 581daddc Scott Ullrich
	(/sbin/umount /cf; /sbin/fsck -fy /cf; /sbin/mount -w /cf)
69 16125d1c Scott Ullrich
fi
70
71 5621d2d5 Scott Ullrich
if [ "$PLATFORM" = "cdrom" ] ; then
72
	# do nothing for cdrom platform
73
elif [ "$PLATFORM" = "embedded" ] ; then
74 f92e9ff3 Scott Ullrich
    # do nothing for embedded platform
75 c0819d14 Jeb Campbell
else
76 d8a2ce2c Scott Ullrich
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
77 7050e57c Scott Ullrich
    /sbin/swapon -a 2>/dev/null >/dev/null
78 98546a74 Scott Ullrich
fi
79 ebe6a739 Scott Ullrich
echo " done."
80 5621d2d5 Scott Ullrich
81 2e269da2 Scott Ullrich
echo -n "Creating symlinks..."
82 895ecb35 Scott Ullrich
# Make sure symlink is correct on embedded
83
if [ "$PLATFORM" = "embedded" ] ; then
84
	rm /conf
85 4e7b2b27 Scott Ullrich
	ln -s /cf/conf/ /conf
86 895ecb35 Scott Ullrich
fi
87
88 6bab150e Scott Ullrich
# Repair symlinks if they are broken
89
if [ ! -L /etc/syslog.conf ]; then
90
	rm -rf /etc/syslog.conf
91
	ln -s /var/etc/syslog.conf /etc/syslog.conf
92
fi
93
94 f1cc2287 Scott Ullrich
# Repair symlinks if they are broken
95
if [ ! -L /etc/hosts ]; then
96
	rm -rf /etc/hosts
97 4e7b2b27 Scott Ullrich
	ln -s /var/etc/hosts /etc/hosts
98 c8fcdb2f Scott Ullrich
fi
99 095d04db Scott Ullrich
100 f1cc2287 Scott Ullrich
if [ ! -L /etc/resolv.conf ]; then
101
    rm -rf /etc/resolv.conf
102 4e7b2b27 Scott Ullrich
    ln -s /var/etc/resolv.conf /etc/resolv.conf
103 f1cc2287 Scott Ullrich
fi
104 095d04db Scott Ullrich
105 652f9fa1 Scott Ullrich
# Setup compatibility link for packages that
106
# have trouble overriding the PREFIX configure
107
# argument since we build our packages in a
108
# seperated PREFIX area
109 4bc3ea93 Scott Ullrich
ln -s / /tmp/tmp
110 652f9fa1 Scott Ullrich
111 cecdf31c Scott Ullrich
# Malloc debugging check
112
if [ ! -L /etc/malloc.conf ]; then
113
    ln -s aj /etc/malloc.conf
114
fi
115
116 6484bb83 Scott Ullrich
if [ ! -L /etc/dhclient.conf ]; then
117
    rm -rf /etc/dhclient.conf
118
fi
119 c8fcdb2f Scott Ullrich
120 bfe6d078 Scott Ullrich
if [ ! -L /etc/sasyncd.conf ]; then
121 b8c835d2 Scott Ullrich
    mkdir -p /var/etc/
122 bfe6d078 Scott Ullrich
    touch /var/etc/sasyncd.conf
123
    rm -rf /etc/sasyncd.conf
124
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
125 84f68d65 Scott Ullrich
    chown root:wheel /var/etc/sasyncd.conf
126 bfe6d078 Scott Ullrich
    chmod 0600 /var/etc/sasyncd.conf
127
fi
128
129 4aa70cd8 Scott Ullrich
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
130
131 69588d92 Scott Ullrich
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
132 d42c2e20 Scott Ullrich
133 09c2529d Scott Ullrich
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
134
135 5b237745 Scott Ullrich
set -T
136
trap "echo 'Reboot interrupted'; exit 1" 3
137
138 61f1e2ec Scott Ullrich
# Remove old nameserver resolution files
139
rm -f /var/etc/nameserver*
140
141 f3677fc5 Scott Ullrich
# Create uploadbar tmp directory
142 e15f2001 Scott Ullrich
mkdir -p /tmp/uploadbar
143 f3677fc5 Scott Ullrich
chmod 777 /tmp/uploadbar
144
145 5b237745 Scott Ullrich
# make some directories in /var
146 102d8912 Scott Ullrich
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
147 ab230731 Scott Ullrich
rm /var/log/* 2>/dev/null
148 9cb8e6f0 Scott Ullrich
rm -rf /var/run/*
149 5b237745 Scott Ullrich
150 2e269da2 Scott Ullrich
echo -n "."
151 5b237745 Scott Ullrich
# generate circular logfiles
152 a7fcb832 Scott Ullrich
if [ ! "$PLATFORM" = "cdrom" ]; then
153 1d05769d Scott Ullrich
	clog -i -s 512144 /var/log/system.log
154 d42d2184 Scott Ullrich
	clog -i -s 512144 /var/log/filter.log
155 1d05769d Scott Ullrich
	clog -i -s 65535 /var/log/dhcpd.log
156
	clog -i -s 65535 /var/log/vpn.log
157
	clog -i -s 65535 /var/log/openvpn.log
158
	clog -i -s 65535 /var/log/portalauth.log
159
	clog -i -s 65535 /var/log/ipsec.log
160
	clog -i -s 65535 /var/log/slbd.log
161
	clog -i -s 65535 /var/log/lighttpd.log
162 18330d38 Scott Ullrich
	clog -i -s 65535 /var/log/ntpd.log
163 13c24013 Scott Ullrich
else
164
    clog -i -s 65535 /var/log/system.log
165
    clog -i -s 65535 /var/log/filter.log
166
    clog -i -s 65535 /var/log/dhcpd.log
167
    clog -i -s 65535 /var/log/vpn.log
168
	clog -i -s 65535 /var/log/openvpn.log
169
    clog -i -s 65535 /var/log/portalauth.log
170
    clog -i -s 65535 /var/log/ipsec.log
171
    clog -i -s 65535 /var/log/slbd.log
172 18330d38 Scott Ullrich
	clog -i -s 65535 /var/log/ntpd.log
173 a7fcb832 Scott Ullrich
fi
174 8d418ca9 Scott Ullrich
175
# change permissions on newly created clog files.
176 95a52053 Bill Marquette
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log /var/log/slbd.log
177 5b237745 Scott Ullrich
178 2e269da2 Scott Ullrich
echo -n "."
179 f93c5384 Scott Ullrich
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
180
if [ "$DEVFS" = "0" ]; then
181
    mount_devfs devfs /dev
182
fi
183 5b237745 Scott Ullrich
184
# Create an initial utmp file
185
cd /var/run && cp /dev/null utmp && chmod 644 utmp
186
187 2e269da2 Scott Ullrich
echo -n "."
188 6fe4f291 Scott Ullrich
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
189 c268f10f Scott Ullrich
190 cdbc61b6 Scott Ullrich
# Make sure /etc/rc.conf doesn't exist.
191
if [ -f /etc/rc.conf ]; then
192
    rm -rf /etc/rc.conf
193
fi
194
195 b1ce7649 Scott Ullrich
# Launching kbdmux(4)
196
if [ -f "/dev/kbdmux0" ]; then
197 2e269da2 Scott Ullrich
	echo -n "."
198 b1ce7649 Scott Ullrich
	kbdcontrol -k /dev/kbdmux0 < /dev/console
199
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
200 4e7b2b27 Scott Ullrich
	[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
201
fi
202
203
# Fire up unionfs if mount points exist.
204
if [ -f /dist/uniondirs ]; then
205 2e269da2 Scott Ullrich
	echo -n "."
206 4e7b2b27 Scott Ullrich
	/etc/rc.d/unionfs start
207 b1ce7649 Scott Ullrich
fi
208 fa8f44ce Scott Ullrich
209 2e269da2 Scott Ullrich
echo "done."
210 deff30cd Scott Ullrich
211 ad0d7518 Scott Ullrich
# Recreate capabilities DB
212
cap_mkdb /etc/login.conf
213
214 6a63742f Scott Ullrich
if [ "$PLATFORM" != "cdrom" ]; then
215
# Populate a dummy php.ini to avoid
216
# the file being clobbered and the firewall
217
# not being able to boot back up.
218
cat >/usr/local/lib/php.ini <<EOF
219
output_buffering = "0"
220
implicit_flush = true
221
magic_quotes_gpc = Off
222
max_execution_time = 99999999
223
max_input_time = 99999999
224
register_argc_argv = Off
225
file_uploads = On
226
upload_tmp_dir = /tmp
227
upload_max_filesize = 90M
228
post_max_size = 90M
229
html_errors = Off
230
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
231
apc.enabled="1"
232
apc.enable_cli="1"
233
apc.shm_size="30"
234
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/
235
extension=apc.so
236
extension=radius.so
237
238
EOF
239
fi
240
241 136fc45a Scott Ullrich
rm -f /cf/conf/backup/backup.cache
242
243 b406ae66 Scott Ullrich
# let the PHP-based configuration subsystem set up the system now
244 d0e94aaf Scott Ullrich
echo -n "Launching PHP init system..."
245 b406ae66 Scott Ullrich
/etc/rc.bootup
246
247 0c5e431d Scott Ullrich
echo -n "Starting CRON... "
248 ea83ac64 Scott Ullrich
cd /tmp && /usr/sbin/cron -s 2>/dev/null
249 0c5e431d Scott Ullrich
echo "done."
250 3e08b3c1 Scott Ullrich
251 5be5825e Scott Ullrich
# Start packages
252
/etc/rc.start_packages
253 3bd1bd72 Scott Ullrich
254 58eba990 Scott Ullrich
rm -rf /usr/local/pkg/pf/CVS
255
256 7b2ac828 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_ro
257 f92eaec2 Scott Ullrich
258 d9f8db28 Scott Ullrich
# Remove stale files that have already been processed by bootup
259
# scripts
260 db54bc25 Scott Ullrich
rm -f /tmp/filter_dirty
261 6374d041 Scott Ullrich
rm -f /tmp/rc.linkup
262 23d38998 Scott Ullrich
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null
263 bc086d51 Scott Ullrich
264 f2025e91 Scott Ullrich
# Start ping handler for every 240 seconds
265
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
266
267 e393a4a8 Scott Ullrich
echo "Bootup complete"
268 1ba9533c Scott Ullrich
269 2d4be1c5 Scott Ullrich
/usr/local/bin/beep.sh start 2>&1 >/dev/null
270 e393a4a8 Scott Ullrich
271 d35cf0de Scott Ullrich
exit 0