1 |
5b237745
|
Scott Ullrich
|
#!/bin/sh
|
2 |
|
|
|
3 |
e5cd29a0
|
Scott Ullrich
|
# /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 |
5b237745
|
Scott Ullrich
|
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
# All rights reserved.
|
9 |
|
|
|
10 |
ce823053
|
Scott Ullrich
|
/bin/stty status '^T'
|
11 |
|
|
/bin/stty susp '^-' intr '^-' quit '^-'
|
12 |
5b237745
|
Scott Ullrich
|
|
13 |
|
|
trap : 2
|
14 |
|
|
trap : 3
|
15 |
|
|
|
16 |
|
|
HOME=/
|
17 |
ce823053
|
Scott Ullrich
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
18 |
5b237745
|
Scott Ullrich
|
export HOME PATH
|
19 |
|
|
|
20 |
d4556e07
|
Scott Ullrich
|
# Set our current version
|
21 |
3f38f066
|
Scott Ullrich
|
version=`cat /etc/version`
|
22 |
|
|
|
23 |
d4556e07
|
Scott Ullrich
|
# Set our operating platform
|
24 |
|
|
PLATFORM=`cat /etc/platform`
|
25 |
|
|
|
26 |
e5cd29a0
|
Scott Ullrich
|
echo
|
27 |
fa894130
|
Colin Smith
|
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
|
28 |
e5cd29a0
|
Scott Ullrich
|
echo
|
29 |
|
|
|
30 |
31540677
|
Colin Smith
|
if [ "$PLATFORM" = "cdrom" ]; then
|
31 |
|
|
echo "Running CDROM routines..."
|
32 |
|
|
/etc/rc.cdrom
|
33 |
|
|
fi
|
34 |
|
|
|
35 |
23a115c5
|
Scott Ullrich
|
# Enable console output if its muted.
|
36 |
|
|
/sbin/conscontrol mute off >/dev/null
|
37 |
|
|
|
38 |
|
|
# Mount all. If it fails run a fsck.
|
39 |
673d64a2
|
Scott Ullrich
|
/sbin/mount -a || /sbin/fsck -y && /sbin/mount -a || /sbin/fsck -y
|
40 |
23a115c5
|
Scott Ullrich
|
|
41 |
65308525
|
Scott Ullrich
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
42 |
|
|
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
|
43 |
|
|
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
|
44 |
|
|
/sbin/swapon -a 2>/dev/null
|
45 |
d77ddc0f
|
Scott Ullrich
|
|
46 |
|
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
47 |
5b237745
|
Scott Ullrich
|
|
48 |
98546a74
|
Scott Ullrich
|
/bin/mkdir -p /usr/savecore 2>/dev/null
|
49 |
|
|
/sbin/savecore /usr/savecore $SWAPDEVICE
|
50 |
|
|
fi
|
51 |
712c2f96
|
Scott Ullrich
|
|
52 |
f1cc2287
|
Scott Ullrich
|
# Repair symlinks if they are broken
|
53 |
|
|
if [ ! -L /etc/hosts ]; then
|
54 |
|
|
rm -rf /etc/hosts
|
55 |
c8fcdb2f
|
Scott Ullrich
|
ln -s /var/etc/hosts /etc/hosts
|
56 |
|
|
fi
|
57 |
095d04db
|
Scott Ullrich
|
|
58 |
f1cc2287
|
Scott Ullrich
|
if [ ! -L /etc/resolv.conf ]; then
|
59 |
|
|
rm -rf /etc/resolv.conf
|
60 |
|
|
ln -s /var/etc/resolv.conf /etc/resolv.conf
|
61 |
|
|
fi
|
62 |
095d04db
|
Scott Ullrich
|
|
63 |
cecdf31c
|
Scott Ullrich
|
# Malloc debugging check
|
64 |
|
|
if [ ! -L /etc/malloc.conf ]; then
|
65 |
|
|
ln -s aj /etc/malloc.conf
|
66 |
|
|
fi
|
67 |
|
|
|
68 |
6484bb83
|
Scott Ullrich
|
if [ ! -L /etc/dhclient.conf ]; then
|
69 |
|
|
rm -rf /etc/dhclient.conf
|
70 |
|
|
ln -s /var/etc/dhclient.conf /etc/dhclient.conf
|
71 |
|
|
fi
|
72 |
c8fcdb2f
|
Scott Ullrich
|
|
73 |
bfe6d078
|
Scott Ullrich
|
if [ ! -L /etc/sasyncd.conf ]; then
|
74 |
b8c835d2
|
Scott Ullrich
|
mkdir -p /var/etc/
|
75 |
bfe6d078
|
Scott Ullrich
|
touch /var/etc/sasyncd.conf
|
76 |
|
|
rm -rf /etc/sasyncd.conf
|
77 |
|
|
ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
|
78 |
84f68d65
|
Scott Ullrich
|
chown root:wheel /var/etc/sasyncd.conf
|
79 |
bfe6d078
|
Scott Ullrich
|
chmod 0600 /var/etc/sasyncd.conf
|
80 |
|
|
fi
|
81 |
|
|
|
82 |
69588d92
|
Scott Ullrich
|
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
|
83 |
d42c2e20
|
Scott Ullrich
|
|
84 |
09c2529d
|
Scott Ullrich
|
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
|
85 |
|
|
|
86 |
5b237745
|
Scott Ullrich
|
set -T
|
87 |
|
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
88 |
|
|
|
89 |
f3677fc5
|
Scott Ullrich
|
# Create uploadbar tmp directory
|
90 |
e15f2001
|
Scott Ullrich
|
mkdir -p /tmp/uploadbar
|
91 |
f3677fc5
|
Scott Ullrich
|
chmod 777 /tmp/uploadbar
|
92 |
|
|
|
93 |
5b237745
|
Scott Ullrich
|
# make some directories in /var
|
94 |
102d8912
|
Scott Ullrich
|
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
|
95 |
5b237745
|
Scott Ullrich
|
rm -rf /var/log/*
|
96 |
9cb8e6f0
|
Scott Ullrich
|
rm -rf /var/run/*
|
97 |
7f0439dc
|
Scott Ullrich
|
rm -rf /tmp/*
|
98 |
5b237745
|
Scott Ullrich
|
|
99 |
|
|
# generate circular logfiles
|
100 |
a7fcb832
|
Scott Ullrich
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
101 |
5e6ffad2
|
Scott Ullrich
|
clog -i -s 10000 /var/log/system.log
|
102 |
|
|
clog -i -s 10000 /var/log/filter.log
|
103 |
|
|
clog -i -s 10000 /var/log/dhcpd.log
|
104 |
|
|
clog -i -s 10000 /var/log/vpn.log
|
105 |
|
|
clog -i -s 10000 /var/log/portalauth.log
|
106 |
7a893851
|
Scott Ullrich
|
clog -i -s 10000 /var/log/ipsec.log
|
107 |
a7fcb832
|
Scott Ullrich
|
else
|
108 |
|
|
clog -i -s 262144 /var/log/system.log
|
109 |
|
|
clog -i -s 262144 /var/log/filter.log
|
110 |
|
|
clog -i -s 32768 /var/log/dhcpd.log
|
111 |
|
|
clog -i -s 32768 /var/log/vpn.log
|
112 |
|
|
clog -i -s 32768 /var/log/portalauth.log
|
113 |
7a893851
|
Scott Ullrich
|
clog -i -s 10000 /var/log/ipsec.log
|
114 |
a7fcb832
|
Scott Ullrich
|
fi
|
115 |
8d418ca9
|
Scott Ullrich
|
|
116 |
|
|
# change permissions on newly created clog files.
|
117 |
3f2b92d2
|
Scott Ullrich
|
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
|
118 |
5b237745
|
Scott Ullrich
|
|
119 |
40697dbf
|
Scott Ullrich
|
/sbin/adjkerntz -i
|
120 |
5b237745
|
Scott Ullrich
|
|
121 |
f93c5384
|
Scott Ullrich
|
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
|
122 |
|
|
if [ "$DEVFS" = "0" ]; then
|
123 |
|
|
mount_devfs devfs /dev
|
124 |
|
|
fi
|
125 |
5b237745
|
Scott Ullrich
|
|
126 |
fc6b5a4d
|
Scott Ullrich
|
echo -n "Syncing master.passwd... "
|
127 |
e4217386
|
Scott Ullrich
|
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
|
128 |
deebaae1
|
Scott Ullrich
|
echo "done."
|
129 |
e4217386
|
Scott Ullrich
|
|
130 |
5b237745
|
Scott Ullrich
|
# Create an initial utmp file
|
131 |
|
|
cd /var/run && cp /dev/null utmp && chmod 644 utmp
|
132 |
|
|
|
133 |
6fe4f291
|
Scott Ullrich
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
134 |
c268f10f
|
Scott Ullrich
|
|
135 |
aa26bd27
|
Scott Ullrich
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
136 |
|
|
|
137 |
cdbc61b6
|
Scott Ullrich
|
# Make sure /etc/rc.conf doesn't exist.
|
138 |
|
|
if [ -f /etc/rc.conf ]; then
|
139 |
ac380696
|
Scott Ullrich
|
echo "Removing /etc/rc.conf..."
|
140 |
cdbc61b6
|
Scott Ullrich
|
rm -rf /etc/rc.conf
|
141 |
|
|
fi
|
142 |
|
|
|
143 |
5b237745
|
Scott Ullrich
|
# let the PHP-based configuration subsystem set up the system now
|
144 |
|
|
/etc/rc.bootup
|
145 |
|
|
|
146 |
3f38f066
|
Scott Ullrich
|
echo -n Starting Secure Shell Services...
|
147 |
36ced816
|
Scott Ullrich
|
/etc/sshd 2>/dev/null
|
148 |
17b9532b
|
Scott Ullrich
|
|
149 |
fc6b5a4d
|
Scott Ullrich
|
echo -n "Starting USB... "
|
150 |
10616c2b
|
Scott Ullrich
|
/usr/sbin/usbd 2>>/tmp/bootup_messages
|
151 |
fc6b5a4d
|
Scott Ullrich
|
echo "done."
|
152 |
10616c2b
|
Scott Ullrich
|
|
153 |
0c5e431d
|
Scott Ullrich
|
echo -n "Starting CRON... "
|
154 |
10616c2b
|
Scott Ullrich
|
/usr/sbin/cron 2>>/tmp/bootup_messages
|
155 |
0c5e431d
|
Scott Ullrich
|
echo "done."
|
156 |
3e08b3c1
|
Scott Ullrich
|
|
157 |
36ced816
|
Scott Ullrich
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
158 |
0c5e431d
|
Scott Ullrich
|
|
159 |
|
|
echo "Syncing packages..."
|
160 |
|
|
/etc/rc.packages 2>/dev/null
|
161 |
|
|
|
162 |
36ced816
|
Scott Ullrich
|
echo "Executing rc.d items... "
|
163 |
0c5e431d
|
Scott Ullrich
|
|
164 |
36ced816
|
Scott Ullrich
|
for FILE in /usr/local/etc/rc.d/*.sh; do
|
165 |
|
|
echo -n " Starting ${FILE}..."
|
166 |
98291f96
|
Colin Smith
|
sh $FILE start >>/tmp/bootup_messages 2>&1
|
167 |
36ced816
|
Scott Ullrich
|
echo "done."
|
168 |
|
|
done
|
169 |
|
|
fi
|
170 |
3bd1bd72
|
Scott Ullrich
|
|
171 |
58eba990
|
Scott Ullrich
|
rm -rf /usr/local/pkg/pf/CVS
|
172 |
|
|
|
173 |
7b2ac828
|
Scott Ullrich
|
/usr/local/bin/php -f /etc/rc.conf_mount_ro
|
174 |
f92eaec2
|
Scott Ullrich
|
|
175 |
bc086d51
|
Scott Ullrich
|
/usr/local/sbin/check_reload_status >/dev/null &
|
176 |
|
|
|
177 |
3f38f066
|
Scott Ullrich
|
echo "Bootup complete"
|
178 |
5b237745
|
Scott Ullrich
|
|
179 |
d35cf0de
|
Scott Ullrich
|
exit 0
|