Project

General

Profile

Download (3 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/bin/sh
2
3 e5cd29a0 Scott Ullrich
# /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 5b237745 Scott Ullrich
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
# All rights reserved.
9
10
stty status '^T'
11 2733ae78 Scott Ullrich
stty susp '^-' intr '^-' quit '^-'
12 5b237745 Scott Ullrich
13
trap : 2
14
trap : 3
15
16
HOME=/
17
PATH=/sbin:/bin:/usr/sbin:/usr/bin
18
export HOME PATH
19
20 3f38f066 Scott Ullrich
version=`cat /etc/version`
21
22 4ec1f1c7 Scott Ullrich
/sbin/conscontrol mute off
23
24 e5cd29a0 Scott Ullrich
echo
25 3f38f066 Scott Ullrich
echo "Welcome to pfSense ${version} ..."
26 e5cd29a0 Scott Ullrich
echo
27
28 2a069553 Scott Ullrich
/sbin/mount -a || fsck -y && mount -a
29 2ed803e7 Scott Ullrich
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
30 1828ab3a Scott Ullrich
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
31 e7435c3b Scott Ullrich
/sbin/swapon -a 2>/dev/null
32 f0314010 Scott Ullrich
/bin/mkdir -p /usr/savecore 2>/dev/null
33 2ed803e7 Scott Ullrich
/sbin/savecore /usr/savecore $SWAPDEVICE
34 5b237745 Scott Ullrich
35 7b2ac828 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_rw
36 f92eaec2 Scott Ullrich
37 f1cc2287 Scott Ullrich
# Repair symlinks if they are broken
38
if [ ! -L /etc/hosts ]; then
39
	rm -rf /etc/hosts
40 c8fcdb2f Scott Ullrich
	ln -s /var/etc/hosts /etc/hosts    
41
fi
42 f1cc2287 Scott Ullrich
if [ ! -L /etc/resolv.conf ]; then
43
    rm -rf /etc/resolv.conf
44
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
45
fi
46 6484bb83 Scott Ullrich
if [ ! -L /etc/dhclient.conf ]; then
47
    rm -rf /etc/dhclient.conf
48
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
49
fi
50 c8fcdb2f Scott Ullrich
51 360fb405 Scott Ullrich
if [ ! -d /cf/conf/backup/ ]; then
52
    mkdir -p /cf/conf/backup/ 2>/dev/null
53 d42c2e20 Scott Ullrich
fi
54
55 5b237745 Scott Ullrich
set -T
56
trap "echo 'Reboot interrupted'; exit 1" 3
57
58 f3677fc5 Scott Ullrich
# Create uploadbar tmp directory
59 e15f2001 Scott Ullrich
mkdir -p /tmp/uploadbar
60 f3677fc5 Scott Ullrich
chmod 777 /tmp/uploadbar
61
62 5b237745 Scott Ullrich
# make some directories in /var
63
mkdir /var/run /var/log /var/etc /var/db/ipf 2>/dev/null
64
chmod 0755 /var/db/ipf
65
rm -rf /var/log/*
66 9cb8e6f0 Scott Ullrich
rm -rf /var/run/*
67 7f0439dc Scott Ullrich
rm -rf /tmp/*
68 5b237745 Scott Ullrich
69
# generate circular logfiles
70
clog -i -s 262144 /var/log/system.log
71
clog -i -s 262144 /var/log/filter.log
72
clog -i -s 32768 /var/log/dhcpd.log
73
clog -i -s 32768 /var/log/vpn.log
74 3f2b92d2 Scott Ullrich
clog -i -s 32768 /var/log/portalauth.log
75
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log
76 5b237745 Scott Ullrich
77 40697dbf Scott Ullrich
/sbin/adjkerntz -i
78 5b237745 Scott Ullrich
79 f93c5384 Scott Ullrich
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
80
if [ "$DEVFS" = "0" ]; then
81
    mount_devfs devfs /dev
82
fi
83 5b237745 Scott Ullrich
84 fc6b5a4d Scott Ullrich
echo -n "Syncing master.passwd... "
85 e4217386 Scott Ullrich
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
86 deebaae1 Scott Ullrich
echo "done."
87 e4217386 Scott Ullrich
88 5b237745 Scott Ullrich
# Create an initial utmp file
89
cd /var/run && cp /dev/null utmp && chmod 644 utmp
90
91
# Build devices database
92
#dev_mkdb
93
94
# Run ldconfig
95 0ede09d9 Scott Ullrich
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
96 5b237745 Scott Ullrich
97 aa26bd27 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_rw
98
99 5b237745 Scott Ullrich
# let the PHP-based configuration subsystem set up the system now
100
/etc/rc.bootup
101
102 3f38f066 Scott Ullrich
echo -n Starting Secure Shell Services...
103 17b9532b Scott Ullrich
/etc/sshd
104
105 fc6b5a4d Scott Ullrich
echo -n "Starting USB... "
106 10616c2b Scott Ullrich
/usr/sbin/usbd 2>>/tmp/bootup_messages
107 fc6b5a4d Scott Ullrich
echo "done."
108 10616c2b Scott Ullrich
109
/usr/sbin/cron 2>>/tmp/bootup_messages
110 04714d83 Scott Ullrich
111 238f6962 Colin Smith
/etc/rc.packages
112 3e08b3c1 Scott Ullrich
113 fc6b5a4d Scott Ullrich
echo "Executing rc.d items... "
114 17b9532b Scott Ullrich
for FILE in /usr/local/etc/rc.d/*.sh; do
115 d53c2f85 Scott Ullrich
    echo -n " Starting ${FILE}..."
116
    sh $FILE >>/tmp/bootup_messages 2>&1
117 fc6b5a4d Scott Ullrich
    echo "done."
118 316a0dda Scott Ullrich
done
119 3bd1bd72 Scott Ullrich
120 44d21387 Scott Ullrich
if [ -f /tmp/filter_boot_dirty ]; then
121 b19c8622 Scott Ullrich
    # one more pass to give package plugins a chance to adjust
122
    echo -n "Final firewall setup in progress..."
123
    /etc/rc.filter_configure
124
    echo "Done."
125
fi
126 a1ad1bc3 Scott Ullrich
127 7b2ac828 Scott Ullrich
/usr/local/bin/php -f /etc/rc.conf_mount_ro
128 f92eaec2 Scott Ullrich
129 3f38f066 Scott Ullrich
echo "Bootup complete"
130 5b237745 Scott Ullrich
131 d35cf0de Scott Ullrich
exit 0