Project

General

Profile

Download (5.43 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
/sbin/mount -a
46

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

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

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

    
65
if [ "$PLATFORM" = "cdrom" ] ; then
66
	# do nothing for cdrom platform
67
elif [ "$PLATFORM" = "embedded" ] ; then
68
    echo "No swap on ${PLATFORM}"
69
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
70
else
71
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
72

    
73
    /sbin/swapon -a 2>/dev/null
74
    
75
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
76
fi
77

    
78

    
79
# Repair symlinks if they are broken
80
if [ ! -L /etc/syslog.conf ]; then
81
	rm -rf /etc/syslog.conf
82
	ln -s /var/etc/syslog.conf /etc/syslog.conf
83
fi
84

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

    
91
if [ ! -L /etc/resolv.conf ]; then
92
    rm -rf /etc/resolv.conf
93
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
94
fi
95

    
96
# Malloc debugging check
97
if [ ! -L /etc/malloc.conf ]; then
98
    ln -s aj /etc/malloc.conf
99
fi
100

    
101
if [ ! -L /etc/dhclient.conf ]; then
102
    rm -rf /etc/dhclient.conf
103
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
104
fi
105

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

    
115
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
116

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

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

    
121
set -T
122
trap "echo 'Reboot interrupted'; exit 1" 3
123

    
124
# Create uploadbar tmp directory
125
mkdir -p /tmp/uploadbar
126
chmod 777 /tmp/uploadbar
127

    
128
# make some directories in /var
129
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
130
rm -rf /var/log/*
131
rm -rf /var/run/*
132
rm -rf /tmp/*
133

    
134
# generate circular logfiles
135
if [ ! "$PLATFORM" = "cdrom" ]; then
136
    clog -i -s 10000 /var/log/system.log
137
    clog -i -s 10000 /var/log/filter.log
138
    clog -i -s 10000 /var/log/dhcpd.log
139
    clog -i -s 10000 /var/log/vpn.log
140
    clog -i -s 10000 /var/log/portalauth.log
141
    clog -i -s 10000 /var/log/ipsec.log
142
    clog -i -s 10000 /var/log/slbd.log
143
else
144
    clog -i -s 262144 /var/log/system.log
145
    clog -i -s 262144 /var/log/filter.log
146
    clog -i -s 32768 /var/log/dhcpd.log
147
    clog -i -s 32768 /var/log/vpn.log
148
    clog -i -s 32768 /var/log/portalauth.log
149
    clog -i -s 10000 /var/log/ipsec.log
150
    clog -i -s 262144 /var/log/slbd.log
151
fi
152

    
153
# change permissions on newly created clog files.
154
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
155

    
156
/sbin/adjkerntz -i
157

    
158
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
159
if [ "$DEVFS" = "0" ]; then
160
    mount_devfs devfs /dev
161
fi
162

    
163
# Create an initial utmp file
164
cd /var/run && cp /dev/null utmp && chmod 644 utmp
165

    
166
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
167

    
168
/usr/local/bin/php -f /etc/rc.conf_mount_rw
169

    
170
# Make sure /etc/rc.conf doesn't exist.
171
if [ -f /etc/rc.conf ]; then
172
    rm -rf /etc/rc.conf
173
fi
174

    
175
echo -n "Starting USB... "
176
/usr/sbin/usbd 2>>/tmp/bootup_messages
177
/usr/local/sbin/kbdcheck
178
echo "done."
179

    
180
# let the PHP-based configuration subsystem set up the system now
181
/etc/rc.bootup
182

    
183
echo -n "Starting CRON... "
184
/usr/sbin/cron 2>>/tmp/bootup_messages
185
echo "done."
186

    
187
if [ ! "$PLATFORM" = "cdrom" ]; then
188

    
189
    echo "Syncing packages..."
190
    /etc/rc.packages 2>/dev/null
191
    
192
    echo "Executing rc.d items... "
193
    
194
    for FILE in /usr/local/etc/rc.d/*.sh; do
195
	echo -n " Starting ${FILE}..."
196
	sh $FILE start >>/tmp/bootup_messages 2>&1
197
	echo "done."
198
    done
199
fi
200

    
201
rm -rf /usr/local/pkg/pf/CVS
202

    
203
/usr/local/bin/php -f /etc/rc.conf_mount_ro
204

    
205
/usr/local/sbin/check_reload_status >/dev/null &
206

    
207
echo "Bootup complete"
208

    
209
if [ -e /dev/ttyv1 ]; then
210
    if [ ! -e /var/etc/console_lockdown ]; then
211
	# Allow VTY switching
212
	/usr/sbin/vidcontrol -S on 2>/dev/null
213
	# Turn off bloody mouse pointer.
214
	/usr/sbin/vidcontrol -m off	 2>/dev/null
215
	env TERM=cons25 sh -c /etc/rc.initial 2>/dev/ttyv1 </dev/ttyv1 >/dev/ttyv1 &
216
	sleep 1
217
	/usr/sbin/vidcontrol -s 2 2>/dev/null
218
    fi
219
else
220
    while [ 1 ];
221
    do
222
	env TERM=cons25 sh -c "/etc/rc.initial"
223
    done
224
    exit
225
fi
226

    
227
/usr/local/bin/beep.sh start
228

    
229
exit 0
(24-24/65)