Project

General

Profile

Download (5.12 KB) Statistics
| Branch: | Tag: | Revision:
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 d8a2ce2c Scott Ullrich
10
#/bin/stty status '^T'
11
#/bin/stty susp '^-' intr '^-' quit '^-'
12
13
#trap : 2
14
#trap : 3
15 5b237745 Scott Ullrich
16 31849b90 Scott Ullrich
# Set our operating platform
17
PLATFORM=`cat /etc/platform`
18 c0819d14 Jeb Campbell
19 5b237745 Scott Ullrich
HOME=/
20 ce823053 Scott Ullrich
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
21 5b237745 Scott Ullrich
export HOME PATH
22
23 d4556e07 Scott Ullrich
# Set our current version
24 3f38f066 Scott Ullrich
version=`cat /etc/version`
25
26 e5cd29a0 Scott Ullrich
echo
27 25d3fbd5 Scott Ullrich
cat /etc/ascii-art/pfsense-logo-small.txt
28
echo
29 d67c6097 Scott Ullrich
echo
30
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
31
echo
32 e5cd29a0 Scott Ullrich
33 31540677 Colin Smith
if [ "$PLATFORM" = "cdrom" ]; then
34
	/etc/rc.cdrom
35
fi
36
37 16469df3 Scott Ullrich
if [ "$PLATFORM" = "embedded" ]; then
38 c613b74f Scott Ullrich
	/etc/rc.embedded
39
fi
40
41 23a115c5 Scott Ullrich
# Enable console output if its muted.
42
/sbin/conscontrol mute off >/dev/null
43
44 16469df3 Scott Ullrich
# Mount memory file system if it exists
45 ebe6a739 Scott Ullrich
echo -n "Mounting filesystems..."
46 16469df3 Scott Ullrich
/sbin/mount -a
47
48 3311566f Scott Ullrich
# Mount /. If it fails run a fsck.
49 625dda09 Scott Ullrich
if [ ! "$PLATFORM" = "cdrom" ] ; then
50 0fa30a3a Scott Ullrich
	/sbin/mount -uw / || (/sbin/fsck -y; /sbin/mount -uw /)
51 fac17748 Scott Ullrich
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 625dda09 Scott Ullrich
fi
59 fe1936d1 Scott Ullrich
60 3311566f Scott Ullrich
# Check to see if a compact flash mountpoint exists
61
# If it fails to mount then run a fsck -y
62 16469df3 Scott Ullrich
if grep -q cf /etc/fstab; then
63 faaa6942 Scott Ullrich
    /sbin/mount -uw /cf || \
64
	(/sbin/umount /cf; /sbin/fsck -y /cf; /sbin/mount -w /cf)
65 16125d1c Scott Ullrich
fi
66
67 5621d2d5 Scott Ullrich
if [ "$PLATFORM" = "cdrom" ] ; then
68
	# do nothing for cdrom platform
69
elif [ "$PLATFORM" = "embedded" ] ; then
70 c0819d14 Jeb Campbell
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
71
else
72 d8a2ce2c Scott Ullrich
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
73 5621d2d5 Scott Ullrich
74 7050e57c Scott Ullrich
    /sbin/swapon -a 2>/dev/null >/dev/null
75 d77ddc0f Scott Ullrich
    
76
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
77 98546a74 Scott Ullrich
fi
78 ebe6a739 Scott Ullrich
echo " done."
79 5621d2d5 Scott Ullrich
80 6bab150e Scott Ullrich
# Repair symlinks if they are broken
81
if [ ! -L /etc/syslog.conf ]; then
82
	rm -rf /etc/syslog.conf
83
	ln -s /var/etc/syslog.conf /etc/syslog.conf
84
fi
85
86 f1cc2287 Scott Ullrich
# Repair symlinks if they are broken
87
if [ ! -L /etc/hosts ]; then
88
	rm -rf /etc/hosts
89 c8fcdb2f Scott Ullrich
	ln -s /var/etc/hosts /etc/hosts    
90
fi
91 095d04db Scott Ullrich
92 f1cc2287 Scott Ullrich
if [ ! -L /etc/resolv.conf ]; then
93
    rm -rf /etc/resolv.conf
94
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
95
fi
96 095d04db Scott Ullrich
97 cecdf31c Scott Ullrich
# Malloc debugging check
98
if [ ! -L /etc/malloc.conf ]; then
99
    ln -s aj /etc/malloc.conf
100
fi
101
102 6484bb83 Scott Ullrich
if [ ! -L /etc/dhclient.conf ]; then
103
    rm -rf /etc/dhclient.conf
104
fi
105 c8fcdb2f Scott Ullrich
106 bfe6d078 Scott Ullrich
if [ ! -L /etc/sasyncd.conf ]; then
107 b8c835d2 Scott Ullrich
    mkdir -p /var/etc/
108 bfe6d078 Scott Ullrich
    touch /var/etc/sasyncd.conf
109
    rm -rf /etc/sasyncd.conf
110
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
111 84f68d65 Scott Ullrich
    chown root:wheel /var/etc/sasyncd.conf
112 bfe6d078 Scott Ullrich
    chmod 0600 /var/etc/sasyncd.conf
