summaryrefslogtreecommitdiffstats
path: root/etc/rc
blob: 325c2a89a2a37d06b7eaf0f7c655319c08ddc34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/sh

# /etc/rc - master bootup script, invokes php setup
# part of pfSense by Scott Ullrich
# Copyright (C) 2004 Scott Ullrich, All rights reserved.
# originally based on m0n0wall (http://neon1.net/m0n0wall)
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
# All rights reserved.

/bin/stty status '^T'
/bin/stty susp '^-' intr '^-' quit '^-'

trap : 2
trap : 3

HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
export HOME PATH

# Set our current version
version=`cat /etc/version`

# Set our operating platform
PLATFORM=`cat /etc/platform`

if [ "$PLATFORM" = "cdrom" ]; then
    /etc/rc.d/freesbie_1st
    /rescue/ln -s /FreeSBIE/cf /cf
    /bin/sh /scripts/pfi start
fi

echo
echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
echo

/sbin/mount -a || fsck -y && mount -a
if [ ! "$PLATFORM" = "cdrom" ]; then
    SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1`
    /sbin/dumpon -v $SWAPDEVICE 2>/dev/null
    /sbin/swapon -a 2>/dev/null
    
    /usr/local/bin/php -f /etc/rc.conf_mount_rw
fi

/sbin/conscontrol mute off

if [ ! "$PLATFORM" = "cdrom" ]; then
    /bin/mkdir -p /usr/savecore 2>/dev/null
    /sbin/savecore /usr/savecore $SWAPDEVICE
fi

# Repair symlinks if they are broken
if [ ! -L /etc/hosts ]; then
	rm -rf /etc/hosts
	ln -s /var/etc/hosts /etc/hosts    
fi

if [ ! -L /etc/resolv.conf ]; then
    rm -rf /etc/resolv.conf
    ln -s /var/etc/resolv.conf /etc/resolv.conf    
fi

if [ ! -L /etc/dhclient.conf ]; then
    rm -rf /etc/dhclient.conf
    ln -s /var/etc/dhclient.conf /etc/dhclient.conf
fi

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

if [ "$PLATFORM" = "cdrom" ]; then
    [ ! -L /conf ] || ln -s /cf/conf /conf
    [ ! -f /cf/conf/config.xml ] || cp /FreeSBIE/cf/conf/config.xml /cf/conf/
    [ ! -f /cf/conf/ez-ipupdate.cache ] || cp /FreeSBIE/cf/conf/ez-ipupdate.cache /cf/conf/
    mkdir /var/db/
fi

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

# Create uploadbar tmp directory
mkdir -p /tmp/uploadbar
chmod 777 /tmp/uploadbar

# make some directories in /var
mkdir /var/run /var/log /var/etc 2>/dev/null
rm -rf /var/log/*
rm -rf /var/run/*
rm -rf /tmp/*

# generate circular logfiles
clog -i -s 262144 /var/log/system.log
clog -i -s 262144 /var/log/filter.log
clog -i -s 32768 /var/log/dhcpd.log
clog -i -s 32768 /var/log/vpn.log
clog -i -s 32768 /var/log/portalauth.log
chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log

/sbin/adjkerntz -i

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

echo -n "Syncing master.passwd... "
/usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd
echo "done."

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

if [ ! "$PLATFORM" = "cdrom" ]; then
    # Run ldconfig
    /sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
fi

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

exit

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

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

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

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

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

    echo "Syncing packages..."
    /etc/rc.packages 2>/dev/null
    
    echo "Executing rc.d items... "
    
    for FILE in /usr/local/etc/rc.d/*.sh; do
	echo -n " Starting ${FILE}..."
	sh $FILE >>/tmp/bootup_messages 2>&1
	echo "done."
    done
fi

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

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

echo "Bootup complete"

exit 0

OpenPOWER on IntegriCloud