Project

General

Profile

Download (6.39 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
# Malloc debugging check
106
if [ ! -L /etc/malloc.conf ]; then
107
    ln -s aj /etc/malloc.conf
108
fi
109

    
110
if [ ! -L /etc/dhclient.conf ]; then
111
    rm -rf /etc/dhclient.conf
112
fi
113

    
114
if [ ! -L /etc/sasyncd.conf ]; then
115
    mkdir -p /var/etc/
116
    touch /var/etc/sasyncd.conf
117
    rm -rf /etc/sasyncd.conf
118
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
119
    chown root:wheel /var/etc/sasyncd.conf
120
    chmod 0600 /var/etc/sasyncd.conf
121
fi
122

    
123
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
124

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

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

    
129
set -T
130
trap "echo 'Reboot interrupted'; exit 1" 3
131

    
132
# Remove old nameserver resolution files
133
rm -f /var/etc/nameserver*
134

    
135
# Create uploadbar tmp directory
136
mkdir -p /tmp/uploadbar
137
chmod 777 /tmp/uploadbar
138

    
139
# make some directories in /var
140
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
141
rm /var/log/* 2>/dev/null
142
rm -rf /var/run/*
143

    
144
echo -n "."
145
# generate circular logfiles
146
if [ ! "$PLATFORM" = "cdrom" ]; then
147
	clog -i -s 512144 /var/log/system.log
148
	clog -i -s 512144 /var/log/filter.log
149
	clog -i -s 65535 /var/log/dhcpd.log
150
	clog -i -s 65535 /var/log/vpn.log
151
	clog -i -s 65535 /var/log/openvpn.log
152
	clog -i -s 65535 /var/log/portalauth.log
153
	clog -i -s 65535 /var/log/ipsec.log
154
	clog -i -s 65535 /var/log/slbd.log
155
	clog -i -s 65535 /var/log/lighttpd.log
156
	clog -i -s 65535 /var/log/ntpd.log
157
else
158
    clog -i -s 65535 /var/log/system.log
159
    clog -i -s 65535 /var/log/filter.log
160
    clog -i -s 65535 /var/log/dhcpd.log
161
    clog -i -s 65535 /var/log/vpn.log
162
	clog -i -s 65535 /var/log/openvpn.log
163
    clog -i -s 65535 /var/log/portalauth.log
164
    clog -i -s 65535 /var/log/ipsec.log
165
    clog -i -s 65535 /var/log/slbd.log
166
	clog -i -s 65535 /var/log/ntpd.log
167
fi
168

    
169
# change permissions on newly created clog files.
170
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
171

    
172
echo -n "."
173
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
174
if [ "$DEVFS" = "0" ]; then
175
    mount_devfs devfs /dev
176
fi
177

    
178
# Create an initial utmp file
179
cd /var/run && cp /dev/null utmp && chmod 644 utmp
180

    
181
echo -n "."
182
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
183

    
184
# Make sure /etc/rc.conf doesn't exist.
185
if [ -f /etc/rc.conf ]; then
186
    rm -rf /etc/rc.conf
187
fi
188

    
189
# Launching kbdmux(4)
190
if [ -f "/dev/kbdmux0" ]; then
191
	echo -n "."
192
	kbdcontrol -k /dev/kbdmux0 < /dev/console
193
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
194
	[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
195
fi
196

    
197
# Fire up unionfs if mount points exist.
198
if [ -f /dist/uniondirs ]; then
199
	echo -n "."
200
	/etc/rc.d/unionfs start
201
fi
202

    
203
echo "done."
204

    
205
# Recreate capabilities DB
206
cap_mkdb /etc/login.conf
207

    
208
if [ "$PLATFORM" != "cdrom" ]; then
209
# Populate a dummy php.ini to avoid
210
# the file being clobbered and the firewall
211
# not being able to boot back up.
212
cat >/usr/local/lib/php.ini <<EOF
213
output_buffering = "0"
214
implicit_flush = true
215
magic_quotes_gpc = Off
216
max_execution_time = 99999999
217
max_input_time = 99999999
218
register_argc_argv = Off
219
file_uploads = On
220
upload_tmp_dir = /tmp
221
upload_max_filesize = 90M
222
post_max_size = 90M
223
html_errors = Off
224
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
225
apc.enabled="1"
226
apc.enable_cli="1"
227
apc.shm_size="30"
228
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/
229
extension=apc.so
230
extension=radius.so
231

    
232
EOF
233
fi
234

    
235
rm -f /cf/conf/backup/backup.cache
236

    
237
# let the PHP-based configuration subsystem set up the system now
238
echo -n "Launching PHP init system..."
239
/etc/rc.bootup
240

    
241
echo -n "Starting CRON... "
242
cd /tmp && /usr/sbin/cron -s 2>/dev/null
243
echo "done."
244

    
245
# Start packages
246
/etc/rc.start_packages
247

    
248
rm -rf /usr/local/pkg/pf/CVS
249

    
250
/usr/local/bin/php -f /etc/rc.conf_mount_ro
251

    
252
# Remove stale files that have already been processed by bootup
253
# scripts
254
rm -f /tmp/filter_dirty
255
rm -f /tmp/rc.linkup
256
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null
257

    
258
# Start ping handler for every 240 seconds
259
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
260

    
261
echo "Bootup complete"
262

    
263
/usr/local/bin/beep.sh start 2>&1 >/dev/null
264

    
265
exit 0
(24-24/76)