Project

General

Profile

Download (5.35 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
# mount /usr.uzip if it exists
17
[ -x /usr.uzip ] && [ -d /usr ] && [ ! -d /usr/local ] \
18
	&& /sbin/mount_cd9660 /dev/`/sbin/mdconfig -af /usr.uzip`.uzip /usr
19

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

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

    
27
# Set our operating platform
28
PLATFORM=`cat /etc/platform`
29

    
30
echo
31
cat /etc/ascii-art/pfsense-logo-small.txt
32
echo
33
echo
34
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
35
echo
36

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

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

    
44
# Mount /. If it fails run a fsck.
45
if [ ! "$PLATFORM" = "cdrom" ] ; then
46
    /sbin/mount -w / || /sbin/fsck -y
47
fi
48

    
49
# Check to see if a compact flash mountpoint exists
50
# If it fails to mount then run a fsck -y
51
if grep cf /etc/fstab; then
52
    /sbin/mount -w /cf || /sbin/fsck -y
53
fi
54

    
55
# Mount memory file system if it exists
56
/sbin/mount -a
57

    
58
if [ "$PLATFORM" = "cdrom" ] ; then
59
	# do nothing for cdrom platform
60
elif [ "$PLATFORM" = "embedded" ] ; then
61
    echo "No swap on ${PLATFORM}"
62
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
63
else
64
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
65

    
66
    /sbin/swapon -a 2>/dev/null
67
    
68
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
69
fi
70

    
71

    
72
# Repair symlinks if they are broken
73
if [ ! -L /etc/syslog.conf ]; then
74
	rm -rf /etc/syslog.conf
75
	ln -s /var/etc/syslog.conf /etc/syslog.conf
76
fi
77

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

    
84
if [ ! -L /etc/resolv.conf ]; then
85
    rm -rf /etc/resolv.conf
86
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
87
fi
88

    
89
# Malloc debugging check
90
if [ ! -L /etc/malloc.conf ]; then
91
    ln -s aj /etc/malloc.conf
92
fi
93

    
94
if [ ! -L /etc/dhclient.conf ]; then
95
    rm -rf /etc/dhclient.conf
96
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
97
fi
98

    
99
if [ ! -L /etc/sasyncd.conf ]; then
100
    mkdir -p /var/etc/
101
    touch /var/etc/sasyncd.conf
102
    rm -rf /etc/sasyncd.conf
103
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
104
    chown root:wheel /var/etc/sasyncd.conf
105
    chmod 0600 /var/etc/sasyncd.conf
106
fi
107

    
108
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
109

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

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

    
114
set -T
115
trap "echo 'Reboot interrupted'; exit 1" 3
116

    
117
# Create uploadbar tmp directory
118
mkdir -p /tmp/uploadbar
119
chmod 777 /tmp/uploadbar
120

    
121
# make some directories in /var
122
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
123
rm -rf /var/log/*
124
rm -rf /var/run/*
125
rm -rf /tmp/*
126

    
127
# generate circular logfiles
128
if [ ! "$PLATFORM" = "cdrom" ]; then
129
    clog -i -s 10000 /var/log/system.log
130
    clog -i -s 10000 /var/log/filter.log
131
    clog -i -s 10000 /var/log/dhcpd.log
132
    clog -i -s 10000 /var/log/vpn.log
133
    clog -i -s 10000 /var/log/portalauth.log
134
    clog -i -s 10000 /var/log/ipsec.log
135
    clog -i -s 10000 /var/log/slbd.log
136
else
137
    clog -i -s 262144 /var/log/system.log
138
    clog -i -s 262144 /var/log/filter.log
139
    clog -i -s 32768 /var/log/dhcpd.log
140
    clog -i -s 32768 /var/log/vpn.log
141
    clog -i -s 32768 /var/log/portalauth.log
142
    clog -i -s 10000 /var/log/ipsec.log
143
    clog -i -s 262144 /var/log/slbd.log
144
fi
145

    
146
# change permissions on newly created clog files.
147
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
148

    
149
/sbin/adjkerntz -i
150

    
151
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
152
if [ "$DEVFS" = "0" ]; then
153
    mount_devfs devfs /dev
154
fi
155

    
156
# Create an initial utmp file
157
cd /var/run && cp /dev/null utmp && chmod 644 utmp
158

    
159
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
160

    
161
/usr/local/bin/php -f /etc/rc.conf_mount_rw
162

    
163
# Make sure /etc/rc.conf doesn't exist.
164
if [ -f /etc/rc.conf ]; then
165
    rm -rf /etc/rc.conf
166
fi
167

    
168
echo -n "Starting USB... "
169
/usr/sbin/usbd 2>>/tmp/bootup_messages
170
/usr/local/sbin/kbdcheck
171
echo "done."
172

    
173
# let the PHP-based configuration subsystem set up the system now
174
/etc/rc.bootup
175

    
176
echo -n "Starting CRON... "
177
/usr/sbin/cron 2>>/tmp/bootup_messages
178
echo "done."
179

    
180
if [ ! "$PLATFORM" = "cdrom" ]; then
181

    
182
    echo "Syncing packages..."
183
    /etc/rc.packages 2>/dev/null
184
    
185
    echo "Executing rc.d items... "
186
    
187
    for FILE in /usr/local/etc/rc.d/*.sh; do
188
	echo -n " Starting ${FILE}..."
189
	sh $FILE start >>/tmp/bootup_messages 2>&1
190
	echo "done."
191
    done
192
fi
193

    
194
rm -rf /usr/local/pkg/pf/CVS
195

    
196
/usr/local/bin/php -f /etc/rc.conf_mount_ro
197

    
198
/usr/local/sbin/check_reload_status >/dev/null &
199

    
200
echo "Bootup complete"
201

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

    
220
/usr/local/bin/beep.sh start
221

    
222
exit 0
(24-24/64)