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
|
# mount /usr.uzip if it exists
|
17
|
[ -x /usr.uzip ] && [ -d /usr ] && [ ! -d /usr/local ] \
|
18
|
&& /sbin/mount_cd9660 /dev/`/sbin/mdconfig -af /usr.uzip`.uzip /usr
|
19
|
|
20
|
HOME=/
|
21
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
22
|
export HOME PATH
|
23
|
|
24
|
# Set our current version
|
25
|
version=`cat /etc/version`
|
26
|
|
27
|
# Set our operating platform
|
28
|
PLATFORM=`cat /etc/platform`
|
29
|
|
30
|
echo
|
31
|
cat /etc/ascii-art/pfsense-logo-small.txt
|
32
|
echo
|
33
|
echo
|
34
|
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
|
35
|
echo
|
36
|
|
37
|
if [ "$PLATFORM" = "cdrom" ]; then
|
38
|
echo "Running CDROM routines..."
|
39
|
/etc/rc.cdrom
|
40
|
fi
|
41
|
|
42
|
# Enable console output if its muted.
|
43
|
/sbin/conscontrol mute off >/dev/null
|
44
|
|
45
|
# Mount /. If it fails run a fsck.
|
46
|
if [ ! "$PLATFORM" = "cdrom" ] ; then
|
47
|
/sbin/mount -w / || /sbin/fsck -y
|
48
|
fi
|
49
|
|
50
|
# Check to see if a compact flash mountpoint exists
|
51
|
# If it fails to mount then run a fsck -y
|
52
|
if grep cf /etc/fstab; then
|
53
|
/sbin/mount -w /cf || /sbin/fsck -y
|
54
|
fi
|
55
|
|
56
|
# Mount memory file system if it exists
|
57
|
/sbin/mount -a
|
58
|
|
59
|
if [ "$PLATFORM" = "cdrom" ] ; then
|
60
|
echo "No swap on ${PLATFORM}"
|
61
|
elif [ "$PLATFORM" = "embedded" ] ; then
|
62
|
echo "No swap on ${PLATFORM}"
|
63
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
64
|
else
|
65
|
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
|
66
|
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
|
67
|
/sbin/swapon -a 2>/dev/null
|
68
|
|
69
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
70
|
|
71
|
/bin/mkdir -p /usr/savecore 2>/dev/null
|
72
|
/sbin/savecore /usr/savecore $SWAPDEVICE
|
73
|
fi
|
74
|
|
75
|
# Repair symlinks if they are broken
|
76
|
if [ ! -L /etc/syslog.conf ]; then
|
77
|
rm -rf /etc/syslog.conf
|
78
|
ln -s /var/etc/syslog.conf /etc/syslog.conf
|
79
|
fi
|
80
|
|
81
|
# Repair symlinks if they are broken
|
82
|
if [ ! -L /etc/hosts ]; then
|
83
|
rm -rf /etc/hosts
|
84
|
ln -s /var/etc/hosts /etc/hosts
|
85
|
fi
|
86
|
|
87
|
if [ ! -L /etc/resolv.conf ]; then
|
88
|
rm -rf /etc/resolv.conf
|
89
|
ln -s /var/etc/resolv.conf /etc/resolv.conf
|
90
|
fi
|
91
|
|
92
|
# Malloc debugging check
|
93
|
if [ ! -L /etc/malloc.conf ]; then
|
94
|
ln -s aj /etc/malloc.conf
|
95
|
fi
|
96
|
|
97
|
if [ ! -L /etc/dhclient.conf ]; then
|
98
|
rm -rf /etc/dhclient.conf
|
99
|
ln -s /var/etc/dhclient.conf /etc/dhclient.conf
|
100
|
fi
|
101
|
|
102
|
if [ ! -L /etc/sasyncd.conf ]; then
|
103
|
mkdir -p /var/etc/
|
104
|
touch /var/etc/sasyncd.conf
|
105
|
rm -rf /etc/sasyncd.conf
|
106
|
ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
|
107
|
chown root:wheel /var/etc/sasyncd.conf
|
108
|
chmod 0600 /var/etc/sasyncd.conf
|
109
|
fi
|
110
|
|
111
|
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
|
112
|
|
113
|
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
|
114
|
|
115
|
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
|
116
|
|
117
|
set -T
|
118
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
119
|
|
120
|
# Create uploadbar tmp directory
|
121
|
mkdir -p /tmp/uploadbar
|
122
|
chmod 777 /tmp/uploadbar
|
123
|
|
124
|
# make some directories in /var
|
125
|
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
|
126
|
rm -rf /var/log/*
|
127
|
rm -rf /var/run/*
|
128
|
rm -rf /tmp/*
|
129
|
|
130
|
# generate circular logfiles
|
131
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
132
|
clog -i -s 10000 /var/log/system.log
|
133
|
clog -i -s 10000 /var/log/filter.log
|
134
|
clog -i -s 10000 /var/log/dhcpd.log
|
135
|
clog -i -s 10000 /var/log/vpn.log
|
136
|
clog -i -s 10000 /var/log/portalauth.log
|
137
|
clog -i -s 10000 /var/log/ipsec.log
|
138
|
clog -i -s 10000 /var/log/slbd.log
|
139
|
else
|
140
|
clog -i -s 262144 /var/log/system.log
|
141
|
clog -i -s 262144 /var/log/filter.log
|
142
|
clog -i -s 32768 /var/log/dhcpd.log
|
143
|
clog -i -s 32768 /var/log/vpn.log
|
144
|
clog -i -s 32768 /var/log/portalauth.log
|
145
|
clog -i -s 10000 /var/log/ipsec.log
|
146
|
clog -i -s 262144 /var/log/slbd.log
|
147
|
fi
|
148
|
|
149
|
# change permissions on newly created clog files.
|
150
|
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
|
151
|
|
152
|
/sbin/adjkerntz -i
|
153
|
|
154
|
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
|
155
|
if [ "$DEVFS" = "0" ]; then
|
156
|
mount_devfs devfs /dev
|
157
|
fi
|
158
|
|
159
|
# Create an initial utmp file
|
160
|
cd /var/run && cp /dev/null utmp && chmod 644 utmp
|
161
|
|
162
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
163
|
|
164
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
165
|
|
166
|
# Make sure /etc/rc.conf doesn't exist.
|
167
|
if [ -f /etc/rc.conf ]; then
|
168
|
echo "Removing /etc/rc.conf..."
|
169
|
rm -rf /etc/rc.conf
|
170
|
fi
|
171
|
|
172
|
echo -n "Starting USB... "
|
173
|
/usr/sbin/usbd 2>>/tmp/bootup_messages
|
174
|
/usr/local/sbin/kbdcheck
|
175
|
echo "done."
|
176
|
|
177
|
# let the PHP-based configuration subsystem set up the system now
|
178
|
/etc/rc.bootup
|
179
|
|
180
|
echo -n Starting Secure Shell Services...
|
181
|
/etc/sshd
|
182
|
|
183
|
echo -n "Starting CRON... "
|
184
|
/usr/sbin/cron 2>>/tmp/bootup_messages
|
185
|
echo "done."
|
186
|
|
187
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
188
|
|
189
|
echo "Syncing packages..."
|
190
|
/etc/rc.packages 2>/dev/null
|
191
|
|
192
|
echo "Executing rc.d items... "
|
193
|
|
194
|
for FILE in /usr/local/etc/rc.d/*.sh; do
|
195
|
echo -n " Starting ${FILE}..."
|
196
|
sh $FILE start >>/tmp/bootup_messages 2>&1
|
197
|
echo "done."
|
198
|
done
|
199
|
fi
|
200
|
|
201
|
rm -rf /usr/local/pkg/pf/CVS
|
202
|
|
203
|
/usr/local/bin/php -f /etc/rc.conf_mount_ro
|
204
|
|
205
|
/usr/local/sbin/check_reload_status >/dev/null &
|
206
|
|
207
|
echo "Bootup complete"
|
208
|
|
209
|
if [ -e /dev/ttyv1 ]; then
|
210
|
if [ ! -e /var/etc/console_lockdown ]; then
|
211
|
# Allow VTY switching
|
212
|
/usr/sbin/vidcontrol -S on 2>/dev/null
|
213
|
# Turn off bloody mouse pointer.
|
214
|
/usr/sbin/vidcontrol -m off 2>/dev/null
|
215
|
env TERM=cons25 sh -c /etc/rc.initial 2>/dev/ttyv1 </dev/ttyv1 >/dev/ttyv1 &
|
216
|
sleep 1
|
217
|
/usr/sbin/vidcontrol -s 2 2>/dev/null
|
218
|
fi
|
219
|
else
|
220
|
while [ 1 ];
|
221
|
do
|
222
|
env TERM=cons25 sh -c "/etc/rc.initial"
|
223
|
done
|
224
|
exit
|
225
|
fi
|
226
|
|
227
|
/usr/local/bin/beep.sh start
|
228
|
|
229
|
exit 0
|