Project

General

Profile

Download (4.75 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
HOME=/
17
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
18
export HOME PATH
19

    
20
# Set our current version
21
version=`cat /etc/version`
22

    
23
# Set our operating platform
24
PLATFORM=`cat /etc/platform`
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
	echo "Running CDROM routines..."
35
	/etc/rc.cdrom
36
fi
37

    
38
# Enable console output if its muted.
39
/sbin/conscontrol mute off >/dev/null
40

    
41
# Mount all. If it fails run a fsck.
42
/sbin/mount -a || /sbin/fsck -y && /sbin/mount -a || /sbin/fsck -y 
43

    
44
if [ ! "$PLATFORM" = "cdrom" ]; then
45
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
46
    /sbin/dumpon -v $SWAPDEVICE 2>/dev/null
47
    /sbin/swapon -a 2>/dev/null
48
    
49
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
50

    
51
    /bin/mkdir -p /usr/savecore 2>/dev/null
52
    /sbin/savecore /usr/savecore $SWAPDEVICE
53
fi
54

    
55
# Repair symlinks if they are broken
56
if [ ! -L /etc/syslog.conf ]; then
57
	rm -rf /etc/syslog.conf
58
	ln -s /var/etc/syslog.conf /etc/syslog.conf
59
fi
60

    
61
# Repair symlinks if they are broken
62
if [ ! -L /etc/hosts ]; then
63
	rm -rf /etc/hosts
64
	ln -s /var/etc/hosts /etc/hosts    
65
fi
66

    
67
if [ ! -L /etc/resolv.conf ]; then
68
    rm -rf /etc/resolv.conf
69
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
70
fi
71

    
72
# Malloc debugging check
73
if [ ! -L /etc/malloc.conf ]; then
74
    ln -s aj /etc/malloc.conf
75
fi
76

    
77
if [ ! -L /etc/dhclient.conf ]; then
78
    rm -rf /etc/dhclient.conf
79
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
80
fi
81

    
82
if [ ! -L /etc/sasyncd.conf ]; then
83
    mkdir -p /var/etc/
84
    touch /var/etc/sasyncd.conf
85
    rm -rf /etc/sasyncd.conf
86
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
87
    chown root:wheel /var/etc/sasyncd.conf
88
    chmod 0600 /var/etc/sasyncd.conf
89
fi
90

    
91
[ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null
92

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

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

    
97
set -T
98
trap "echo 'Reboot interrupted'; exit 1" 3
99

    
100
# Create uploadbar tmp directory
101
mkdir -p /tmp/uploadbar
102
chmod 777 /tmp/uploadbar
103

    
104
# make some directories in /var
105
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
106
rm -rf /var/log/*
107
rm -rf /var/run/*
108
rm -rf /tmp/*
109

    
110
# generate circular logfiles
111
if [ ! "$PLATFORM" = "cdrom" ]; then
112
    clog -i -s 10000 /var/log/system.log
113
    clog -i -s 10000 /var/log/filter.log
114
    clog -i -s 10000 /var/log/dhcpd.log
115
    clog -i -s 10000 /var/log/vpn.log
116
    clog -i -s 10000 /var/log/portalauth.log
117
    clog -i -s 10000 /var/log/ipsec.log
118
    clog -i -s 10000 /var/log/slbd.log
119
else
120
    clog -i -s 262144 /var/log/system.log
121
    clog -i -s 262144 /var/log/filter.log
122
    clog -i -s 32768 /var/log/dhcpd.log
123
    clog -i -s 32768 /var/log/vpn.log
124
    clog -i -s 32768 /var/log/portalauth.log
125
    clog -i -s 10000 /var/log/ipsec.log
126
    clog -i -s 262144 /var/log/slbd.log
127
fi
128

    
129
# change permissions on newly created clog files.
130
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
131

    
132
/sbin/adjkerntz -i
133

    
134
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
135
if [ "$DEVFS" = "0" ]; then
136
    mount_devfs devfs /dev
137
fi
138

    
139
echo -n "Syncing master.passwd... "
140
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
141
/usr/sbin/pwd_mkdb /etc/master.passwd
142
echo "done."
143

    
144
# Create an initial utmp file
145
cd /var/run && cp /dev/null utmp && chmod 644 utmp
146

    
147
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
148

    
149
/usr/local/bin/php -f /etc/rc.conf_mount_rw
150

    
151
# Make sure /etc/rc.conf doesn't exist.
152
if [ -f /etc/rc.conf ]; then
153
    echo "Removing /etc/rc.conf..."
154
    rm -rf /etc/rc.conf
155
fi
156

    
157
echo -n "Starting USB... "
158
/usr/sbin/usbd 2>>/tmp/bootup_messages
159
/usr/local/sbin/kbdcheck
160
echo "done."
161

    
162
# let the PHP-based configuration subsystem set up the system now
163
/etc/rc.bootup
164

    
165
echo -n Starting Secure Shell Services...
166
/etc/sshd 2>/dev/null
167
echo "done."
168

    
169
echo -n "Starting CRON... "
170
/usr/sbin/cron 2>>/tmp/bootup_messages
171
echo "done."
172

    
173
if [ ! "$PLATFORM" = "cdrom" ]; then
174

    
175
    echo "Syncing packages..."
176
    /etc/rc.packages 2>/dev/null
177
    
178
    echo "Executing rc.d items... "
179
    
180
    for FILE in /usr/local/etc/rc.d/*.sh; do
181
	echo -n " Starting ${FILE}..."
182
	sh $FILE start >>/tmp/bootup_messages 2>&1
183
	echo "done."
184
    done
185
fi
186

    
187
rm -rf /usr/local/pkg/pf/CVS
188

    
189
/usr/local/bin/php -f /etc/rc.conf_mount_ro
190

    
191
/usr/local/sbin/check_reload_status >/dev/null &
192

    
193
echo "Bootup complete"
194

    
195
exit 0
(22-22/59)