Project

General

Profile

Download (4.34 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
# Malloc debugging check
64
if [ ! -L /etc/malloc.conf ]; then
65
    ln -s aj /etc/malloc.conf
66
fi
67

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

    
73
if [ ! -L /etc/sasyncd.conf ]; then
74
    mkdir -p /var/etc/
75
    touch /var/etc/sasyncd.conf
76
    rm -rf /etc/sasyncd.conf
77
    ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf
78
    chown root:wheel /var/etc/sasyncd.conf
79
    chmod 0600 /var/etc/sasyncd.conf
80
fi
81

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

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

    
86
set -T
87
trap "echo 'Reboot interrupted'; exit 1" 3
88

    
89
# Create uploadbar tmp directory
90
mkdir -p /tmp/uploadbar
91
chmod 777 /tmp/uploadbar
92

    
93
# make some directories in /var
94
mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null
95
rm -rf /var/log/*
96
rm -rf /var/run/*
97
rm -rf /tmp/*
98

    
99
# generate circular logfiles
100
if [ ! "$PLATFORM" = "cdrom" ]; then
101
    clog -i -s 10000 /var/log/system.log
102
    clog -i -s 10000 /var/log/filter.log
103
    clog -i -s 10000 /var/log/dhcpd.log
104
    clog -i -s 10000 /var/log/vpn.log
105
    clog -i -s 10000 /var/log/portalauth.log
106
    clog -i -s 10000 /var/log/ipsec.log
107
else
108
    clog -i -s 262144 /var/log/system.log
109
    clog -i -s 262144 /var/log/filter.log
110
    clog -i -s 32768 /var/log/dhcpd.log
111
    clog -i -s 32768 /var/log/vpn.log
112
    clog -i -s 32768 /var/log/portalauth.log
113
    clog -i -s 10000 /var/log/ipsec.log
114
fi
115

    
116
# change permissions on newly created clog files.
117
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
118

    
119
/sbin/adjkerntz -i
120

    
121
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
122
if [ "$DEVFS" = "0" ]; then
123
    mount_devfs devfs /dev
124
fi
125

    
126
echo -n "Syncing master.passwd... "
127
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
128
echo "done."
129

    
130
# Create an initial utmp file
131
cd /var/run && cp /dev/null utmp && chmod 644 utmp
132

    
133
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
134

    
135
/usr/local/bin/php -f /etc/rc.conf_mount_rw
136

    
137
# Make sure /etc/rc.conf doesn't exist.
138
if [ -f /etc/rc.conf ]; then
139
    echo "Removing /etc/rc.conf..."
140
    rm -rf /etc/rc.conf
141
fi
142

    
143
# let the PHP-based configuration subsystem set up the system now
144
/etc/rc.bootup
145

    
146
echo -n Starting Secure Shell Services...
147
/etc/sshd 2>/dev/null
148

    
149
echo -n "Starting USB... "
150
/usr/sbin/usbd 2>>/tmp/bootup_messages
151
echo "done."
152

    
153
echo -n "Starting CRON... "
154
/usr/sbin/cron 2>>/tmp/bootup_messages
155
echo "done."
156

    
157
if [ ! "$PLATFORM" = "cdrom" ]; then
158

    
159
    echo "Syncing packages..."
160
    /etc/rc.packages 2>/dev/null
161
    
162
    echo "Executing rc.d items... "
163
    
164
    for FILE in /usr/local/etc/rc.d/*.sh; do
165
	echo -n " Starting ${FILE}..."
166
	sh $FILE start >>/tmp/bootup_messages 2>&1
167
	echo "done."
168
    done
169
fi
170

    
171
rm -rf /usr/local/pkg/pf/CVS
172

    
173
/usr/local/bin/php -f /etc/rc.conf_mount_ro
174

    
175
/usr/local/sbin/check_reload_status >/dev/null &
176

    
177
echo "Bootup complete"
178

    
179
exit 0
(21-21/56)