Project

General

Profile

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