Project

General

Profile

Download (5.54 KB) Statistics
| Branch: | Tag: | Revision:
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
# Set our operating platform
17
PLATFORM=`cat /etc/platform`
18

    
19
HOME=/
20
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
21
export HOME PATH
22

    
23
# Set our current version
24
version=`cat /etc/version`
25

    
26
echo
27
cat /etc/ascii-art/pfsense-logo-small.txt
28
echo
29
echo
30
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
31
echo
32

    
33
if [ "$PLATFORM" = "cdrom" ]; then
34
	/etc/rc.cdrom
35
fi
36

    
37
if [ "$PLATFORM" = "embedded" ]; then
38
	/etc/rc.embedded
39
fi
40

    
41
# Enable console output if its muted.
42
/sbin/conscontrol mute off >/dev/null
43

    
44
# Mount memory file system if it exists
45
echo -n "Mounting filesystems..."
46
/sbin/mount -a
47

    
48
# Mount /. If it fails run a fsck.
49
if [ ! "$PLATFORM" = "cdrom" ] ; then
50
	/sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /)
51

    
52
	# If /conf is a directory, convert it to a symlink
53
	# to /cf/conf
54
	if [ -d "/conf" ]; then
55
		rm -rf /conf
56
		ln -s /cf/conf /conf
57
	fi
58
fi
59

    
60
# Check to see if a compact flash mountpoint exists
61
# If it fails to mount then run a fsck -fy
62
if grep -q cf /etc/fstab; then
63
    /sbin/mount -uw /cf || \
64
	(/sbin/umount /cf; /sbin/fsck -fy /cf; /sbin/mount -w /cf)
65
fi
66

    
67
if [ "$PLATFORM" = "cdrom" ] ; then
68
	# do nothing for cdrom platform
69
elif [ "$PLATFORM" = "embedded" ] ; then
70
    # do nothing for embedded platform
71
else
72
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
73
    /sbin/swapon -a 2>/dev/null >/dev/null
74
fi
75
echo " done."
76

    
77
echo -n "Creating symlinks..."
78
# Make sure symlink is correct on embedded
79
if [ "$PLATFORM" = "embedded" ] ; then
80
	rm /conf
81
	ln -s /cf/conf/ /conf
82
fi
83

    
84
# Repair symlinks if they are broken
85
if [ ! -L /etc/syslog.conf ]; then
86
	rm -rf /etc/syslog.conf
87
	ln -s /var/etc/syslog.conf /etc/syslog.conf
88
fi
89

    
90
# Repair symlinks if they are broken
91
if [ ! -L /etc/hosts ]; then
92
	rm -rf /etc/hosts
93
	ln -s /var/etc/hosts /etc/hosts
94
fi
95

    
96
if [ ! -L /etc/resolv.conf ]; then
97
    rm -rf /etc/resolv.conf
98
    ln -s /var/etc/resolv.conf /etc/resolv.conf
99
fi
100

    
101
# Malloc debugging check
102
if [ ! -L /etc/malloc.conf ]; then
103
    ln -s aj /etc/malloc.conf
104
fi
105

    
106
if [ ! -L /etc/dhclient.conf ]; then
107
    rm -rf /etc/dhclient.conf
108
fi
109

    
110
if [ ! -L /etc/sasyncd.conf ]; then
111
    mkdir -p /var/etc/
112
    touch /var/etc/sasyncd.conf
113
    rm -rf /etc/sasyncd.conf
114
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
115
    chown root:wheel /var/etc/sasyncd.conf
116
    chmod 0600 /var/etc/sasyncd.conf
117
fi
118

    
119
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
120

    
121
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
122

    
123
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
124

    
125
set -T
126
trap "echo 'Reboot interrupted'; exit 1" 3
127

    
128
# Remove old nameserver resolution files
129
rm -f /var/etc/nameserver*
130

    
131
# Create uploadbar tmp directory
132
mkdir -p /tmp/uploadbar
133
chmod 777 /tmp/uploadbar
134

    
135
# make some directories in /var
136
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
137
rm -rf /var/log/*
138
rm -rf /var/run/*
139

    
140
echo -n "."
141
# generate circular logfiles
142
if [ ! "$PLATFORM" = "cdrom" ]; then
143
	clog -i -s 512144 /var/log/system.log
144
	clog -i -s 512144 /var/log/filter.log
145
	clog -i -s 65535 /var/log/dhcpd.log
146
	clog -i -s 65535 /var/log/vpn.log
147
	clog -i -s 65535 /var/log/openvpn.log
148
	clog -i -s 65535 /var/log/portalauth.log
149
	clog -i -s 65535 /var/log/ipsec.log
150
	clog -i -s 65535 /var/log/slbd.log
151
	clog -i -s 65535 /var/log/lighttpd.log
152
	clog -i -s 65535 /var/log/ntpd.log
153
else
154
    clog -i -s 65535 /var/log/system.log
155
    clog -i -s 65535 /var/log/filter.log
156
    clog -i -s 65535 /var/log/dhcpd.log
157
    clog -i -s 65535 /var/log/vpn.log
158
	clog -i -s 65535 /var/log/openvpn.log
159
    clog -i -s 65535 /var/log/portalauth.log
160
    clog -i -s 65535 /var/log/ipsec.log
161
    clog -i -s 65535 /var/log/slbd.log
162
	clog -i -s 65535 /var/log/ntpd.log
163
fi
164

    
165
# change permissions on newly created clog files.
166
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
167

    
168
echo -n "."
169
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
170
if [ "$DEVFS" = "0" ]; then
171
    mount_devfs devfs /dev
172
fi
173

    
174
# Create an initial utmp file
175
cd /var/run && cp /dev/null utmp && chmod 644 utmp
176

    
177
echo -n "."
178
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
179

    
180
# Make sure /etc/rc.conf doesn't exist.
181
if [ -f /etc/rc.conf ]; then
182
    rm -rf /etc/rc.conf
183
fi
184

    
185
# Launching kbdmux(4)
186
if [ -f "/dev/kbdmux0" ]; then
187
	echo -n "."
188
	kbdcontrol -k /dev/kbdmux0 < /dev/console
189
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
190
	[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
191
fi
192

    
193
# Fire up unionfs if mount points exist.
194
if [ -f /dist/uniondirs ]; then
195
	echo -n "."
196
	/etc/rc.d/unionfs start
197
fi
198

    
199
echo "done."
200

    
201
# let the PHP-based configuration subsystem set up the system now
202
echo -n "Launching PHP init system..."
203
/etc/rc.bootup
204

    
205
echo -n "Starting CRON... "
206
cd /tmp && /usr/sbin/cron -s
207
echo "done."
208

    
209
# Start packages
210
/etc/rc.start_packages
211

    
212
rm -rf /usr/local/pkg/pf/CVS
213

    
214
/usr/local/bin/php -f /etc/rc.conf_mount_ro
215

    
216
# Remove stale files that have already been processed by bootup
217
# scripts
218
rm -f /tmp/filter_dirty
219
rm -f /tmp/rc.linkup
220
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status 2>/dev/null
221

    
222
# Start ping handler for every 240 seconds
223
minicron 240 /var/run/ping_hosts.pid /etc/ping_hosts.sh
224

    
225
echo "Bootup complete"
226

    
227
/usr/local/bin/beep.sh start 2>&1 >/dev/null
228

    
229
exit 0
(24-24/76)