Project

General

Profile

Download (7.63 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
# /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
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
# All rights reserved.
9

    
10
#/bin/stty status '^T'
11
#/bin/stty susp '^-' intr '^-' quit '^-'
12

    
13
#trap : 2
14
#trap : 3
15

    
16
# Set our operating platform
17
PLATFORM=`cat /etc/platform`
18

    
19
HOME=/
20
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
21
export HOME PATH
22

    
23
# Set our current version
24
version=`cat /etc/version`
25

    
26
echo
27
cat /etc/ascii-art/pfsense-logo-small.txt
28
echo
29
echo
30
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
31
echo
32

    
33
if [ "$PLATFORM" = "cdrom" ]; then
34
	/etc/rc.cdrom
35
fi
36

    
37
if [ "$PLATFORM" = "embedded" ]; then
38
	/etc/rc.embedded
39
fi
40

    
41
if [ "$PLATFORM" = "pfSense" ]; then
42
	mdmfs -S -M -s 2m md /var/run
43
fi
44

    
45
# Enable console output if its muted.
46
/sbin/conscontrol mute off >/dev/null
47

    
48
# Mount memory file system if it exists
49
echo -n "Mounting filesystems..."
50
/sbin/mount -a
51

    
52
# Mount /. If it fails run a fsck.
53
if [ ! "$PLATFORM" = "cdrom" ] ; then
54
	/sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /)
55

    
56
	# If /conf is a directory, convert it to a symlink
57
	# to /cf/conf
58
	if [ -d "/conf" ]; then
59
		# If item is not a symlink then rm and recreate
60
		CONFPOINTSTO=`readlink /conf` 
61
		if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then 
62
			rm -rf /conf
63
			ln -s /cf/conf /conf
64
		fi
65
	fi
66
fi
67

    
68
# Check to see if a compact flash mountpoint exists
69
# If it fails to mount then run a fsck -fy
70
if grep -q cf /etc/fstab; then
71
    /sbin/mount -uw /cf || \
72
	(/sbin/umount /cf; /sbin/fsck -fy /cf; /sbin/mount -w /cf)
73
fi
74

    
75
if [ "$PLATFORM" = "cdrom" ] ; then
76
	# do nothing for cdrom platform
77
elif [ "$PLATFORM" = "embedded" ] ; then
78
    # do nothing for embedded platform
79
else
80
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
81
    /sbin/swapon -a 2>/dev/null >/dev/null
82
fi
83
echo " done."
84

    
85
echo -n "Creating symlinks..."
86
# Make sure symlink is correct on embedded
87
if [ "$PLATFORM" = "embedded" ] ; then
88
	rm /conf
89
	ln -s /cf/conf/ /conf
90
fi
91

    
92
# Repair symlinks if they are broken
93
if [ ! -L /etc/syslog.conf ]; then
94
	rm -rf /etc/syslog.conf
95
	ln -s /var/etc/syslog.conf /etc/syslog.conf
96
fi
97

    
98
# Repair symlinks if they are broken
99
if [ ! -L /etc/hosts ]; then
100
	rm -rf /etc/hosts
101
	ln -s /var/etc/hosts /etc/hosts
102
fi
103

    
104
if [ ! -L /etc/resolv.conf ]; then
105
    rm -rf /etc/resolv.conf
106
    ln -s /var/etc/resolv.conf /etc/resolv.conf
107
fi
108

    
109
# Setup compatibility link for packages that
110
# have trouble overriding the PREFIX configure
111
# argument since we build our packages in a
112
# seperated PREFIX area
113
# Only create if symlink does not exist. 
114
if [ ! -h /tmp/tmp ]; then
115
    ln -hfs / /tmp/tmp
116
fi
117

    
118
# Malloc debugging check
119
if [ ! -L /etc/malloc.conf ]; then
120
    ln -s aj /etc/malloc.conf
121
fi
122

    
123
if [ ! -L /etc/dhclient.conf ]; then
124
    rm -rf /etc/dhclient.conf
125
fi
126

    
127
if [ ! -L /etc/sasyncd.conf ]; then
128
    mkdir -p /var/etc/
129
    touch /var/etc/sasyncd.conf
130
    rm -rf /etc/sasyncd.conf
131
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
132
    chown root:wheel /var/etc/sasyncd.conf
133
    chmod 0600 /var/etc/sasyncd.conf
