Project

General

Profile

Download (6.05 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
# Enable Softupdates if enablesoftupdates is found in config.xml
42
SOFTUPDATES=`/usr/bin/grep "enablesoftupdates" /cf/conf/config.xml | wc -l`
43
if [ $SOFTUPDATES -gt 0 ]; then
44
	FILESYSTEM=`cat /etc/fstab | grep "/" | grep ufs | awk '{ print $1 }'`
45
	/sbin/tunefs -n enable $FILESYSTEM 2>/dev/null
46
	if [ $? != 0 ]; then
47
		echo "Cleaning filesystem..."
48
		fsck -y $FILESYSTEM
49
		echo "Attempting soft updates enable again..."
50
		/sbin/tunefs -n enable $FILESYSTEM
51
	fi
52
fi
53

    
54
# Enable console output if its muted.
55
/sbin/conscontrol mute off >/dev/null
56

    
57
# Mount memory file system if it exists
58
echo -n "Mounting filesystems..."
59
/sbin/mount -a
60

    
61
# Mount /. If it fails run a fsck.
62
if [ ! "$PLATFORM" = "cdrom" ] ; then
63
	/sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /)
64

    
65
	# If /conf is a directory, convert it to a symlink
66
	# to /cf/conf
67
	if [ -d "/conf" ]; then
68
		rm -rf /conf
69
		ln -s /cf/conf /conf
70
	fi
71
fi
72

    
73
# Check to see if a compact flash mountpoint exists
74
# If it fails to mount then run a fsck -fy
75
if grep -q cf /etc/fstab; then
76
    /sbin/mount -uw /cf || \
77
	(/sbin/umount /cf; /sbin/fsck -fy /cf; /sbin/mount -w /cf)
78
fi
79

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

    
90
echo -n "Creating symlinks..."
91
# Make sure symlink is correct on embedded
92
if [ "$PLATFORM" = "embedded" ] ; then
93
	rm /conf
94
	ln -s /cf/conf/ /conf
95
fi
96

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

    
103
# Repair symlinks if they are broken
104
if [ ! -L /etc/hosts ]; then
105
	rm -rf /etc/hosts
106
	ln -s /var/etc/hosts /etc/hosts
107
fi
108

    
109
if [ ! -L /etc/resolv.conf ]; then
110
    rm -rf /etc/resolv.conf
111
    ln -s /var/etc/resolv.conf /etc/resolv.conf
112
fi
113

    
114
# Malloc debugging check
115
if [ ! -L /etc/malloc.conf ]; then
116
    ln -s aj /etc/malloc.conf
117
fi
118

    
119
if [ ! -L /etc/dhclient.conf ]; then
120
    rm -rf /etc/dhclient.conf
121
fi
122

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

    
132
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
133

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

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

    
138
set -T
139
trap "echo 'Reboot interrupted'; exit 1" 3
140

    
141
# Remove old nameserver resolution files
142
rm -f /var/etc/nameserver*
143

    
144
# Create uploadbar tmp directory
145
mkdir -p /tmp/uploadbar
146
chmod 777 /tmp/uploadbar
147

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

    
153
echo -n "."
154
# generate circular logfiles
155
if [ ! "$PLATFORM" = "cdrom" ]; then
156
	clog -i -s 512144 /var/log/system.log
157
	clog -i -s 512144 /var/log/filter.log
158
	clog -i -s 65535 /var/log/dhcpd.log
159
	clog -i -s 65535 /var/log/vpn.log
160
	clog -i -s 65535 /var/log/openvpn.log
161
	clog -i -s 65535 /var/log/portalauth.log
162
	clog -i -s 65535 /var/log/ipsec.log
163
	clog -i -s 65535 /var/log/slbd.log
164
	clog -i -s 65535 /var/log/lighttpd.log
165
	clog -i -s 65535 /var/log/ntpd.log
166
else
167
    clog -i -s 65535 /var/log/system.log
168
    clog -i -s 65535 /var/log/filter.log
169
    clog -i -s 65535 /var/log/dhcpd.log
170
    clog -i -s 65535 /var/log/vpn.log
171
	clog -i -s 65535 /var/log/openvpn.log
172
    clog -i -s 65535 /var/log/portalauth.log
173
    clog -i -s 65535 /var/log/ipsec.log
174
    clog -i -s 65535 /var/log/slbd.log
175
	clog -i -s 65535 /var/log/ntpd.log
176
fi
177

    
178
# change permissions on newly created clog files.
179
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
180

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

    
187
# Create an initial utmp file
188
cd /var/run && cp /dev/null utmp && chmod 644 utmp
189

    
190
echo -n "."
191
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
192

    
193
# Make sure /etc/rc.conf doesn't exist.
194
if [ -f /etc/rc.conf ]; then
195
    rm -rf /etc/rc.conf
196
fi
197

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

    
206
# Fire up unionfs if mount points exist.
207
if [ -f /dist/uniondirs ]; then
208
	echo -n "."
209
	/etc/rc.d/unionfs start
210
fi
211

    
212
echo "done."
213

    
214
# Recreate capabilities DB
215
cap_mkdb /etc/login.conf
216

    
217
# let the PHP-based configuration subsystem set up the system now
218
echo -n "Launching PHP init system..."
219
/etc/rc.bootup
220

    
221
echo -n "Starting CRON... "
222
cd /tmp && /usr/sbin/cron -s
223
echo "done."
224

    
225
# Start packages
226
/etc/rc.start_packages
227

    
228
rm -rf /usr/local/pkg/pf/CVS
229

    
230
/usr/local/bin/php -f /etc/rc.conf_mount_ro
231

    
232
# Remove stale files that have already been processed by bootup
233
# scripts
234
rm -f /tmp/filter_dirty
235
rm -f /tmp/rc.linkup
236
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null
237

    
238
# Start ping handler for every 240 seconds
239
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
240

    
241
echo "Bootup complete"
242

    
243
/usr/local/bin/beep.sh start 2>&1 >/dev/null
244

    
245
exit 0
(24-24/76)