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
|
HOME=/
|
17
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
18
|
export HOME PATH
|
19
|
|
20
|
# Set our current version
|
21
|
version=`cat /etc/version`
|
22
|
|
23
|
# Set our operating platform
|
24
|
PLATFORM=`cat /etc/platform`
|
25
|
|
26
|
if [ "$PLATFORM" = "cdrom" ]; then
|
27
|
/etc/rc.d/freesbie_1st
|
28
|
/bin/sh /scripts/pfi start
|
29
|
fi
|
30
|
|
31
|
echo
|
32
|
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
|
33
|
echo
|
34
|
|
35
|
/sbin/mount -a || fsck -y && mount -a
|
36
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
37
|
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
|
38
|
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
|
39
|
/sbin/swapon -a 2>/dev/null
|
40
|
|
41
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
42
|
fi
|
43
|
|
44
|
/sbin/conscontrol mute off
|
45
|
|
46
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
47
|
/bin/mkdir -p /usr/savecore 2>/dev/null
|
48
|
/sbin/savecore /usr/savecore $SWAPDEVICE
|
49
|
fi
|
50
|
|
51
|
# Repair symlinks if they are broken
|
52
|
if [ ! -L /etc/hosts ]; then
|
53
|
rm -rf /etc/hosts
|
54
|
ln -s /var/etc/hosts /etc/hosts
|
55
|
fi
|
56
|
|
57
|
if [ ! -L /etc/resolv.conf ]; then
|
58
|
rm -rf /etc/resolv.conf
|
59
|
ln -s /var/etc/resolv.conf /etc/resolv.conf
|
60
|
fi
|
61
|
|
62
|
if [ ! -L /etc/dhclient.conf ]; then
|
63
|
rm -rf /etc/dhclient.conf
|
64
|
ln -s /var/etc/dhclient.conf /etc/dhclient.conf
|
65
|
fi
|
66
|
|
67
|
if [ ! -d /cf/conf/backup/ ]; then
|
68
|
mkdir -p /cf/conf/backup/ 2>/dev/null
|
69
|
fi
|
70
|
|
71
|
if [ "$PLATFORM" = "cdrom" ]; then
|
72
|
ln -s /cf/conf /conf
|
73
|
if [ ! -f /cf/conf/config.xml ]; then
|
74
|
cp /FreeSBIE/cf/conf/* /cf/conf/ 2>/dev/null
|
75
|
fi
|
76
|
fi
|
77
|
|
78
|
set -T
|
79
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
80
|
|
81
|
# Create uploadbar tmp directory
|
82
|
mkdir -p /tmp/uploadbar
|
83
|
chmod 777 /tmp/uploadbar
|
84
|
|
85
|
# make some directories in /var
|
86
|
mkdir /var/run /var/log /var/etc 2>/dev/null
|
87
|
rm -rf /var/log/*
|
88
|
rm -rf /var/run/*
|
89
|
rm -rf /tmp/*
|
90
|
|
91
|
# generate circular logfiles
|
92
|
clog -i -s 262144 /var/log/system.log
|
93
|
clog -i -s 262144 /var/log/filter.log
|
94
|
clog -i -s 32768 /var/log/dhcpd.log
|
95
|
clog -i -s 32768 /var/log/vpn.log
|
96
|
clog -i -s 32768 /var/log/portalauth.log
|
97
|
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
|
98
|
|
99
|
/sbin/adjkerntz -i
|
100
|
|
101
|
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
|
102
|
if [ "$DEVFS" = "0" ]; then
|
103
|
mount_devfs devfs /dev
|
104
|
fi
|
105
|
|
106
|
echo -n "Syncing master.passwd... "
|
107
|
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
|
108
|
echo "done."
|
109
|
|
110
|
# Create an initial utmp file
|
111
|
cd /var/run && cp /dev/null utmp && chmod 644 utmp
|
112
|
|
113
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
114
|
# Run ldconfig
|
115
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
116
|
fi
|
117
|
|
118
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
119
|
|
120
|
# let the PHP-based configuration subsystem set up the system now
|
121
|
/etc/rc.bootup
|
122
|
|
123
|
echo -n Starting Secure Shell Services...
|
124
|
/etc/sshd 2>/dev/null
|
125
|
|
126
|
echo -n "Starting USB... "
|
127
|
/usr/sbin/usbd 2>>/tmp/bootup_messages
|
128
|
echo "done."
|
129
|
|
130
|
echo -n "Starting CRON... "
|
131
|
/usr/sbin/cron 2>>/tmp/bootup_messages
|
132
|
echo "done."
|
133
|
|
134
|
if [ ! "$PLATFORM" = "cdrom" ]; then
|
135
|
|
136
|
echo "Syncing packages..."
|
137
|
/etc/rc.packages 2>/dev/null
|
138
|
|
139
|
echo "Executing rc.d items... "
|
140
|
|
141
|
for FILE in /usr/local/etc/rc.d/*.sh; do
|
142
|
echo -n " Starting ${FILE}..."
|
143
|
sh $FILE >>/tmp/bootup_messages 2>&1
|
144
|
echo "done."
|
145
|
done
|
146
|
fi
|
147
|
|
148
|
if [ -f /tmp/filter_boot_dirty ]; then
|
149
|
# one more pass to give package plugins a chance to adjust
|
150
|
echo -n "Final firewall setup in progress..."
|
151
|
/etc/rc.filter_configure
|
152
|
echo "Done."
|
153
|
fi
|
154
|
|
155
|
/usr/local/bin/php -f /etc/rc.conf_mount_ro
|
156
|
|
157
|
echo "Bootup complete"
|
158
|
|
159
|
exit 0
|
160
|
|