134
fi
135

    
136
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
137

    
138
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
139

    
140
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
141

    
142
set -T
143
trap "echo 'Reboot interrupted'; exit 1" 3
144

    
145
# Remove old nameserver resolution files
146
rm -f /var/etc/nameserver*
147

    
148
# Create uploadbar tmp directory
149
mkdir -p /tmp/uploadbar
150
chmod 777 /tmp/uploadbar
151

    
152
# make some directories in /var
153
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
154
rm /var/log/* 2>/dev/null
155
rm -rf /var/run/*
156

    
157
echo -n "."
158
DISABLESYSLOGCLOG=`cat /cf/conf/config.xml | grep disablesyslogclog | wc -l | awk '{ print $1 }'`
159
if [ ! "$PLATFORM" = "cdrom" ]; then
160
	if [ "$DISABLESYSLOGCLOG" -gt "0" ]; then 
161
		touch /var/log/system.log
162
		touch /var/log/filter.log
163
		touch /var/log/dhcpd.log
164
		touch /var/log/vpn.log
165
		touch /var/log/openvpn.log
166
		touch /var/log/portalauth.log
167
		touch /var/log/ipsec.log
168
		touch /var/log/slbd.log
169
		touch /var/log/lighttpd.log
170
		touch /var/log/ntpd.log
171
	else 
172
		# generate circular logfiles
173
		clog -i -s 512144 /var/log/system.log
174
		clog -i -s 512144 /var/log/filter.log
175
		clog -i -s 65535 /var/log/dhcpd.log
176
		clog -i -s 65535 /var/log/vpn.log
177
		clog -i -s 65535 /var/log/openvpn.log
178
		clog -i -s 65535 /var/log/portalauth.log
179
		clog -i -s 65535 /var/log/ipsec.log
180
		clog -i -s 65535 /var/log/slbd.log
181
		clog -i -s 65535 /var/log/lighttpd.log
182
		clog -i -s 65535 /var/log/ntpd.log
183
	fi 
184
fi
185

    
186
# change permissions on newly created clog files.
187
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
188

    
189
echo -n "."
190
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
191
if [ "$DEVFS" = "0" ]; then
192
    mount_devfs devfs /dev
193
fi
194

    
195
# Create an initial utmp file
196
cd /var/run && cp /dev/null utmp && chmod 644 utmp
197

    
198
echo -n "."
199
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
200

    
201
# Make sure /etc/rc.conf doesn't exist.
202
if [ -f /etc/rc.conf ]; then
203
    rm -rf /etc/rc.conf
204
fi
205

    
206
# Launching kbdmux(4)
207
if [ -f "/dev/kbdmux0" ]; then
208
	echo -n "."
209
	kbdcontrol -k /dev/kbdmux0 < /dev/console
210
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
211
	[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
212
fi
213

    
214
# Fire up unionfs if mount points exist.
215
if [ -f /dist/uniondirs ]; then
216
	echo -n "."
217
	/etc/rc.d/unionfs start
218
fi
219

    
220
echo "done."
221

    
222
# Recreate capabilities DB
223
cap_mkdb /etc/login.conf
224

    
225
if [ "$PLATFORM" != "cdrom" ]; then
226
	# Populate a dummy php.ini to avoid
227
	# the file being clobbered and the firewall
228
	# not being able to boot back up.
229
	cat >/usr/local/lib/php.ini <<EOF
230
output_buffering = "0"
231
implicit_flush = true
232
magic_quotes_gpc = Off
233
max_execution_time = 99999999
234
max_input_time = 99999999
235
register_argc_argv = On
236
file_uploads = On
237
upload_tmp_dir = /tmp
238
upload_max_filesize = 100M
239
post_max_size = 100M
240
html_errors = Off
241
zlib.output_compression = On
242
zlib.output_compression_level = 5
243
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
244

    
245
; add additional extensions below
246
; standard PHP extension
247
extension=apc.so
248
extension=pcre.so
249
extension=bz2.so
250
extension=bcmath.so
251
extension=ctype.so
252
extension=curl.so
253
extension=gettext.so
254
extension=mbstring.so
255
extension=pcntl.so
256
extension=posix.so
257
extension=readline.so
258
extension=session.so
259
extension=shmop.so
260
extension=sysvmsg.so
261
extension=sysvsem.so
262
extension=sysvshm.so
263
extension=tokenizer.so
264
extension=xml.so
265
extension=ldap.so
266
extension=zlib.so
267

    
268
; standard PHP extensions currently beeing unused
269
;extension=json.so
270
;extension=ncurses.so
271
;xmlreader.so
272
;xmlwriter.so
273

    
274
;[xdebug]
275
;xdebug.remote_enable = On
276
;xdebug.default_enable = On
277
;xdebug.remote_mode = On
278
;xdebug.remote_handler = dbgp
279
;xdebug.remote_host = 127.0.0.1
280
;xdebug.remote_port = 17869
281
;xdebug.idekey = devphp
282

    
283
apc.enabled="1"
284
apc.enable_cli="1"
285
apc.shm_size="25"
286

    
287
EOF
288

    
289
fi
290

    
291
cp /usr/local/lib/php.ini /usr/local/etc/
292

    
293
rm -f /cf/conf/backup/backup.cache
294

    
295
# let the PHP-based configuration subsystem set up the system now
296
echo -n "Launching PHP init system..."
297
/etc/rc.bootup
298

    
299
echo -n "Starting CRON... "
300
cd /tmp && /usr/sbin/cron -s 2>/dev/null
301
echo "done."
302

    
303
# Start packages
304
/etc/rc.start_packages
305

    
306
rm -rf /usr/local/pkg/pf/CVS
307

    
308
/usr/local/bin/php -f /etc/rc.conf_mount_ro
309

    
310
# Remove stale files that have already been processed by bootup
311
# scripts
312
rm -f /tmp/filter_dirty
313
rm -f /tmp/rc.linkup
314
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status &
315

    
316
# Start ping handler for every 240 seconds
317
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
318

    
319
chmod a+rw /tmp/.
320

    
321
echo "Bootup complete"
322

    
323
/usr/local/bin/beep.sh start 2>&1 >/dev/null
324

    
325
exit 0
(25-25/79)