Project

General

Profile

Download (3 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
stty status '^T'
11
stty susp '^-' intr '^-' quit '^-'
12

    
13
trap : 2
14
trap : 3
15

    
16
HOME=/
17
PATH=/sbin:/bin:/usr/sbin:/usr/bin
18
export HOME PATH
19

    
20
version=`cat /etc/version`
21

    
22
/sbin/conscontrol mute off
23

    
24
echo
25
echo "Welcome to pfSense ${version} ..."
26
echo
27

    
28
/sbin/mount -a || fsck -y && mount -a
29
SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
30
/sbin/dumpon -v $SWAPDEVICE 2>/dev/null
31
/sbin/swapon -a 2>/dev/null
32
/bin/mkdir -p /usr/savecore 2>/dev/null
33
/sbin/savecore /usr/savecore $SWAPDEVICE
34

    
35
/usr/local/bin/php -f /etc/rc.conf_mount_rw
36

    
37
# Repair symlinks if they are broken
38
if [ ! -L /etc/hosts ]; then
39
	rm -rf /etc/hosts
40
	ln -s /var/etc/hosts /etc/hosts    
41
fi
42
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
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

    
51
if [ ! -d /cf/conf/backup/ ]; then
52
    mkdir -p /cf/conf/backup/ 2>/dev/null
53
fi
54

    
55
set -T
56
trap "echo 'Reboot interrupted'; exit 1" 3
57

    
58
# Create uploadbar tmp directory
59
mkdir -p /tmp/uploadbar
60
chmod 777 /tmp/uploadbar
61

    
62
# 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
rm -rf /var/run/*
67
rm -rf /tmp/*
68

    
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
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

    
77
/sbin/adjkerntz -i
78

    
79
DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8`
80
if [ "$DEVFS" = "0" ]; then
81
    mount_devfs devfs /dev
82
fi
83

    
84
echo -n "Syncing master.passwd... "
85
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
86
echo "done."
87

    
88
# 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
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
96

    
97
/usr/local/bin/php -f /etc/rc.conf_mount_rw
98

    
99
# let the PHP-based configuration subsystem set up the system now
100
/etc/rc.bootup
101

    
102
echo -n Starting Secure Shell Services...
103
/etc/sshd
104

    
105
echo -n "Starting USB... "
106
/usr/sbin/usbd 2>>/tmp/bootup_messages
107
echo "done."
108

    
109
/usr/sbin/cron 2>>/tmp/bootup_messages
110

    
111
/etc/rc.packages
112

    
113
echo "Executing rc.d items... "
114
for FILE in /usr/local/etc/rc.d/*.sh; do
115
    echo -n " Starting ${FILE}..."
116
    sh $FILE >>/tmp/bootup_messages 2>&1
117
    echo "done."
118
done
119

    
120
if [ -f /tmp/filter_boot_dirty ]; then
121
    # 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

    
127
/usr/local/bin/php -f /etc/rc.conf_mount_ro
128

    
129
echo "Bootup complete"
130

    
131
exit 0
132

    
(20-20/52)