Project

General

Profile

Download (7.48 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
# generate circular logfiles
159
if [ ! "$PLATFORM" = "cdrom" ]; then
160
	clog -i -s 512144 /var/log/system.log
161
	clog -i -s 512144 /var/log/filter.log
162
	clog -i -s 65535 /var/log/dhcpd.log
163
	clog -i -s 65535 /var/log/vpn.log
164
	clog -i -s 65535 /var/log/openvpn.log
165
	clog -i -s 65535 /var/log/portalauth.log
166
	clog -i -s 65535 /var/log/ipsec.log
167
	clog -i -s 65535 /var/log/slbd.log
168
	clog -i -s 65535 /var/log/lighttpd.log
169
	clog -i -s 65535 /var/log/ntpd.log
170
else
171
    clog -i -s 65535 /var/log/system.log
172
    clog -i -s 65535 /var/log/filter.log
173
    clog -i -s 65535 /var/log/dhcpd.log
174
    clog -i -s 65535 /var/log/vpn.log
175
	clog -i -s 65535 /var/log/openvpn.log
176
    clog -i -s 65535 /var/log/portalauth.log
177
    clog -i -s 65535 /var/log/ipsec.log
178
    clog -i -s 65535 /var/log/slbd.log
179
	clog -i -s 65535 /var/log/ntpd.log
180
fi
181

    
182
# change permissions on newly created clog files.
183
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
184

    
185
echo -n "."
186
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
187
if [ "$DEVFS" = "0" ]; then
188
    mount_devfs devfs /dev
189
fi
190

    
191
# Create an initial utmp file
192
cd /var/run && cp /dev/null utmp && chmod 644 utmp
193

    
194
echo -n "."
195
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
196

    
197
# Make sure /etc/rc.conf doesn't exist.
198
if [ -f /etc/rc.conf ]; then
199
    rm -rf /etc/rc.conf
200
fi
201

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

    
210
# Fire up unionfs if mount points exist.
211
if [ -f /dist/uniondirs ]; then
212
	echo -n "."
213
	/etc/rc.d/unionfs start
214
fi
215

    
216
echo "done."
217

    
218
# Recreate capabilities DB
219
cap_mkdb /etc/login.conf
220

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

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

    
263
; standard PHP extensions currently beeing unused
264
;extension=json.so
265
;extension=ncurses.so
266
;xmlreader.so
267
;xmlwriter.so
268

    
269
;[xdebug]
270
;xdebug.remote_enable = On
271
;xdebug.default_enable = On
272
;xdebug.remote_mode = On
273
;xdebug.remote_handler = dbgp
274
;xdebug.remote_host = 127.0.0.1
275
;xdebug.remote_port = 17869
276
;xdebug.idekey = devphp
277

    
278

    
279
EOF
280

    
281
cp /usr/local/lib/php.ini /usr/local/etc/
282

    
283
rm -f /cf/conf/backup/backup.cache
284

    
285
# let the PHP-based configuration subsystem set up the system now
286
echo -n "Launching PHP init system..."
287
/etc/rc.bootup
288

    
289
echo -n "Starting CRON... "
290
cd /tmp && /usr/sbin/cron -s 2>/dev/null
291
echo "done."
292

    
293
# Start packages
294
/etc/rc.start_packages
295

    
296
rm -rf /usr/local/pkg/pf/CVS
297

    
298
/usr/local/bin/php -f /etc/rc.conf_mount_ro
299

    
300
# Remove stale files that have already been processed by bootup
301
# scripts
302
rm -f /tmp/filter_dirty
303
rm -f /tmp/rc.linkup
304
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status &
305

    
306
# Start ping handler for every 240 seconds
307
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
308

    
309
chmod a+rw /tmp/.
310

    
311
echo "Bootup complete"
312

    
313
/usr/local/bin/beep.sh start 2>&1 >/dev/null
314

    
315
exit 0
(25-25/79)