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 |
|
|
stty status '^T'
|
11 |
2733ae78
|
Scott Ullrich
|
stty susp '^-' intr '^-' quit '^-'
|
12 |
5b237745
|
Scott Ullrich
|
|
13 |
|
|
trap : 2
|
14 |
|
|
trap : 3
|
15 |
|
|
|
16 |
|
|
HOME=/
|
17 |
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
18 |
|
|
export HOME PATH
|
19 |
|
|
|
20 |
3f38f066
|
Scott Ullrich
|
version=`cat /etc/version`
|
21 |
|
|
|
22 |
4ec1f1c7
|
Scott Ullrich
|
/sbin/conscontrol mute off
|
23 |
|
|
|
24 |
e5cd29a0
|
Scott Ullrich
|
echo
|
25 |
3f38f066
|
Scott Ullrich
|
echo "Welcome to pfSense ${version} ..."
|
26 |
e5cd29a0
|
Scott Ullrich
|
echo
|
27 |
|
|
|
28 |
2a069553
|
Scott Ullrich
|
/sbin/mount -a || fsck -y && mount -a
|
29 |
2ed803e7
|
Scott Ullrich
|
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
|
30 |
1828ab3a
|
Scott Ullrich
|
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
|
31 |
e7435c3b
|
Scott Ullrich
|
/sbin/swapon -a 2>/dev/null
|
32 |
f0314010
|
Scott Ullrich
|
/bin/mkdir -p /usr/savecore 2>/dev/null
|
33 |
2ed803e7
|
Scott Ullrich
|
/sbin/savecore /usr/savecore $SWAPDEVICE
|
34 |
5b237745
|
Scott Ullrich
|
|
35 |
7b2ac828
|
Scott Ullrich
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
36 |
f92eaec2
|
Scott Ullrich
|
|
37 |
04701f45
|
Scott Ullrich
|
platform=`cat /etc/platform`
|
38 |
|
|
if [ "$PLATFORM" = "cdrom" ]; then
|
39 |
54d01d53
|
Scott Ullrich
|
/etc/rc.d/freesbie_1st
|
40 |
04701f45
|
Scott Ullrich
|
fi
|
41 |
|
|
|
42 |
f1cc2287
|
Scott Ullrich
|
# Repair symlinks if they are broken
|
43 |
|
|
if [ ! -L /etc/hosts ]; then
|
44 |
|
|
rm -rf /etc/hosts
|
45 |
c8fcdb2f
|
Scott Ullrich
|
ln -s /var/etc/hosts /etc/hosts
|
46 |
|
|
fi
|
47 |
f1cc2287
|
Scott Ullrich
|
if [ ! -L /etc/resolv.conf ]; then
|
48 |
|
|
rm -rf /etc/resolv.conf
|
49 |
|
|
ln -s /var/etc/resolv.conf /etc/resolv.conf
|
50 |
|
|
fi
|
51 |
6484bb83
|
Scott Ullrich
|
if [ ! -L /etc/dhclient.conf ]; then
|
52 |
|
|
rm -rf /etc/dhclient.conf
|
53 |
|
|
ln -s /var/etc/dhclient.conf /etc/dhclient.conf
|
54 |
|
|
fi
|
55 |
c8fcdb2f
|
Scott Ullrich
|
|
56 |
360fb405
|
Scott Ullrich
|
if [ ! -d /cf/conf/backup/ ]; then
|
57 |
|
|
mkdir -p /cf/conf/backup/ 2>/dev/null
|
58 |
d42c2e20
|
Scott Ullrich
|
fi
|
59 |
|
|
|
60 |
5b237745
|
Scott Ullrich
|
set -T
|
61 |
|
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
62 |
|
|
|
63 |
f3677fc5
|
Scott Ullrich
|
# Create uploadbar tmp directory
|
64 |
e15f2001
|
Scott Ullrich
|
mkdir -p /tmp/uploadbar
|
65 |
f3677fc5
|
Scott Ullrich
|
chmod 777 /tmp/uploadbar
|
66 |
|
|
|
67 |
5b237745
|
Scott Ullrich
|
# make some directories in /var
|
68 |
|
|
mkdir /var/run /var/log /var/etc /var/db/ipf 2>/dev/null
|
69 |
|
|
chmod 0755 /var/db/ipf
|
70 |
|
|
rm -rf /var/log/*
|
71 |
9cb8e6f0
|
Scott Ullrich
|
rm -rf /var/run/*
|
72 |
7f0439dc
|
Scott Ullrich
|
rm -rf /tmp/*
|
73 |
5b237745
|
Scott Ullrich
|
|
74 |
|
|
# generate circular logfiles
|
75 |
|
|
clog -i -s 262144 /var/log/system.log
|
76 |
|
|
clog -i -s 262144 /var/log/filter.log
|
77 |
|
|
clog -i -s 32768 /var/log/dhcpd.log
|
78 |
|
|
clog -i -s 32768 /var/log/vpn.log
|
79 |
3f2b92d2
|
Scott Ullrich
|
clog -i -s 32768 /var/log/portalauth.log
|
80 |
|
|
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
|
81 |
5b237745
|
Scott Ullrich
|
|
82 |
40697dbf
|
Scott Ullrich
|
/sbin/adjkerntz -i
|
83 |
5b237745
|
Scott Ullrich
|
|
84 |
f93c5384
|
Scott Ullrich
|
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
|
85 |
|
|
if [ "$DEVFS" = "0" ]; then
|
86 |
|
|
mount_devfs devfs /dev
|
87 |
|
|
fi
|
88 |
5b237745
|
Scott Ullrich
|
|
89 |
fc6b5a4d
|
Scott Ullrich
|
echo -n "Syncing master.passwd... "
|
90 |
e4217386
|
Scott Ullrich
|
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
|
91 |
deebaae1
|
Scott Ullrich
|
echo "done."
|
92 |
e4217386
|
Scott Ullrich
|
|
93 |
5b237745
|
Scott Ullrich
|
# Create an initial utmp file
|
94 |
|
|
cd /var/run && cp /dev/null utmp && chmod 644 utmp
|
95 |
|
|
|
96 |
|
|
# Build devices database
|
97 |
|
|
#dev_mkdb
|
98 |
|
|
|
99 |
|
|
# Run ldconfig
|
100 |
0ede09d9
|
Scott Ullrich
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
101 |
5b237745
|
Scott Ullrich
|
|
102 |
aa26bd27
|
Scott Ullrich
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
103 |
|
|
|
104 |
5b237745
|
Scott Ullrich
|
# let the PHP-based configuration subsystem set up the system now
|
105 |
|
|
/etc/rc.bootup
|
106 |
|
|
|
107 |
3f38f066
|
Scott Ullrich
|
echo -n Starting Secure Shell Services...
|
108 |
17b9532b
|
Scott Ullrich
|
/etc/sshd
|
109 |
|
|
|
110 |
fc6b5a4d
|
Scott Ullrich
|
echo -n "Starting USB... "
|
111 |
10616c2b
|
Scott Ullrich
|
/usr/sbin/usbd 2>>/tmp/bootup_messages
|
112 |
fc6b5a4d
|
Scott Ullrich
|
echo "done."
|
113 |
10616c2b
|
Scott Ullrich
|
|
114 |
|
|
/usr/sbin/cron 2>>/tmp/bootup_messages
|
115 |
04714d83
|
Scott Ullrich
|
|
116 |
238f6962
|
Colin Smith
|
/etc/rc.packages
|
117 |
3e08b3c1
|
Scott Ullrich
|
|
118 |
fc6b5a4d
|
Scott Ullrich
|
echo "Executing rc.d items... "
|
119 |
17b9532b
|
Scott Ullrich
|
for FILE in /usr/local/etc/rc.d/*.sh; do
|
120 |
d53c2f85
|
Scott Ullrich
|
echo -n " Starting ${FILE}..."
|
121 |
|
|
sh $FILE >>/tmp/bootup_messages 2>&1
|
122 |
fc6b5a4d
|
Scott Ullrich
|
echo "done."
|
123 |
316a0dda
|
Scott Ullrich
|
done
|
124 |
3bd1bd72
|
Scott Ullrich
|
|
125 |
44d21387
|
Scott Ullrich
|
if [ -f /tmp/filter_boot_dirty ]; then
|
126 |
b19c8622
|
Scott Ullrich
|
# one more pass to give package plugins a chance to adjust
|
127 |
|
|
echo -n "Final firewall setup in progress..."
|
128 |
|
|
/etc/rc.filter_configure
|
129 |
|
|
echo "Done."
|
130 |
|
|
fi
|
131 |
a1ad1bc3
|
Scott Ullrich
|
|
132 |
7b2ac828
|
Scott Ullrich
|
/usr/local/bin/php -f /etc/rc.conf_mount_ro
|
133 |
f92eaec2
|
Scott Ullrich
|
|
134 |
3f38f066
|
Scott Ullrich
|
echo "Bootup complete"
|
135 |
5b237745
|
Scott Ullrich
|
|
136 |
d35cf0de
|
Scott Ullrich
|
exit 0
|