113
fi
114
115 4aa70cd8 Scott Ullrich
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
116
117 69588d92 Scott Ullrich
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
118 d42c2e20 Scott Ullrich
119 09c2529d Scott Ullrich
[ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null
120
121 5b237745 Scott Ullrich
set -T
122
trap "echo 'Reboot interrupted'; exit 1" 3
123
124 f3677fc5 Scott Ullrich
# Create uploadbar tmp directory
125 e15f2001 Scott Ullrich
mkdir -p /tmp/uploadbar
126 f3677fc5 Scott Ullrich
chmod 777 /tmp/uploadbar
127
128 5b237745 Scott Ullrich
# make some directories in /var
129 102d8912 Scott Ullrich
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
130 5b237745 Scott Ullrich
rm -rf /var/log/*
131 9cb8e6f0 Scott Ullrich
rm -rf /var/run/*
132 5b237745 Scott Ullrich
133
# generate circular logfiles
134 a7fcb832 Scott Ullrich
if [ ! "$PLATFORM" = "cdrom" ]; then
135 5e6ffad2 Scott Ullrich
    clog -i -s 10000 /var/log/system.log
136
    clog -i -s 10000 /var/log/filter.log
137
    clog -i -s 10000 /var/log/dhcpd.log
138
    clog -i -s 10000 /var/log/vpn.log
139
    clog -i -s 10000 /var/log/portalauth.log
140 7a893851 Scott Ullrich
    clog -i -s 10000 /var/log/ipsec.log
141 95a52053 Bill Marquette
    clog -i -s 10000 /var/log/slbd.log
142 a7fcb832 Scott Ullrich
else
143 0de811c7 Scott Ullrich
    clog -i -s 300144 /var/log/system.log
144 253d5e75 Scott Ullrich
    clog -i -s 512144 /var/log/filter.log
145 a7fcb832 Scott Ullrich
    clog -i -s 32768 /var/log/dhcpd.log
146
    clog -i -s 32768 /var/log/vpn.log
147
    clog -i -s 32768 /var/log/portalauth.log
148 7a893851 Scott Ullrich
    clog -i -s 10000 /var/log/ipsec.log
149 95a52053 Bill Marquette
    clog -i -s 262144 /var/log/slbd.log
150 a7fcb832 Scott Ullrich
fi
151 8d418ca9 Scott Ullrich
152
# change permissions on newly created clog files.
153 95a52053 Bill Marquette
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
154 5b237745 Scott Ullrich
155 40697dbf Scott Ullrich
/sbin/adjkerntz -i
156 5b237745 Scott Ullrich
157 f93c5384 Scott Ullrich
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
158
if [ "$DEVFS" = "0" ]; then
159
    mount_devfs devfs /dev
160
fi
161 5b237745 Scott Ullrich
162
# Create an initial utmp file
163
cd /var/run && cp /dev/null utmp && chmod 644 utmp
164
165 6fe4f291 Scott Ullrich
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
166 c268f10f Scott Ullrich
167 aa26bd27 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_rw
168
169 cdbc61b6 Scott Ullrich
# Make sure /etc/rc.conf doesn't exist.
170
if [ -f /etc/rc.conf ]; then
171
    rm -rf /etc/rc.conf
172
fi
173
174 b1ce7649 Scott Ullrich
# Launching kbdmux(4)
175
if [ -f "/dev/kbdmux0" ]; then
176
	echo "Starting Keyboard Mux Services..."
177
	kbdcontrol -k /dev/kbdmux0 < /dev/console
178
	[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
179
	[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console	
180
fi
181 fa8f44ce Scott Ullrich
182 b406ae66 Scott Ullrich
# let the PHP-based configuration subsystem set up the system now
183
/etc/rc.bootup
184
185 0c5e431d Scott Ullrich
echo -n "Starting CRON... "
186 10616c2b Scott Ullrich
/usr/sbin/cron 2>>/tmp/bootup_messages
187 0c5e431d Scott Ullrich
echo "done."
188 3e08b3c1 Scott Ullrich
189 36ced816 Scott Ullrich
if [ ! "$PLATFORM" = "cdrom" ]; then
190 0c5e431d Scott Ullrich
191
    echo "Syncing packages..."
192
    /etc/rc.packages 2>/dev/null
193
    
194 36ced816 Scott Ullrich
    echo "Executing rc.d items... "
195 0c5e431d Scott Ullrich
    
196 36ced816 Scott Ullrich
    for FILE in /usr/local/etc/rc.d/*.sh; do
197
	echo -n " Starting ${FILE}..."
198 3f43f9a6 Scott Ullrich
	sh $FILE start >>/tmp/bootup_messages 2>&1
199 36ced816 Scott Ullrich
	echo "done."
200
    done
201
fi
202 3bd1bd72 Scott Ullrich
203 58eba990 Scott Ullrich
rm -rf /usr/local/pkg/pf/CVS
204
205 7b2ac828 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_ro
206 f92eaec2 Scott Ullrich
207 3b354930 Scott Ullrich
/usr/local/sbin/check_reload_status
208 bc086d51 Scott Ullrich
209 e393a4a8 Scott Ullrich
echo "Bootup complete"
210 1ba9533c Scott Ullrich
211 e393a4a8 Scott Ullrich
/usr/local/bin/beep.sh start
212
213 d35cf0de Scott Ullrich
exit 0