blob: 259958fe03352dab46bd1b70afed48b68a3f3614 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
#!/bin/sh
# $Id$
# /etc/rc - master bootup script, invokes php setup
# part of pfSense by Scott Ullrich
# Copyright (C) 2004 Scott Ullrich, All rights reserved.
# originally based on m0n0wall (http://neon1.net/m0n0wall)
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
# All rights reserved.
#/bin/stty status '^T'
#/bin/stty susp '^-' intr '^-' quit '^-'
#trap : 2
#trap : 3
HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
export HOME PATH
# Set our operating platform
PLATFORM=`cat /etc/platform`
# Set our current version
version=`cat /etc/version`
if [ "$PLATFORM" = "cdrom" ]; then
/etc/rc.cdrom
fi
if [ "$PLATFORM" = "embedded" ]; then
/etc/rc.embedded
fi
if [ "$PLATFORM" = "pfSense" ]; then
mdmfs -S -M -s 2m md /var/run
fi
product=`cat /etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
echo
cat /etc/ascii-art/pfsense-logo-small.txt
echo
echo
echo "Welcome to ${product} ${version} on the '${PLATFORM}' platform..."
echo
# Enable console output if its muted.
/sbin/conscontrol mute off >/dev/null
# Mount memory file system if it exists
echo -n "Mounting filesystems..."
/sbin/mount -a
# Mount /. If it fails run a fsck.
if [ ! "$PLATFORM" = "cdrom" ] ; then
/sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /)
# If /conf is a directory, convert it to a symlink
# to /cf/conf
if [ -d "/conf" ]; then
# If item is not a symlink then rm and recreate
CONFPOINTSTO=`readlink /conf`
if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then
rm -rf /conf
ln -s /cf/conf /conf
fi
fi
fi
# Check to see if a compact flash mountpoint exists
# If it fails to mount then run a fsck -fy
if grep -q cf /etc/fstab; then
/sbin/mount -uw /cf || \
(/sbin/umount /cf; /sbin/fsck -fy /cf; /sbin/mount -w /cf)
fi
if [ "$PLATFORM" = "cdrom" ] ; then
# do nothing for cdrom platform
elif [ "$PLATFORM" = "embedded" ] ; then
# do nothing for embedded platform
else
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
/sbin/swapon -a 2>/dev/null >/dev/null
fi
echo " done."
if [ "$PLATFORM" = "cdrom" ] ; then
mkdir /tmp/unionfs
mkdir /tmp/unionfs/usr
mkdir /tmp/unionfs/root
mkdir /tmp/unionfs/sbin
mkdir /tmp/unionfs/bin
mkdir /tmp/unionfs/boot
mkdir /tmp/unionfs/confdefault
echo -n "Mounting unionfs directories:"
echo -n " usr"
mount_unionfs /tmp/unionfs/usr /usr/
echo -n " root"
mount_unionfs /tmp/unionfs/root /root/
echo -n " bin"
mount_unionfs /tmp/unionfs/bin /bin/
echo -n " sbin"
mount_unionfs /tmp/unionfs/sbin /sbin/
echo -n " boot"
mount_unionfs /tmp/unionfs/boot /boot/
echo -n " conf.default"
mount_unionfs /tmp/unionfs/confdefault /conf.default/
echo "... done."
fi
echo -n "Creating symlinks..."
# Make sure symlink is correct on embedded
if [ "$PLATFORM" = "embedded" ] ; then
rm /conf
ln -s /cf/conf/ /conf
fi
# Repair symlinks if they are broken
if [ ! -L /etc/syslog.conf ]; then
rm -rf /etc/syslog.conf
ln -s /var/etc/syslog.conf /etc/syslog.conf
fi
# Repair symlinks if they are broken
if [ ! -L /etc/hosts ]; then
rm -rf /etc/hosts
ln -s /var/etc/hosts /etc/hosts
fi
if [ ! -L /etc/resolv.conf ]; then
rm -rf /etc/resolv.conf
ln -s /var/etc/resolv.conf /etc/resolv.conf
fi
# Setup compatibility link for packages that
# have trouble overriding the PREFIX configure
# argument since we build our packages in a
# seperated PREFIX area
# Only create if symlink does not exist.
if [ ! -h /tmp/tmp ]; then
ln -hfs / /tmp/tmp
fi
# Make sure our /tmp is 777 + Sticky
chmod 1777 /tmp
if [ ! "$PLATFORM" = "cdrom" ] ; then
# Malloc debugging check
if [ -L /etc/malloc.conf ]; then
#ln -s aj /etc/malloc.conf
rm /etc/malloc.conf
fi
fi
if [ ! -L /etc/dhclient.conf ]; then
rm -rf /etc/dhclient.conf
fi
if [ ! -L /etc/sasyncd.conf ]; then
mkdir -p /var/etc/
touch /var/etc/sasyncd.conf
rm -rf /etc/sasyncd.conf
ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
chown root:wheel /var/etc/sasyncd.conf
chmod 0600 /var/etc/sasyncd.conf
fi
if [ ! -d /var/tmp ]; then
mkdir -p /var/tmp
fi
if [ ! -d /cf/conf/backup/ ]; then
mkdir -p /cf/conf/backup/
fi
if [ ! -f /var/db/ez-ipupdate.cache ]; then
touch /var/db/ez-ipupdate.cache
fi
# OpenVPN storage
if [ ! -d /var/etc/openvpn ]; then
mkdir -p /var/etc/openvpn
fi
if [ ! -d /var/etc/openvpn-csc ]; then
mkdir -p /var/etc/openvpn-csc
fi
set -T
trap "echo 'Reboot interrupted'; exit 1" 3
# Remove old nameserver resolution files
rm -f /var/etc/nameserver*
# Create uploadbar tmp directory
mkdir -p /tmp/uploadbar
chmod 0777 /tmp/uploadbar
# make some directories in /var
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
rm /var/log/* 2>/dev/null
rm -rf /var/run/*
echo -n "."
DISABLESYSLOGCLOG=`cat /cf/conf/config.xml | grep disablesyslogclog | wc -l | awk '{ print $1 }'`
if [ "$DISABLESYSLOGCLOG" -gt "0" ]; then
touch /var/log/system.log
touch /var/log/filter.log
touch /var/log/dhcpd.log
touch /var/log/vpn.log
touch /var/log/openvpn.log
touch /var/log/portalauth.log
touch /var/log/ipsec.log
touch /var/log/relayd.log
touch /var/log/lighttpd.log
touch /var/log/ntpd.log
else
# generate circular logfiles
clog -i -s 512144 /var/log/system.log
clog -i -s 512144 /var/log/filter.log
clog -i -s 65535 /var/log/dhcpd.log
clog -i -s 65535 /var/log/vpn.log
clog -i -s 65535 /var/log/openvpn.log
clog -i -s 65535 /var/log/portalauth.log
clog -i -s 65535 /var/log/ipsec.log
clog -i -s 65535 /var/log/relayd.log
clog -i -s 65535 /var/log/lighttpd.log
clog -i -s 65535 /var/log/ntpd.log
fi
# change permissions on newly created clog files.
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log /var/log/relayd.log
echo -n "."
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
if [ "$DEVFS" = "0" ]; then
mount_devfs devfs /dev
fi
# Create an initial utmp file
cd /var/run && cp /dev/null utmp && chmod 644 utmp
echo -n "."
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
# Make sure /etc/rc.conf doesn't exist.
if [ -f /etc/rc.conf ]; then
rm -rf /etc/rc.conf
fi
# Launching kbdmux(4)
if [ -f "/dev/kbdmux0" ]; then
echo -n "."
kbdcontrol -k /dev/kbdmux0 < /dev/console
[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
fi
# Fire up unionfs if mount points exist.
if [ -f /dist/uniondirs ]; then
echo -n "."
/etc/rc.d/unionfs start
fi
echo "done."
# Recreate capabilities DB
cap_mkdb /etc/login.conf
if [ "$PLATFORM" != "cdrom" ]; then
# Populate a dummy php.ini to avoid
# the file being clobbered and the firewall
# not being able to boot back up.
cat >/usr/local/lib/php.ini <<EOF
# File generated from /etc/rc
output_buffering = "0"
expose_php = Off
implicit_flush = true
magic_quotes_gpc = Off
max_execution_time = 99999999
max_input_time = 99999999
register_argc_argv = On
file_uploads = On
upload_tmp_dir = /tmp
upload_max_filesize = 100M
post_max_size = 100M
html_errors = Off
zlib.output_compression = On
zlib.output_compression_level = 5
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
extension_dir=/usr/local/lib/php/20060613/
; add additional extensions below
; standard PHP extension
extension=pcre.so
extension=bz2.so
extension=bcmath.so
extension=ctype.so
extension=curl.so
extension=gettext.so
extension=mbstring.so
extension=mhash.so
;extension=openssl.so
extension=pcntl.so
extension=posix.so
extension=readline.so
extension=session.so
;extension=simplexml.so
extension=shmop.so
extension=sysvmsg.so
extension=sysvsem.so
extension=sysvshm.so
extension=tokenizer.so
extension=xml.so
extension=ldap.so
extension=zlib.so
; standard PHP extensions currently beeing unused
;extension=json.so
;extension=ncurses.so
;xmlreader.so
;xmlwriter.so
;[xdebug]
;xdebug.remote_enable = On
;xdebug.default_enable = On
;xdebug.remote_mode = On
;xdebug.remote_handler = dbgp
;xdebug.remote_host = 127.0.0.1
;xdebug.remote_port = 17869
;xdebug.idekey = devphp
EOF
RAM=`sysctl hw.realmem | awk '{print $2/1000000}' | awk -F '.' '{print $1}'`
export RAM
if [ $RAM -gt 96 ]; then
cat >>/usr/local/lib/php.ini <<EOF
extension=apc.so
apc.enabled="1"
apc.enable_cli="1"
apc.shm_size="25"
EOF
fi
fi
cp /usr/local/lib/php.ini /usr/local/etc/php.ini
rm -f /cf/conf/backup/backup.cache
# let the PHP-based configuration subsystem set up the system now
echo -n "Launching PHP init system..."
/etc/rc.bootup
echo -n "Starting CRON... "
cd /tmp && /usr/sbin/cron -s 2>/dev/null
echo "done."
# Start packages
/etc/rc.start_packages
rm -rf /usr/local/pkg/pf/CVS
/usr/local/bin/php -f /etc/rc.conf_mount_ro
# Remove stale files that have already been processed by bootup
# scripts
rm -f /tmp/filter_dirty
rm -f /tmp/rc.linkup
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status &
# Start ping handler for every 240 seconds
minicron 240 /var/run/ping_hosts.pid /usr/local/bin/ping_hosts.sh
chmod a+rw /tmp/.
echo "Bootup complete"
/usr/local/bin/beep.sh start 2>&1 >/dev/null
exit 0
|