1 |
5b237745
|
Scott Ullrich
|
#!/bin/sh
|
2 |
|
|
|
3 |
3b6a207d
|
Scott Ullrich
|
# $Id$
|
4 |
|
|
|
5 |
e5cd29a0
|
Scott Ullrich
|
# /etc/rc - master bootup script, invokes php setup
|
6 |
|
|
# part of pfSense by Scott Ullrich
|
7 |
8ad39798
|
Scott Ullrich
|
# Copyright (C) 2004-2010 Scott Ullrich, All rights reserved.
|
8 |
e5cd29a0
|
Scott Ullrich
|
# originally based on m0n0wall (http://neon1.net/m0n0wall)
|
9 |
5b237745
|
Scott Ullrich
|
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
# All rights reserved.
|
11 |
d8a2ce2c
|
Scott Ullrich
|
|
12 |
|
|
#/bin/stty status '^T'
|
13 |
|
|
#/bin/stty susp '^-' intr '^-' quit '^-'
|
14 |
|
|
|
15 |
|
|
#trap : 2
|
16 |
|
|
#trap : 3
|
17 |
5b237745
|
Scott Ullrich
|
|
18 |
|
|
HOME=/
|
19 |
ce823053
|
Scott Ullrich
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
20 |
5b237745
|
Scott Ullrich
|
export HOME PATH
|
21 |
|
|
|
22 |
1c44a77d
|
Scott Ullrich
|
# Set our operating platform
|
23 |
e8d0903d
|
Ermal
|
PLATFORM=`/bin/cat /etc/platform`
|
24 |
1c44a77d
|
Scott Ullrich
|
|
25 |
842878b5
|
Scott Ullrich
|
# Set our current version
|
26 |
e8d0903d
|
Ermal
|
version=`/bin/cat /etc/version`
|
27 |
842878b5
|
Scott Ullrich
|
|
28 |
e4121dde
|
Renato Botelho
|
# Read product_name from $g, defaults to pfSense
|
29 |
|
|
# Use php -n here because we are not ready to load extensions yet
|
30 |
|
|
product=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var product_name pfSense)
|
31 |
c580e34c
|
Renato Botelho
|
|
32 |
e5323cca
|
jim-p
|
# Setup dumpdev/ddb/savecore"
|
33 |
|
|
echo "Configuring crash dumps..."
|
34 |
c580e34c
|
Renato Botelho
|
if [ "$PLATFORM" = "${product}" ]; then
|
35 |
e5323cca
|
jim-p
|
/etc/rc.dumpon
|
36 |
|
|
fi
|
37 |
|
|
|
38 |
6346f188
|
jim-p
|
# Setup ddb on all platforms. On full install it will save the dump, on NanoBSD it will print to console and auto-reboot.
|
39 |
|
|
if [ ! -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
|
40 |
|
|
/sbin/ddb /etc/ddb.conf
|
41 |
|
|
fi
|
42 |
|
|
|
43 |
990fa101
|
jim-p
|
if [ -e /root/force_fsck ]; then
|
44 |
f2e36920
|
Ermal LUÇI
|
echo "Forcing filesystem(s) check..."
|
45 |
|
|
/sbin/fsck -y -F -t ufs
|
46 |
302c005e
|
Ermal
|
fi
|
47 |
|
|
|
48 |
09f65382
|
Renato Botelho
|
if [ "${PLATFORM}" != "cdrom" ]; then
|
49 |
7fd93993
|
Ermal LUÇI
|
/sbin/fsck -p -F
|
50 |
|
|
FSCK_ACTION_NEEDED=0
|
51 |
|
|
case $? in
|
52 |
|
|
0)
|
53 |
|
|
echo "Filesystems are clean, continuing..."
|
54 |
|
|
echo "Mounting filesystems..."
|
55 |
|
|
;;
|
56 |
|
|
8)
|
57 |
|
|
echo "Preen mode recommended running a check that will be performed now."
|
58 |
|
|
FSCK_ACTION_NEEDED=1
|
59 |
|
|
;;
|
60 |
|
|
*)
|
61 |
235962c0
|
Phil Davis
|
echo "Stopping boot is recommended because filesystem manual action is needed, nevertheless automated repair of the filesystem will be attempted."
|
62 |
7fd93993
|
Ermal LUÇI
|
FSCK_ACTION_NEEDED=1
|
63 |
|
|
;;
|
64 |
|
|
esac
|
65 |
|
|
|
66 |
|
|
if [ ${FSCK_ACTION_NEEDED} = 1 ]; then
|
67 |
|
|
echo "WARNING: Trying to recover filesystem from inconsistency..."
|
68 |
|
|
/sbin/fsck -yF
|
69 |
|
|
fi
|
70 |
842878b5
|
Scott Ullrich
|
|
71 |
f2e36920
|
Ermal LUÇI
|
/sbin/mount -a 2>/dev/null
|
72 |
|
|
mount_rc=$?
|
73 |
|
|
attempts=0
|
74 |
|
|
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
|
75 |
7fd93993
|
Ermal LUÇI
|
/sbin/fsck -yF
|
76 |
f5813962
|
Renato Botelho
|
/sbin/mount -a 2>/dev/null
|
77 |
|
|
mount_rc=$?
|
78 |
f2e36920
|
Ermal LUÇI
|
attempts=$((attempts+1))
|
79 |
|
|
done
|
80 |
e92e83d4
|
jim-p
|
|
81 |
217935fe
|
Ermal LUÇI
|
if [ "${PLATFORM}" = "nanobsd" ]; then
|
82 |
|
|
# XXX This script does need all filesystems rw!!!!
|
83 |
|
|
# Put this workaround for now until better ways are found.
|
84 |
|
|
/sbin/mount -u -w -o sync,noatime /
|
85 |
|
|
/sbin/mount -u -w -o sync,noatime /cf
|
86 |
|
|
fi
|
87 |
|
|
|
88 |
842878b5
|
Scott Ullrich
|
# If /conf is a directory, convert it to a symlink to /cf/conf
|
89 |
c4995e62
|
Chris Buechler
|
if [ -d "/conf" ]; then
|
90 |
|
|
# If item is not a symlink then rm and recreate
|
91 |
e173dd74
|
Phil Davis
|
CONFPOINTSTO=`readlink /conf`
|
92 |
|
|
if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then
|
93 |
e8d0903d
|
Ermal
|
/bin/rm -rf /conf
|
94 |
|
|
/bin/ln -s /cf/conf /conf
|
95 |
c4995e62
|
Chris Buechler
|
fi
|
96 |
|
|
fi
|
97 |
efc0e29a
|
jim-p
|
|
98 |
a5c36eb2
|
Renato Botelho
|
USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
|
99 |
e7c1f181
|
Renato Botelho
|
unset MOVE_PKG_DATA
|
100 |
|
|
if [ "$PLATFORM" = "${product}" ]; then
|
101 |
|
|
# If use MFS var is disabled, move files back to place
|
102 |
|
|
if [ "${USE_MFS_TMPVAR}" != "true" -a -f /root/var/db/pkg/local.sqlite ]; then
|
103 |
|
|
MOVE_PKG_DATA=1
|
104 |
|
|
rm -rf /var/db/pkg 2>/dev/null
|
105 |
|
|
rm -rf /var/cache/pkg 2>/dev/null
|
106 |
|
|
mv /root/var/db/pkg /var/db
|
107 |
|
|
mv /root/var/cache/pkg /var/cache
|
108 |
|
|
# If use MFS var is enabled, move files to a safe place
|
109 |
|
|
elif [ "${USE_MFS_TMPVAR}" = "true" -a -f /var/db/pkg/local.sqlite ]; then
|
110 |
|
|
MOVE_PKG_DATA=1
|
111 |
|
|
/bin/mkdir -p /root/var/db /root/var/cache
|
112 |
|
|
mv /var/db/pkg /root/var/db
|
113 |
|
|
mv /var/cache/pkg /root/var/cache
|
114 |
|
|
fi
|
115 |
|
|
elif [ "${PLATFORM}" = "nanobsd" ]; then
|
116 |
|
|
MOVE_PKG_DATA=1
|
117 |
|
|
fi
|
118 |
|
|
|
119 |
a5c36eb2
|
Renato Botelho
|
if [ "${PLATFORM}" = "nanobsd" ] || [ "${USE_MFS_TMPVAR}" = "true" ]; then
|
120 |
efc0e29a
|
jim-p
|
/etc/rc.embedded
|
121 |
|
|
fi
|
122 |
e7c1f181
|
Renato Botelho
|
|
123 |
d71525b3
|
Renato Botelho
|
if [ -n "${MOVE_PKG_DATA}" -o "${USE_MFS_TMPVAR}" = "true" ]; then
|
124 |
e7c1f181
|
Renato Botelho
|
/bin/mkdir -p /var/db /var/cache
|
125 |
|
|
ln -sf ../../root/var/db/pkg /var/db/pkg
|
126 |
|
|
ln -sf ../../root/var/cache/pkg /var/cache/pkg
|
127 |
|
|
fi
|
128 |
c4995e62
|
Chris Buechler
|
fi
|
129 |
|
|
|
130 |
990fa101
|
jim-p
|
/bin/rm -f /root/force_fsck
|
131 |
2085c6de
|
jim-p
|
/bin/rm -f /root/TRIM_set
|
132 |
|
|
/bin/rm -f /root/TRIM_unset
|
133 |
|
|
|
134 |
f2e36920
|
Ermal LUÇI
|
if [ "${PLATFORM}" = "nanobsd" ]; then
|
135 |
|
|
/sbin/kldstat -qm zfs
|
136 |
|
|
if [ $? -eq 0 ]; then
|
137 |
|
|
/sbin/kldunload zfs
|
138 |
|
|
fi
|
139 |
c580e34c
|
Renato Botelho
|
elif [ "$PLATFORM" = "${product}" ]; then
|
140 |
f2e36920
|
Ermal LUÇI
|
# Handle ZFS read-only case
|
141 |
|
|
/sbin/kldstat -qm zfs
|
142 |
|
|
if [ $? -eq 0 ]; then
|
143 |
|
|
ZFSFSAVAILABLE=$(/sbin/zfs mount 2>/dev/null | wc -l)
|
144 |
|
|
if [ $ZFSFSAVAILABLE -eq 0 ]; then
|
145 |
|
|
/sbin/kldunload zfs
|
146 |
|
|
elif [ -f /usr/bin/grep ]; then
|
147 |
|
|
ZFSROOT=`/sbin/zfs mount | /usr/bin/grep ' /$' | /usr/bin/cut -d ' ' -f 1`
|
148 |
|
|
if [ "$ZFSROOT" != "" ]; then
|
149 |
|
|
/sbin/zfs set readonly=off $ZFSROOT
|
150 |
|
|
fi
|
151 |
|
|
fi
|
152 |
|
|
fi
|
153 |
|
|
elif [ "${PLATFORM}" = "cdrom" ]; then
|
154 |
|
|
/etc/rc.cdrom
|
155 |
|
|
fi
|
156 |
|
|
|
157 |
92ac3b3d
|
jim-p
|
# Disable APM on ATA drives. Leaving this on will kill drives long-term, especially laptop drives, by generating excessive Load Cycles.
|
158 |
06fd1952
|
Ermal
|
if [ -f /etc/rc.disable_hdd_apm ]; then
|
159 |
|
|
/etc/rc.disable_hdd_apm
|
160 |
|
|
fi
|
161 |
92ac3b3d
|
jim-p
|
|
162 |
6990ad35
|
Phil Davis
|
# Eject CD devices on 3G modems
|
163 |
2f8782fe
|
smos
|
MANUFACTURER="huawei|zte"
|
164 |
|
|
CDDEVICE=`dmesg |egrep -ie "($MANUFACTURER)" | awk -F: '/cd/ {print $1}'`
|
165 |
|
|
if [ "$CDDEVICE" != "" ]; then
|
166 |
|
|
cdcontrol -f /dev/"$CDDEVICE" eject
|
167 |
|
|
fi
|
168 |
793d3c96
|
smos
|
|
169 |
e4121dde
|
Renato Botelho
|
# Use php -n here because we are not ready to load extensions yet
|
170 |
|
|
varrunpath=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var varrun_path "/var/run")
|
171 |
3d7639eb
|
Scott Ullrich
|
|
172 |
a5c36eb2
|
Renato Botelho
|
if [ "$PLATFORM" = "${product}" ] && [ "${USE_MFS_TMPVAR}" != "true" ]; then
|
173 |
7d3be92f
|
Ermal
|
/sbin/mdmfs -S -M -s 4m md $varrunpath
|
174 |
|
|
fi
|
175 |
|
|
|
176 |
e4121dde
|
Renato Botelho
|
# Use php -n here because we are not ready to load extensions yet
|
177 |
|
|
hideplatform=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var hideplatform)
|
178 |
|
|
if [ "$hideplatform" = "true" ]; then
|
179 |
3d7639eb
|
Scott Ullrich
|
platformbanner="" # hide the platform
|
180 |
|
|
else
|
181 |
|
|
platformbanner=" on the '${PLATFORM}' platform"
|
182 |
|
|
fi
|
183 |
1c44a77d
|
Scott Ullrich
|
|
184 |
|
|
echo
|
185 |
|
|
cat /etc/ascii-art/pfsense-logo-small.txt
|
186 |
|
|
echo
|
187 |
|
|
echo
|
188 |
13500a22
|
Phil Davis
|
echo "Welcome to ${product} ${version}${platformbanner}..."
|
189 |
1c44a77d
|
Scott Ullrich
|
echo
|
190 |
|
|
|
191 |
6fa9f38c
|
Renato Botelho
|
/sbin/conscontrol mute off >/dev/null
|
192 |
d5f60dba
|
Scott Ullrich
|
|
193 |
c580e34c
|
Renato Botelho
|
if [ "$PLATFORM" = "${product}" ]; then
|
194 |
3b39d0ac
|
jim-p
|
SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1`
|
195 |
|
|
/sbin/swapon -a 2>/dev/null >/dev/null
|
196 |
e5323cca
|
jim-p
|
/etc/rc.savecore
|
197 |
98546a74
|
Scott Ullrich
|
fi
|
198 |
5621d2d5
|
Scott Ullrich
|
|
199 |
12bf92ca
|
Scott Ullrich
|
if [ "$PLATFORM" = "cdrom" ] ; then
|
200 |
df40aa86
|
Scott Ullrich
|
echo -n "Mounting unionfs directories..."
|
201 |
e8d0903d
|
Ermal
|
/bin/mkdir /tmp/unionfs
|
202 |
|
|
/bin/mkdir /tmp/unionfs/usr
|
203 |
|
|
/bin/mkdir /tmp/unionfs/root
|
204 |
|
|
/bin/mkdir /tmp/unionfs/sbin
|
205 |
|
|
/bin/mkdir /tmp/unionfs/bin
|
206 |
|
|
/bin/mkdir /tmp/unionfs/boot
|
207 |
|
|
/bin/mkdir /tmp/unionfs/confdefault
|
208 |
|
|
/sbin/mount_unionfs /tmp/unionfs/usr /usr/
|
209 |
|
|
/sbin/mount_unionfs /tmp/unionfs/root /root/
|
210 |
e173dd74
|
Phil Davis
|
/sbin/mount_unionfs /tmp/unionfs/bin /bin/
|
211 |
|
|
/sbin/mount_unionfs /tmp/unionfs/sbin /sbin/
|
212 |
e8d0903d
|
Ermal
|
/sbin/mount_unionfs /tmp/unionfs/boot /boot/
|
213 |
|
|
/sbin/mount_unionfs /tmp/unionfs/confdefault /conf.default/
|
214 |
df40aa86
|
Scott Ullrich
|
echo "done."
|
215 |
12bf92ca
|
Scott Ullrich
|
fi
|
216 |
|
|
|
217 |
080b4ce1
|
Ermal
|
# make some directories in /var
|
218 |
1a28657c
|
Ermal LUÇI
|
/bin/mkdir -p $varrunpath /var/log /var/etc /var/db/entropy /var/db/rrd /var/at/jobs/ /var/empty 2>/dev/null
|
219 |
080b4ce1
|
Ermal
|
/bin/rm -rf $varrunpath/*
|
220 |
c580e34c
|
Renato Botelho
|
if [ "$PLATFORM" != "${product}" ]; then
|
221 |
080b4ce1
|
Ermal
|
/bin/rm /var/log/* 2>/dev/null
|
222 |
|
|
fi
|
223 |
|
|
|
224 |
9e9bc51c
|
Ermal
|
# Cleanup configuration files from previous instance
|
225 |
|
|
/bin/rm -rf /var/etc/*
|
226 |
|
|
|
227 |
96fcf698
|
Renato Botelho
|
# Workaround for ipsec symlinks, otherwise it's going to break
|
228 |
|
|
# strongswan pkg upgrade
|
229 |
|
|
|
230 |
|
|
if [ -L /usr/local/etc/ipsec.d ]; then
|
231 |
|
|
rm -f /usr/local/etc/ipsec.d
|
232 |
|
|
fi
|
233 |
|
|
if [ -L /usr/local/etc/ipsec.conf ]; then
|
234 |
|
|
rm -f /usr/local/etc/ipsec.conf
|
235 |
|
|
fi
|
236 |
47220a8c
|
Renato Botelho
|
if [ -L /usr/local/etc/strongswan.d ]; then
|
237 |
|
|
rm -f /usr/local/etc/strongswan.d
|
238 |
|
|
fi
|
239 |
96fcf698
|
Renato Botelho
|
if [ -L /usr/local/etc/strongswan.conf ]; then
|
240 |
|
|
rm -f /usr/local/etc/strongswan.conf
|
241 |
|
|
fi
|
242 |
|
|
|
243 |
2e269da2
|
Scott Ullrich
|
echo -n "Creating symlinks..."
|
244 |
6bab150e
|
Scott Ullrich
|
# Repair symlinks if they are broken
|
245 |
080b4ce1
|
Ermal
|
if [ -f /etc/newsyslog.conf ]; then
|
246 |
|
|
/bin/rm -f /etc/newsyslog.conf
|
247 |
|
|
fi
|
248 |
6bab150e
|
Scott Ullrich
|
if [ ! -L /etc/syslog.conf ]; then
|
249 |
e8d0903d
|
Ermal
|
/bin/rm -rf /etc/syslog.conf
|
250 |
9e9bc51c
|
Ermal
|
if [ ! -f /var/etc/syslog.conf ]; then
|
251 |
|
|
touch /var/etc/syslog.conf
|
252 |
|
|
fi
|
253 |
e8d0903d
|
Ermal
|
/bin/ln -s /var/etc/syslog.conf /etc/syslog.conf
|
254 |
6bab150e
|
Scott Ullrich
|
fi
|
255 |
|
|
|
256 |
f1cc2287
|
Scott Ullrich
|
# Repair symlinks if they are broken
|
257 |
|
|
if [ ! -L /etc/hosts ]; then
|
258 |
e8d0903d
|
Ermal
|
/bin/rm -rf /etc/hosts
|
259 |
|
|
/bin/ln -s /var/etc/hosts /etc/hosts
|
260 |
c8fcdb2f
|
Scott Ullrich
|
fi
|
261 |
095d04db
|
Scott Ullrich
|
|
262 |
f1cc2287
|
Scott Ullrich
|
if [ ! -L /etc/resolv.conf ]; then
|
263 |
e173dd74
|
Phil Davis
|
/bin/rm -rf /etc/resolv.conf
|
264 |
|
|
/bin/ln -s /var/etc/resolv.conf /etc/resolv.conf
|
265 |
f1cc2287
|
Scott Ullrich
|
fi
|
266 |
095d04db
|
Scott Ullrich
|
|
267 |
30501526
|
Warren Baker
|
if [ ! -L /etc/resolvconf.conf ]; then
|
268 |
e173dd74
|
Phil Davis
|
/bin/rm -rf /etc/resolvconf.conf
|
269 |
|
|
/bin/ln -s /var/etc/resolvconf.conf /etc/resolvconf.conf
|
270 |
30501526
|
Warren Baker
|
fi
|
271 |
|
|
|
272 |
230787e7
|
Scott Ullrich
|
# Setup compatibility link for packages that
|
273 |
|
|
# have trouble overriding the PREFIX configure
|
274 |
|
|
# argument since we build our packages in a
|
275 |
5aa68a55
|
Renato Botelho
|
# separated PREFIX area
|
276 |
e173dd74
|
Phil Davis
|
# Only create if symlink does not exist.
|
277 |
eb03f14e
|
Chris Buechler
|
if [ ! -h /tmp/tmp ]; then
|
278 |
e173dd74
|
Phil Davis
|
/bin/ln -hfs / /tmp/tmp
|
279 |
eb03f14e
|
Chris Buechler
|
fi
|
280 |
230787e7
|
Scott Ullrich
|
|
281 |
4be3f6cf
|
Seth Mos
|
# Make sure our /tmp is 777 + Sticky
|
282 |
3fb8caf2
|
Scott Ullrich
|
if [ ! "$PLATFORM" = "cdrom" ] ; then
|
283 |
e8d0903d
|
Ermal
|
/bin/rm -rf /tmp/*
|
284 |
3fb8caf2
|
Scott Ullrich
|
fi
|
285 |
e8d0903d
|
Ermal
|
/bin/chmod 1777 /tmp
|
286 |
0652f3ae
|
Seth Mos
|
|
287 |
dd64811a
|
Scott Ullrich
|
if [ ! "$PLATFORM" = "cdrom" ] ; then
|
288 |
|
|
# Malloc debugging check
|
289 |
|
|
if [ -L /etc/malloc.conf ]; then
|
290 |
e173dd74
|
Phil Davis
|
#ln -s aj /etc/malloc.conf
|
291 |
e8d0903d
|
Ermal
|
/bin/rm /etc/malloc.conf
|
292 |
dd64811a
|
Scott Ullrich
|
fi
|
293 |
cecdf31c
|
Scott Ullrich
|
fi
|
294 |
|
|
|
295 |
6484bb83
|
Scott Ullrich
|
if [ ! -L /etc/dhclient.conf ]; then
|
296 |
e173dd74
|
Phil Davis
|
/bin/rm -rf /etc/dhclient.conf
|
297 |
6484bb83
|
Scott Ullrich
|
fi
|
298 |
c8fcdb2f
|
Scott Ullrich
|
|
299 |
544156a7
|
Scott Ullrich
|
if [ ! -d /var/tmp ]; then
|
300 |
e8d0903d
|
Ermal
|
/bin/mkdir -p /var/tmp
|
301 |
544156a7
|
Scott Ullrich
|
fi
|
302 |
4aa70cd8
|
Scott Ullrich
|
|
303 |
5b237745
|
Scott Ullrich
|
set -T
|
304 |
|
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
305 |
|
|
|
306 |
61f1e2ec
|
Scott Ullrich
|
# Remove old nameserver resolution files
|
307 |
e8d0903d
|
Ermal
|
/bin/rm -f /var/etc/nameserver*
|
308 |
61f1e2ec
|
Scott Ullrich
|
|
309 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
310 |
a5c36eb2
|
Renato Botelho
|
DISABLESYSLOGCLOG=$(/usr/local/sbin/read_xml_tag.sh boolean system/disablesyslogclog)
|
311 |
1e8599e5
|
Chris Buechler
|
LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppp relayd wireless nginx ntpd gateways resolver routing"
|
312 |
c7a3356e
|
jim-p
|
|
313 |
a5c36eb2
|
Renato Botelho
|
DEFAULT_LOG_FILE_SIZE=$(/usr/local/sbin/read_xml_tag.sh string syslog/logfilesize)
|
314 |
|
|
DEFAULT_LOG_FILE_SIZE=${DEFAULT_LOG_FILE_SIZE:-"511488"}
|
315 |
c7a3356e
|
jim-p
|
|
316 |
973b2663
|
Ermal
|
for logfile in $LOG_FILES; do
|
317 |
a5c36eb2
|
Renato Botelho
|
if [ "$DISABLESYSLOGCLOG" = "true" ]; then
|
318 |
973b2663
|
Ermal
|
/usr/bin/touch /var/log/$logfile.log
|
319 |
e173dd74
|
Phil Davis
|
else
|
320 |
973b2663
|
Ermal
|
if [ ! -f /var/log/$logfile.log ]; then
|
321 |
41df62c1
|
jim-p
|
/usr/local/sbin/clog -i -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
|
322 |
e8197e56
|
Ermal
|
fi
|
323 |
e173dd74
|
Phil Davis
|
fi
|
324 |
973b2663
|
Ermal
|
done
|
325 |
|
|
|
326 |
41df62c1
|
jim-p
|
# change permissions on newly created log files.
|
327 |
e8d0903d
|
Ermal
|
/bin/chmod 0600 /var/log/*.log
|
328 |
8d418ca9
|
Scott Ullrich
|
|
329 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
330 |
6fa9f38c
|
Renato Botelho
|
DEVFS=`/sbin/mount | /usr/bin/grep devfs | /usr/bin/wc -l | /usr/bin/cut -d" " -f8`
|
331 |
|
|
if [ "$DEVFS" = "0" ]; then
|
332 |
|
|
mount_devfs devfs /dev
|
333 |
f93c5384
|
Scott Ullrich
|
fi
|
334 |
5b237745
|
Scott Ullrich
|
|
335 |
|
|
# Create an initial utmp file
|
336 |
7d3be92f
|
Ermal
|
cd $varrunpath && /bin/cp /dev/null utmp && /bin/chmod 644 utmp
|
337 |
5b237745
|
Scott Ullrich
|
|
338 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
339 |
6fe4f291
|
Scott Ullrich
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
340 |
05dd0c32
|
Ermal
|
/etc/rc.d/ldconfig start 2>/dev/null
|
341 |
c268f10f
|
Scott Ullrich
|
|
342 |
6fa9f38c
|
Renato Botelho
|
# Launching kbdmux(4)
|
343 |
|
|
if [ -f "/dev/kbdmux0" ]; then
|
344 |
|
|
echo -n "."
|
345 |
|
|
/usr/sbin/kbdcontrol -k /dev/kbdmux0 < /dev/console
|
346 |
|
|
[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
|
347 |
|
|
[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
|
348 |
|
|
fi
|
349 |
4e7b2b27
|
Scott Ullrich
|
|
350 |
6fa9f38c
|
Renato Botelho
|
# Fire up unionfs if mount points exist.
|
351 |
|
|
if [ -f /dist/uniondirs ]; then
|
352 |
|
|
echo -n "."
|
353 |
|
|
/etc/rc.d/unionfs start
|
354 |
b1ce7649
|
Scott Ullrich
|
fi
|
355 |
fa8f44ce
|
Scott Ullrich
|
|
356 |
2e269da2
|
Scott Ullrich
|
echo "done."
|
357 |
deff30cd
|
Scott Ullrich
|
|
358 |
ad0d7518
|
Scott Ullrich
|
# Recreate capabilities DB
|
359 |
416e6432
|
Ermal
|
/usr/bin/cap_mkdb /etc/login.conf
|
360 |
ad0d7518
|
Scott Ullrich
|
|
361 |
a5733f63
|
Renato Botelho
|
# Second upgrade stage
|
362 |
|
|
/usr/local/sbin/${product}-upgrade -y -b 2
|
363 |
842fc1e2
|
Renato Botelho
|
|
364 |
40e46009
|
Scott Ullrich
|
# Run the php.ini setup file and populate
|
365 |
3646fbcb
|
Renato Botelho
|
# /usr/local/etc/php.ini
|
366 |
aa840cf9
|
Scott Ullrich
|
/etc/rc.php_ini_setup 2>/tmp/php_errors.txt
|
367 |
3646fbcb
|
Renato Botelho
|
/usr/local/sbin/php-fpm -c /usr/local/etc/php.ini -y /usr/local/lib/php-fpm.conf -RD 2>&1 >/dev/null
|
368 |
0cf5aa69
|
Scott Ullrich
|
|
369 |
206f684d
|
Scott Ullrich
|
# Launch external configuration loader for supported platforms
|
370 |
|
|
if [ "$PLATFORM" = "nanobsd" ]; then
|
371 |
1590947b
|
Ermal
|
/usr/local/sbin/fcgicli -f /etc/ecl.php
|
372 |
206f684d
|
Scott Ullrich
|
fi
|
373 |
|
|
|
374 |
|
|
# Launch external configuration loader for supported platforms
|
375 |
c580e34c
|
Renato Botelho
|
if [ "$PLATFORM" = "${product}" ]; then
|
376 |
1590947b
|
Ermal
|
/usr/local/sbin/fcgicli -f /etc/ecl.php
|
377 |
206f684d
|
Scott Ullrich
|
fi
|
378 |
|
|
|
379 |
490615d3
|
Scott Ullrich
|
if [ -f /etc/rc.custom_boot_early ]; then
|
380 |
|
|
/bin/echo -n "Launching /etc/rc.custom_boot_early...";
|
381 |
|
|
/etc/rc.custom_boot_early
|
382 |
|
|
echo "Done"
|
383 |
|
|
fi
|
384 |
|
|
|
385 |
4aea91d8
|
Ermal
|
export fcgipath=/var/run/php-fpm.socket
|
386 |
01599e5e
|
Ermal
|
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status
|
387 |
e8d0903d
|
Ermal
|
|
388 |
b406ae66
|
Scott Ullrich
|
# let the PHP-based configuration subsystem set up the system now
|
389 |
8e2eb65e
|
Scott Ullrich
|
echo -n "Launching the init system..."
|
390 |
e8d0903d
|
Ermal
|
/bin/rm -f /cf/conf/backup/backup.cache
|
391 |
|
|
/usr/bin/touch $varrunpath/booting
|
392 |
217935fe
|
Ermal LUÇI
|
|
393 |
|
|
if [ "${PLATFORM}" = "nanobsd" ]; then
|
394 |
|
|
# XXX This script does need all filesystems rw!!!!
|
395 |
|
|
# Put this workaround for now until better ways are found.
|
396 |
|
|
/sbin/mount -u -f -r -o sync,noatime /
|
397 |
|
|
/sbin/mount -u -f -r -o sync,noatime /cf
|
398 |
|
|
fi
|
399 |
|
|
|
400 |
b406ae66
|
Scott Ullrich
|
/etc/rc.bootup
|
401 |
|
|
|
402 |
f658bac7
|
Ermal LUÇI
|
# /etc/rc.bootup unset $g['booting'], and removes file
|
403 |
|
|
# Be sure the file is removed to not create troubles after
|
404 |
|
|
if [ -f $varrunpath/booting ]; then
|
405 |
|
|
/bin/rm $varrunpath/booting
|
406 |
|
|
fi
|
407 |
5551d818
|
Renato Botelho
|
|
408 |
0c5e431d
|
Scott Ullrich
|
echo -n "Starting CRON... "
|
409 |
ea83ac64
|
Scott Ullrich
|
cd /tmp && /usr/sbin/cron -s 2>/dev/null
|
410 |
0c5e431d
|
Scott Ullrich
|
echo "done."
|
411 |
3e08b3c1
|
Scott Ullrich
|
|
412 |
5be5825e
|
Scott Ullrich
|
# Start packages
|
413 |
1590947b
|
Ermal
|
/usr/local/sbin/fcgicli -f /etc/rc.start_packages
|
414 |
3bd1bd72
|
Scott Ullrich
|
|
415 |
e8d0903d
|
Ermal
|
/bin/rm -rf /usr/local/pkg/pf/CVS
|
416 |
bc086d51
|
Scott Ullrich
|
|
417 |
0092b3bd
|
mgrooms
|
# Start ping handler every 240 seconds
|
418 |
7d3be92f
|
Ermal
|
/usr/local/bin/minicron 240 $varrunpath/ping_hosts.pid /usr/local/bin/ping_hosts.sh
|
419 |
f2025e91
|
Scott Ullrich
|
|
420 |
0092b3bd
|
mgrooms
|
# Start account expire handler every hour
|
421 |
1590947b
|
Ermal
|
/usr/local/bin/minicron 3600 $varrunpath/expire_accounts.pid '/usr/local/sbin/fcgicli -f /etc/rc.expireaccounts'
|
422 |
0092b3bd
|
mgrooms
|
|
423 |
f6ba4bd1
|
Scott Ullrich
|
# Start alias url updater every 24 hours
|
424 |
1590947b
|
Ermal
|
/usr/local/bin/minicron 86400 $varrunpath/update_alias_url_data.pid '/usr/local/sbin/fcgicli -f /etc/rc.update_alias_url_data'
|
425 |
f6ba4bd1
|
Scott Ullrich
|
|
426 |
c432da9c
|
Scott Ullrich
|
/bin/chmod a+rw /tmp/.
|
427 |
b569598b
|
Scott Ullrich
|
|
428 |
52398a6b
|
jim-p
|
# Check for GEOM mirrors
|
429 |
|
|
GMIRROR_STATUS=`/sbin/gmirror status`
|
430 |
|
|
if [ "${GMIRROR_STATUS}" != "" ]; then
|
431 |
|
|
# Using a flag file at bootup saves an expensive exec/check on each page load.
|
432 |
|
|
/usr/bin/touch /var/run/gmirror_active
|
433 |
|
|
# Setup monitoring/notifications
|
434 |
|
|
/usr/local/bin/minicron 60 /var/run/gmirror_status_check.pid /usr/local/sbin/gmirror_status_check.php
|
435 |
|
|
fi
|
436 |
|
|
|
437 |
a5733f63
|
Renato Botelho
|
/usr/local/sbin/${product}-upgrade -y -b 3
|
438 |
|
|
|
439 |
dcafc712
|
Adam Gibson
|
# Log product version to syslog
|
440 |
4982e61e
|
Adam Gibson
|
BUILDTIME=`cat /etc/version.buildtime`
|
441 |
|
|
ARCH=`uname -m`
|
442 |
76fce373
|
Adam Gibson
|
echo "$product ($PLATFORM) $version $ARCH $BUILDTIME"
|
443 |
4982e61e
|
Adam Gibson
|
|
444 |
e393a4a8
|
Scott Ullrich
|
echo "Bootup complete"
|
445 |
1ba9533c
|
Scott Ullrich
|
|
446 |
2d4be1c5
|
Scott Ullrich
|
/usr/local/bin/beep.sh start 2>&1 >/dev/null
|
447 |
e393a4a8
|
Scott Ullrich
|
|
448 |
4171fa68
|
Scott Ullrich
|
# Reset the cache. read-only requires this.
|
449 |
7734aea6
|
Andrew Thompson
|
/bin/rm -f /tmp/config.cache
|
450 |
4171fa68
|
Scott Ullrich
|
|
451 |
d35cf0de
|
Scott Ullrich
|
exit 0
|