Project

General

Profile

Download (3.89 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
[ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null
69

    
70
set -T
71
trap "echo 'Reboot interrupted'; exit 1" 3
72

    
73
# Create uploadbar tmp directory
74
mkdir -p /tmp/uploadbar
75
chmod 777 /tmp/uploadbar
76

    
77
# make some directories in /var
78
mkdir /var/run /var/log /var/etc 2>/dev/null
79
rm -rf /var/log/*
80
rm -rf /var/run/*
81
rm -rf /tmp/*
82

    
83
# generate circular logfiles
84
if [ ! "$PLATFORM" = "cdrom" ]; then
85
    clog -i -s 1000 /var/log/system.log
86
    clog -i -s 1000 /var/log/filter.log
87
    clog -i -s 1000 /var/log/dhcpd.log
88
    clog -i -s 1000 /var/log/vpn.log
89
    clog -i -s 1000 /var/log/portalauth.log
90
else
91
    clog -i -s 262144 /var/log/system.log
92
    clog -i -s 262144 /var/log/filter.log
93
    clog -i -s 32768 /var/log/dhcpd.log
94
    clog -i -s 32768 /var/log/vpn.log
95
    clog -i -s 32768 /var/log/portalauth.log
96
fi
97
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
98

    
99
/sbin/adjkerntz -i
100

    
101
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
102
if [ "$DEVFS" = "0" ]; then
103
    mount_devfs devfs /dev
104
fi
105

    
106
echo -n "Syncing master.passwd... "
107
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
108
echo "done."
109

    
110
# Create an initial utmp file
111
cd /var/run && cp /dev/null utmp && chmod 644 utmp
112

    
113
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
114

    
115
/usr/local/bin/php -f /etc/rc.conf_mount_rw
116

    
117
# Make sure /etc/rc.conf doesn't exist.
118
if [ -f /etc/rc.conf ]; then
119
    echo "Removing /etc/rc.conf..."
120
    rm -rf /etc/rc.conf
121
fi
122

    
123
# let the PHP-based configuration subsystem set up the system now
124
/etc/rc.bootup
125

    
126
echo -n Starting Secure Shell Services...
127
/etc/sshd 2>/dev/null
128

    
129
echo -n "Starting USB... "
130
/usr/sbin/usbd 2>>/tmp/bootup_messages
131
echo "done."
132

    
133
echo -n "Starting CRON... "
134
/usr/sbin/cron 2>>/tmp/bootup_messages
135
echo "done."
136

    
137
if [ ! "$PLATFORM" = "cdrom" ]; then
138

    
139
    echo "Syncing packages..."
140
    /etc/rc.packages 2>/dev/null
141
    
142
    echo "Executing rc.d items... "
143
    
144
    for FILE in /usr/local/etc/rc.d/*.sh; do
145
	echo -n " Starting ${FILE}..."
146
	sh $FILE start >>/tmp/bootup_messages 2>&1
147
	echo "done."
148
    done
149
fi
150

    
151
if [ -f /tmp/filter_boot_dirty ]; then
152
    # one more pass to give package plugins a chance to adjust
153
    echo -n "Final firewall setup in progress..."
154
    /etc/rc.filter_configure
155
    echo "Done."
156
fi
157

    
158
rm -rf /usr/local/pkg/pf/CVS
159

    
160
/usr/local/bin/php -f /etc/rc.conf_mount_ro
161

    
162
echo "Bootup complete"
163

    
164
exit 0
(21-21/54)