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
|
stty status '^T'
|
11
|
stty susp '^-' intr '^-' quit '^-'
|
12
|
|
13
|
trap : 2
|
14
|
trap : 3
|
15
|
|
16
|
HOME=/
|
17
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
18
|
export HOME PATH
|
19
|
|
20
|
version=`cat /etc/version`
|
21
|
|
22
|
/sbin/conscontrol mute off
|
23
|
|
24
|
echo
|
25
|
echo "Welcome to pfSense ${version} ..."
|
26
|
echo
|
27
|
|
28
|
/sbin/mount -a || fsck -y && mount -a
|
29
|
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
|
30
|
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
|
31
|
/sbin/swapon -a 2>/dev/null
|
32
|
/bin/mkdir -p /usr/savecore 2>/dev/null
|
33
|
/sbin/savecore /usr/savecore $SWAPDEVICE
|
34
|
|
35
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
36
|
|
37
|
platform=`cat /etc/platform`
|
38
|
if [ "$PLATFORM" = "cdrom" ]; then
|
39
|
/etc/rc.d/freesbie_1st
|
40
|
fi
|
41
|
|
42
|
# Repair symlinks if they are broken
|
43
|
if [ ! -L /etc/hosts ]; then
|
44
|
rm -rf /etc/hosts
|
45
|
ln -s /var/etc/hosts /etc/hosts
|
46
|
fi
|
47
|
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
|
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
|
|
56
|
if [ ! -d /cf/conf/backup/ ]; then
|
57
|
mkdir -p /cf/conf/backup/ 2>/dev/null
|
58
|
fi
|
59
|
|
60
|
set -T
|
61
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
62
|
|
63
|
# Create uploadbar tmp directory
|
64
|
mkdir -p /tmp/uploadbar
|
65
|
chmod 777 /tmp/uploadbar
|
66
|
|
67
|
# 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
|
rm -rf /var/run/*
|
72
|
rm -rf /tmp/*
|
73
|
|
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
|
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
|
|
82
|
/sbin/adjkerntz -i
|
83
|
|
84
|
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
|
85
|
if [ "$DEVFS" = "0" ]; then
|
86
|
mount_devfs devfs /dev
|
87
|
fi
|
88
|
|
89
|
echo -n "Syncing master.passwd... "
|
90
|
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
|
91
|
echo "done."
|
92
|
|
93
|
# 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
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
101
|
|
102
|
/usr/local/bin/php -f /etc/rc.conf_mount_rw
|
103
|
|
104
|
# let the PHP-based configuration subsystem set up the system now
|
105
|
/etc/rc.bootup
|
106
|
|
107
|
echo -n Starting Secure Shell Services...
|
108
|
/etc/sshd
|
109
|
|
110
|
echo -n "Starting USB... "
|
111
|
/usr/sbin/usbd 2>>/tmp/bootup_messages
|
112
|
echo "done."
|
113
|
|
114
|
/usr/sbin/cron 2>>/tmp/bootup_messages
|
115
|
|
116
|
/etc/rc.packages
|
117
|
|
118
|
echo "Executing rc.d items... "
|
119
|
for FILE in /usr/local/etc/rc.d/*.sh; do
|
120
|
echo -n " Starting ${FILE}..."
|
121
|
sh $FILE >>/tmp/bootup_messages 2>&1
|
122
|
echo "done."
|
123
|
done
|
124
|
|
125
|
if [ -f /tmp/filter_boot_dirty ]; then
|
126
|
# 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
|
|
132
|
/usr/local/bin/php -f /etc/rc.conf_mount_ro
|
133
|
|
134
|
echo "Bootup complete"
|
135
|
|
136
|
exit 0
|
137
|
|