Project

General

Profile

Download (6.56 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
		rm -rf /conf
60
		ln -s /cf/conf /conf
61
	fi
62
fi
63

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

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

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

    
88
# 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
# Repair symlinks if they are broken
95
if [ ! -L /etc/hosts ]; then
96
	rm -rf /etc/hosts
97
	ln -s /var/etc/hosts /etc/hosts
98
fi
99

    
100
if [ ! -L /etc/resolv.conf ]; then
101
    rm -rf /etc/resolv.conf
102
    ln -s /var/etc/resolv.conf /etc/resolv.conf
103
fi
104

    
105
# 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
ln -s / /tmp/tmp
110

    
111
# Malloc debugging check
112
if [ ! -L /etc/malloc.conf ]; then
113
    ln -s aj /etc/malloc.conf
114
fi
115

    
116
if [ ! -L /etc/dhclient.conf ]; then
117
    rm -rf /etc/dhclient.conf
118
fi
119

    
120
if [ ! -L /etc/sasyncd.conf ]; then
121
    mkdir -p /var/etc/
122
    touch /var/etc/sasyncd.conf
123
    rm -rf /etc/sasyncd.conf
124
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
125
    chown root:wheel /var/etc/sasyncd.conf
126
    chmod 0600 /var/etc/sasyncd.conf
127
fi
128

    
129
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
130

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

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

    
135
set -T
136
trap "echo 'Reboot interrupted'; exit 1" 3
137

    
138
# Remove old nameserver resolution files
139
rm -f /var/etc/nameserver*
140

    
141
# Create uploadbar tmp directory
142
mkdir -p /tmp/uploadbar
143
chmod 777 /tmp/uploadbar
144

    
145
# make some directories in /var
146
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
147
rm /var/log/* 2>/dev/null
148
rm -rf /var/run/*
149

    
150
echo -n "."
151
# generate circular logfiles
152
if [ ! "$PLATFORM" = "cdrom" ]; then
153
	clog -i -s 512144 /var/log/system.log
154
	clog -i -s 512144 /var/log/filter.log
155
	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
	clog -i -s 65535 /var/log/ntpd.log
163
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
	clog -i -s 65535 /var/log/ntpd.log
173
fi
174

    
175
# change permissions on newly created clog files.
176
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

    
178
echo -n "."
179
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
180
if [ "$DEVFS" = "0" ]; then
181
    mount_devfs devfs /dev
182
fi
183

    
184
# Create an initial utmp file
185
cd /var/run && cp /dev/null utmp && chmod 644 utmp
186

    
187
echo -n "."
188
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
189

    
190
# 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
# Launching kbdmux(4)
196
if [ -f "/dev/kbdmux0" ]; then
197
	echo -n "."
198
	kbdcontrol -k /dev/kbdmux0 < /dev/console
199
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
200
	[ -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
	echo -n "."
206
	/etc/rc.d/unionfs start
207
fi
208

    
209
echo "done."
210

    
211
# Recreate capabilities DB
212
cap_mkdb /etc/login.conf
213

    
214
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
rm -f /cf/conf/backup/backup.cache
242

    
243
# let the PHP-based configuration subsystem set up the system now
244
echo -n "Launching PHP init system..."
245
/etc/rc.bootup
246

    
247
echo -n "Starting CRON... "
248
cd /tmp && /usr/sbin/cron -s 2>/dev/null
249
echo "done."
250

    
251
# Start packages
252
/etc/rc.start_packages
253

    
254
rm -rf /usr/local/pkg/pf/CVS
255

    
256
/usr/local/bin/php -f /etc/rc.conf_mount_ro
257

    
258
# Remove stale files that have already been processed by bootup
259
# scripts
260
rm -f /tmp/filter_dirty
261
rm -f /tmp/rc.linkup
262
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status &
263

    
264
# Start ping handler for every 240 seconds
265
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
266

    
267
echo "Bootup complete"
268

    
269
/usr/local/bin/beep.sh start 2>&1 >/dev/null
270

    
271
exit 0
(24-24/77)