Project

General

Profile

Download (4.24 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
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
28
echo
29

    
30
if [ "$PLATFORM" = "cdrom" ]; then
31
	echo "Running CDROM routines..."
32
	/etc/rc.cdrom
33
fi
34

    
35
# Enable console output if its muted.
36
/sbin/conscontrol mute off >/dev/null
37

    
38
# Mount all. If it fails run a fsck.
39
/sbin/mount -a || /sbin/fsck -y && /sbin/mount -a || /sbin/fsck -y 
40

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

    
48
    /bin/mkdir -p /usr/savecore 2>/dev/null
49
    /sbin/savecore /usr/savecore $SWAPDEVICE
50
fi
51

    
52
# Repair symlinks if they are broken
53
if [ ! -L /etc/hosts ]; then
54
	rm -rf /etc/hosts
55
	ln -s /var/etc/hosts /etc/hosts    
56
fi
57

    
58
if [ ! -L /etc/resolv.conf ]; then
59
    rm -rf /etc/resolv.conf
60
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
61
fi
62

    
63
if [ ! -L /etc/dhclient.conf ]; then
64
    rm -rf /etc/dhclient.conf
65
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
66
fi
67

    
68
if [ ! -L /etc/sasyncd.conf ]; then
69
    mkdir -p /var/etc/
70
    touch /var/etc/sasyncd.conf
71
    rm -rf /etc/sasyncd.conf
72
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
73
    chown root:wheel /var/etc/sasyncd.conf
74
    chmod 0600 /var/etc/sasyncd.conf
75
fi
76

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

    
79
set -T
80
trap "echo 'Reboot interrupted'; exit 1" 3
81

    
82
# Create uploadbar tmp directory
83
mkdir -p /tmp/uploadbar
84
chmod 777 /tmp/uploadbar
85

    
86
# make some directories in /var
87
mkdir /var/run /var/log /var/etc 2>/dev/null
88
rm -rf /var/log/*
89
rm -rf /var/run/*
90
rm -rf /tmp/*
91

    
92
# generate circular logfiles
93
if [ ! "$PLATFORM" = "cdrom" ]; then
94
    clog -i -s 10000 /var/log/system.log
95
    clog -i -s 10000 /var/log/filter.log
96
    clog -i -s 10000 /var/log/dhcpd.log
97
    clog -i -s 10000 /var/log/vpn.log
98
    clog -i -s 10000 /var/log/portalauth.log
99
else
100
    clog -i -s 262144 /var/log/system.log
101
    clog -i -s 262144 /var/log/filter.log
102
    clog -i -s 32768 /var/log/dhcpd.log
103
    clog -i -s 32768 /var/log/vpn.log
104
    clog -i -s 32768 /var/log/portalauth.log
105
fi
106

    
107
# change permissions on newly created clog files.
108
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
109

    
110
/sbin/adjkerntz -i
111

    
112
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
113
if [ "$DEVFS" = "0" ]; then
114
    mount_devfs devfs /dev
115
fi
116

    
117
echo -n "Syncing master.passwd... "
118
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
119
echo "done."
120

    
121
# Create an initial utmp file
122
cd /var/run && cp /dev/null utmp && chmod 644 utmp
123

    
124
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
125

    
126
/usr/local/bin/php -f /etc/rc.conf_mount_rw
127

    
128
# Make sure /etc/rc.conf doesn't exist.
129
if [ -f /etc/rc.conf ]; then
130
    echo "Removing /etc/rc.conf..."
131
    rm -rf /etc/rc.conf
132
fi
133

    
134
# let the PHP-based configuration subsystem set up the system now
135
/etc/rc.bootup
136

    
137
echo -n Starting Secure Shell Services...
138
/etc/sshd 2>/dev/null
139

    
140
echo -n "Starting USB... "
141
/usr/sbin/usbd 2>>/tmp/bootup_messages
142
echo "done."
143

    
144
echo -n "Starting CRON... "
145
/usr/sbin/cron 2>>/tmp/bootup_messages
146
echo "done."
147

    
148
if [ ! "$PLATFORM" = "cdrom" ]; then
149

    
150
    echo "Syncing packages..."
151
    /etc/rc.packages 2>/dev/null
152
    
153
    echo "Executing rc.d items... "
154
    
155
    for FILE in /usr/local/etc/rc.d/*.sh; do
156
	echo -n " Starting ${FILE}..."
157
	sh $FILE start >>/tmp/bootup_messages 2>&1
158
	echo "done."
159
    done
160
fi
161

    
162
if [ -f /tmp/filter_boot_dirty ]; then
163
    # one more pass to give package plugins a chance to adjust
164
    echo -n "Final firewall setup in progress..."
165
    /etc/rc.filter_configure
166
    echo "Done."
167
fi
168

    
169
rm -rf /usr/local/pkg/pf/CVS
170

    
171
/usr/local/bin/php -f /etc/rc.conf_mount_ro
172

    
173
/usr/local/sbin/check_reload_status >/dev/null &
174

    
175
echo "Bootup complete"
176

    
177
exit 0
(21-21/54)