1 |
5b237745
|
Scott Ullrich
|
#!/bin/sh
|
2 |
ac24dc24
|
Renato Botelho
|
#
|
3 |
|
|
# pfSense-rc
|
4 |
|
|
#
|
5 |
|
|
# part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
# Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
# Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
|
|
# Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
|
9 |
ac24dc24
|
Renato Botelho
|
# All rights reserved.
|
10 |
|
|
#
|
11 |
e5cd29a0
|
Scott Ullrich
|
# originally based on m0n0wall (http://neon1.net/m0n0wall)
|
12 |
c5d81585
|
Renato Botelho
|
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13 |
5b237745
|
Scott Ullrich
|
# All rights reserved.
|
14 |
ac24dc24
|
Renato Botelho
|
#
|
15 |
b12ea3fb
|
Renato Botelho
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
# you may not use this file except in compliance with the License.
|
17 |
|
|
# You may obtain a copy of the License at
|
18 |
ac24dc24
|
Renato Botelho
|
#
|
19 |
b12ea3fb
|
Renato Botelho
|
# http://www.apache.org/licenses/LICENSE-2.0
|
20 |
ac24dc24
|
Renato Botelho
|
#
|
21 |
b12ea3fb
|
Renato Botelho
|
# Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
# See the License for the specific language governing permissions and
|
25 |
|
|
# limitations under the License.
|
26 |
d8a2ce2c
|
Scott Ullrich
|
|
27 |
|
|
#/bin/stty status '^T'
|
28 |
|
|
#/bin/stty susp '^-' intr '^-' quit '^-'
|
29 |
|
|
|
30 |
|
|
#trap : 2
|
31 |
|
|
#trap : 3
|
32 |
5b237745
|
Scott Ullrich
|
|
33 |
|
|
HOME=/
|
34 |
ce823053
|
Scott Ullrich
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
35 |
5b237745
|
Scott Ullrich
|
export HOME PATH
|
36 |
|
|
|
37 |
55f81e30
|
Phil Davis
|
get_version ()
|
38 |
|
|
{
|
39 |
|
|
# Set our current version
|
40 |
|
|
version=`/bin/cat /etc/version`
|
41 |
|
|
|
42 |
|
|
# Version patch
|
43 |
|
|
version_patch="0"
|
44 |
|
|
if [ -f /etc/version.patch ]; then
|
45 |
|
|
version_patch=`/bin/cat /etc/version.patch`
|
46 |
|
|
fi
|
47 |
842878b5
|
Scott Ullrich
|
|
48 |
55f81e30
|
Phil Davis
|
if [ "${version_patch}" = "0" ]; then
|
49 |
|
|
version_patch=""
|
50 |
|
|
else
|
51 |
|
|
version_patch=" (Patch ${version_patch})"
|
52 |
|
|
fi
|
53 |
|
|
}
|
54 |
5a0235ca
|
Renato Botelho
|
|
55 |
55f81e30
|
Phil Davis
|
get_version
|
56 |
5a0235ca
|
Renato Botelho
|
|
57 |
e5323cca
|
jim-p
|
# Setup dumpdev/ddb/savecore"
|
58 |
|
|
echo "Configuring crash dumps..."
|
59 |
dc61252a
|
Renato Botelho
|
/etc/rc.dumpon
|
60 |
e5323cca
|
jim-p
|
|
61 |
92a78939
|
jim-p
|
if [ -e /root/force_growfs ]; then
|
62 |
|
|
/etc/rc.d/growfs onestart
|
63 |
302c005e
|
Ermal
|
fi
|
64 |
|
|
|
65 |
1b21bfdb
|
Luiz Souza
|
#
|
66 |
286cd231
|
Luiz Souza
|
# The file system needs to be unmounted to guarantee a clean operation of fsck.
|
67 |
|
|
# Pending changes can keep the file system dirty until all the cached data is
|
68 |
|
|
# flushed to the disk.
|
69 |
|
|
#
|
70 |
|
|
/sbin/mount -ur /
|
71 |
1b21bfdb
|
Luiz Souza
|
|
72 |
|
|
fsck_forced_iterations=`/bin/kenv -q pfsense.fsck.force`
|
73 |
|
|
if [ ! -z "${fsck_forced_iterations}" ]; then
|
74 |
|
|
echo "Forcing filesystem check (${fsck_forced_iterations} times)..."
|
75 |
|
|
while [ ${fsck_forced_iterations} -gt 0 ]; do
|
76 |
|
|
/sbin/fsck -y -t ufs
|
77 |
|
|
fsck_forced_iterations=$((fsck_forced_iterations - 1))
|
78 |
|
|
done
|
79 |
|
|
fi
|
80 |
|
|
|
81 |
60f164f3
|
Renato Botelho
|
FSCK_ACTION_NEEDED=0
|
82 |
cc82c328
|
Renato Botelho
|
/sbin/fsck -p
|
83 |
60f164f3
|
Renato Botelho
|
case $? in
|
84 |
|
|
0)
|
85 |
|
|
echo "Filesystems are clean, continuing..."
|
86 |
|
|
echo "Mounting filesystems..."
|
87 |
|
|
;;
|
88 |
feeb0581
|
Renato Botelho
|
8|16)
|
89 |
60f164f3
|
Renato Botelho
|
echo "Preen mode recommended running a check that will be performed now."
|
90 |
|
|
FSCK_ACTION_NEEDED=1
|
91 |
|
|
;;
|
92 |
|
|
*)
|
93 |
|
|
echo "Stopping boot is recommended because filesystem manual action is needed, nevertheless automated repair of the filesystem will be attempted."
|
94 |
|
|
FSCK_ACTION_NEEDED=1
|
95 |
|
|
;;
|
96 |
|
|
esac
|
97 |
|
|
|
98 |
|
|
if [ ${FSCK_ACTION_NEEDED} = 1 ]; then
|
99 |
|
|
echo "WARNING: Trying to recover filesystem from inconsistency..."
|
100 |
cc82c328
|
Renato Botelho
|
/sbin/fsck -y -t ufs
|
101 |
60f164f3
|
Renato Botelho
|
fi
|
102 |
842878b5
|
Scott Ullrich
|
|
103 |
60f164f3
|
Renato Botelho
|
/sbin/mount -a 2>/dev/null
|
104 |
|
|
mount_rc=$?
|
105 |
|
|
attempts=0
|
106 |
cc82c328
|
Renato Botelho
|
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 10 ]; do
|
107 |
|
|
/sbin/fsck -y -t ufs
|
108 |
f2e36920
|
Ermal LUÇI
|
/sbin/mount -a 2>/dev/null
|
109 |
|
|
mount_rc=$?
|
110 |
60f164f3
|
Renato Botelho
|
attempts=$((attempts+1))
|
111 |
|
|
done
|
112 |
217935fe
|
Ermal LUÇI
|
|
113 |
cc82c328
|
Renato Botelho
|
if [ ${mount_rc} -ne 0 ]; then
|
114 |
|
|
echo "ERROR: Impossible to mount filesystem, use interactive shell to attempt to recover it"
|
115 |
|
|
/bin/sh
|
116 |
|
|
/sbin/reboot
|
117 |
|
|
fi
|
118 |
|
|
|
119 |
b712dd52
|
Renato Botelho
|
# Handle ZFS read-only case
|
120 |
fcf164d6
|
Renato Botelho
|
unset USE_ZFS
|
121 |
|
|
if /sbin/kldstat -qm zfs; then
|
122 |
b712dd52
|
Renato Botelho
|
ZFSFSAVAILABLE=$(/sbin/zfs mount 2>/dev/null | wc -l)
|
123 |
|
|
if [ $ZFSFSAVAILABLE -eq 0 ]; then
|
124 |
|
|
/sbin/kldunload zfs
|
125 |
fcf164d6
|
Renato Botelho
|
else
|
126 |
|
|
USE_ZFS=1
|
127 |
|
|
ZFSROOT=$(/sbin/zfs mount | /usr/bin/awk '$2 == "/" {print $1}')
|
128 |
|
|
if [ -n "$ZFSROOT" ]; then
|
129 |
b712dd52
|
Renato Botelho
|
/sbin/zfs set readonly=off $ZFSROOT
|
130 |
|
|
fi
|
131 |
fcf164d6
|
Renato Botelho
|
/sbin/zfs mount -a
|
132 |
635dcc69
|
jim-p
|
# If /bootpool is present, then there is an additional zfs pool to import
|
133 |
|
|
# See https://redmine.pfsense.org/issues/8063
|
134 |
|
|
if [ -d /bootpool ]; then
|
135 |
|
|
/sbin/zpool import -f bootpool
|
136 |
|
|
fi
|
137 |
b712dd52
|
Renato Botelho
|
fi
|
138 |
|
|
fi
|
139 |
|
|
|
140 |
60f164f3
|
Renato Botelho
|
# If /conf is a directory, convert it to a symlink to /cf/conf
|
141 |
|
|
if [ -d "/conf" ]; then
|
142 |
|
|
# If item is not a symlink then rm and recreate
|
143 |
|
|
CONFPOINTSTO=`readlink /conf`
|
144 |
|
|
if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then
|
145 |
|
|
/bin/rm -rf /conf
|
146 |
|
|
/bin/ln -s /cf/conf /conf
|
147 |
c4995e62
|
Chris Buechler
|
fi
|
148 |
60f164f3
|
Renato Botelho
|
fi
|
149 |
efc0e29a
|
jim-p
|
|
150 |
60f164f3
|
Renato Botelho
|
USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
|
151 |
fcf164d6
|
Renato Botelho
|
|
152 |
60f164f3
|
Renato Botelho
|
unset MOVE_PKG_DATA
|
153 |
dc61252a
|
Renato Botelho
|
# If use MFS var is disabled, move files back to place
|
154 |
|
|
if [ "${USE_MFS_TMPVAR}" != "true" -a -f /root/var/db/pkg/local.sqlite ]; then
|
155 |
|
|
MOVE_PKG_DATA=1
|
156 |
|
|
rm -rf /var/db/pkg 2>/dev/null
|
157 |
|
|
rm -rf /var/cache/pkg 2>/dev/null
|
158 |
9bf6cdc1
|
Renato Botelho
|
mv -f /root/var/db/pkg /var/db
|
159 |
|
|
mv -f /root/var/cache/pkg /var/cache
|
160 |
dc61252a
|
Renato Botelho
|
# If use MFS var is enabled, move files to a safe place
|
161 |
|
|
elif [ "${USE_MFS_TMPVAR}" = "true" -a -f /var/db/pkg/local.sqlite ]; then
|
162 |
60f164f3
|
Renato Botelho
|
MOVE_PKG_DATA=1
|
163 |
9bf6cdc1
|
Renato Botelho
|
rm -rf /root/var/db/pkg 2>/dev/null
|
164 |
|
|
rm -rf /root/var/cache/pkg 2>/dev/null
|
165 |
dc61252a
|
Renato Botelho
|
/bin/mkdir -p /root/var/db /root/var/cache
|
166 |
9bf6cdc1
|
Renato Botelho
|
mv -f /var/db/pkg /root/var/db
|
167 |
|
|
mv -f /var/cache/pkg /root/var/cache
|
168 |
60f164f3
|
Renato Botelho
|
fi
|
169 |
e7c1f181
|
Renato Botelho
|
|
170 |
5d81840b
|
Renato Botelho
|
# Mount /var and /tmp on ZFS filesystems when it's necessary
|
171 |
|
|
if [ -n "${USE_ZFS}" -a "${USE_MFS_TMPVAR}" = "true" ]; then
|
172 |
|
|
zfs list -H -o name,mountpoint |
|
173 |
|
|
while read volume mountpoint; do
|
174 |
|
|
[ "${mountpoint}" != "/var" -a "${mountpoint}" != "/tmp" ] \
|
175 |
|
|
&& continue
|
176 |
|
|
|
177 |
|
|
/sbin/zfs umount ${volume}
|
178 |
|
|
done
|
179 |
|
|
fi
|
180 |
|
|
|
181 |
dc61252a
|
Renato Botelho
|
if [ "${USE_MFS_TMPVAR}" = "true" ]; then
|
182 |
60f164f3
|
Renato Botelho
|
/etc/rc.embedded
|
183 |
|
|
fi
|
184 |
e7c1f181
|
Renato Botelho
|
|
185 |
60f164f3
|
Renato Botelho
|
if [ -n "${MOVE_PKG_DATA}" -o "${USE_MFS_TMPVAR}" = "true" ]; then
|
186 |
|
|
/bin/mkdir -p /var/db /var/cache
|
187 |
|
|
ln -sf ../../root/var/db/pkg /var/db/pkg
|
188 |
|
|
ln -sf ../../root/var/cache/pkg /var/cache/pkg
|
189 |
c4995e62
|
Chris Buechler
|
fi
|
190 |
|
|
|
191 |
05871043
|
jim-p
|
# Read product_name from $g, defaults to pfSense
|
192 |
|
|
# Use php -n here because we are not ready to load extensions yet
|
193 |
|
|
product=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var product_name pfSense)
|
194 |
|
|
|
195 |
|
|
# Setup ddb on all platforms.
|
196 |
|
|
if [ ! -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
|
197 |
|
|
/sbin/ddb /etc/${product}-ddb.conf
|
198 |
|
|
fi
|
199 |
|
|
|
200 |
029d6129
|
NOYB
|
# Restore contents of the RAM disk store
|
201 |
|
|
/etc/rc.restore_ramdisk_store
|
202 |
|
|
|
203 |
9235b25e
|
Renato Botelho
|
# Make sure /home exists
|
204 |
|
|
[ -d /home ] \
|
205 |
|
|
|| mkdir /home
|
206 |
|
|
|
207 |
990fa101
|
jim-p
|
/bin/rm -f /root/force_fsck
|
208 |
e9034b15
|
Renato Botelho
|
/bin/rm -f /root/force_growfs
|
209 |
2085c6de
|
jim-p
|
/bin/rm -f /root/TRIM_set
|
210 |
|
|
/bin/rm -f /root/TRIM_unset
|
211 |
|
|
|
212 |
92ac3b3d
|
jim-p
|
# Disable APM on ATA drives. Leaving this on will kill drives long-term, especially laptop drives, by generating excessive Load Cycles.
|
213 |
06fd1952
|
Ermal
|
if [ -f /etc/rc.disable_hdd_apm ]; then
|
214 |
|
|
/etc/rc.disable_hdd_apm
|
215 |
|
|
fi
|
216 |
92ac3b3d
|
jim-p
|
|
217 |
6990ad35
|
Phil Davis
|
# Eject CD devices on 3G modems
|
218 |
2f8782fe
|
smos
|
MANUFACTURER="huawei|zte"
|
219 |
|
|
CDDEVICE=`dmesg |egrep -ie "($MANUFACTURER)" | awk -F: '/cd/ {print $1}'`
|
220 |
|
|
if [ "$CDDEVICE" != "" ]; then
|
221 |
|
|
cdcontrol -f /dev/"$CDDEVICE" eject
|
222 |
|
|
fi
|
223 |
793d3c96
|
smos
|
|
224 |
e4121dde
|
Renato Botelho
|
# Use php -n here because we are not ready to load extensions yet
|
225 |
|
|
varrunpath=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var varrun_path "/var/run")
|
226 |
3d7639eb
|
Scott Ullrich
|
|
227 |
dc61252a
|
Renato Botelho
|
if [ "${USE_MFS_TMPVAR}" != "true" ]; then
|
228 |
7d3be92f
|
Ermal
|
/sbin/mdmfs -S -M -s 4m md $varrunpath
|
229 |
|
|
fi
|
230 |
|
|
|
231 |
1c44a77d
|
Scott Ullrich
|
echo
|
232 |
dd6c64d8
|
Renato Botelho
|
cat /usr/local/share/pfSense/ascii-art/pfsense-logo-small.txt
|
233 |
1c44a77d
|
Scott Ullrich
|
echo
|
234 |
|
|
echo
|
235 |
3f4a0df9
|
Renato Botelho
|
echo "Welcome to ${product} ${version}${version_patch}..."
|
236 |
1c44a77d
|
Scott Ullrich
|
echo
|
237 |
|
|
|
238 |
6fa9f38c
|
Renato Botelho
|
/sbin/conscontrol mute off >/dev/null
|
239 |
d5f60dba
|
Scott Ullrich
|
|
240 |
d36e5a49
|
jim-p
|
SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1 | /usr/bin/head -n 1`
|
241 |
d988e0bb
|
Luiz Souza
|
if [ -n "${SWAPDEVICE}" ]; then
|
242 |
d36e5a49
|
jim-p
|
/bin/rm -f /tmp/fstab.swap
|
243 |
|
|
if ! [ -c ${SWAPDEVICE} ]; then
|
244 |
14d47037
|
jim-p
|
# Keep the original device, in case it is special, such as encrypted+mirrored zfs swap
|
245 |
|
|
echo "${SWAPDEVICE} none swap sw 0 0" >> /tmp/fstab.swap
|
246 |
|
|
# The swap device in fstab does not exist, look for other valid entries and update fstab
|
247 |
|
|
for SWAPLABEL in /dev/label/swap* /dev/mirror/swap*; do
|
248 |
|
|
if [ -c ${SWAPLABEL} ]; then
|
249 |
|
|
echo "${SWAPLABEL} none swap sw 0 0" >> /tmp/fstab.swap
|
250 |
|
|
fi
|
251 |
d36e5a49
|
jim-p
|
done
|
252 |
|
|
else
|
253 |
|
|
/bin/cp /etc/fstab /tmp/fstab.swap
|
254 |
|
|
fi
|
255 |
|
|
/sbin/swapon -F /tmp/fstab.swap -a 2>/dev/null >/dev/null
|
256 |
d988e0bb
|
Luiz Souza
|
/etc/rc.savecore
|
257 |
|
|
fi
|
258 |
5621d2d5
|
Scott Ullrich
|
|
259 |
080b4ce1
|
Ermal
|
# make some directories in /var
|
260 |
b6355bdc
|
jim-p
|
/bin/mkdir -p $varrunpath /var/log /var/etc /var/db/entropy /var/db/rrd /var/at/jobs/ /var/empty /var/log/nginx 2>/dev/null
|
261 |
3e20b9ca
|
Phil Davis
|
|
262 |
|
|
# turn off the immutable flag, set /var/empty to read-only, make it immutable again
|
263 |
|
|
chflags noschg /var/empty
|
264 |
c01bdca9
|
Renato Botelho
|
chmod 0555 /var/empty
|
265 |
3e20b9ca
|
Phil Davis
|
chflags schg /var/empty
|
266 |
|
|
|
267 |
080b4ce1
|
Ermal
|
/bin/rm -rf $varrunpath/*
|
268 |
|
|
|
269 |
9e9bc51c
|
Ermal
|
# Cleanup configuration files from previous instance
|
270 |
|
|
/bin/rm -rf /var/etc/*
|
271 |
|
|
|
272 |
96fcf698
|
Renato Botelho
|
# Workaround for ipsec symlinks, otherwise it's going to break
|
273 |
|
|
# strongswan pkg upgrade
|
274 |
|
|
|
275 |
|
|
if [ -L /usr/local/etc/ipsec.d ]; then
|
276 |
|
|
rm -f /usr/local/etc/ipsec.d
|
277 |
|
|
fi
|
278 |
|
|
if [ -L /usr/local/etc/ipsec.conf ]; then
|
279 |
|
|
rm -f /usr/local/etc/ipsec.conf
|
280 |
|
|
fi
|
281 |
47220a8c
|
Renato Botelho
|
if [ -L /usr/local/etc/strongswan.d ]; then
|
282 |
|
|
rm -f /usr/local/etc/strongswan.d
|
283 |
|
|
fi
|
284 |
96fcf698
|
Renato Botelho
|
if [ -L /usr/local/etc/strongswan.conf ]; then
|
285 |
|
|
rm -f /usr/local/etc/strongswan.conf
|
286 |
|
|
fi
|
287 |
|
|
|
288 |
fc84b222
|
Renato Botelho
|
# Remove deprecated symlinks - #5538
|
289 |
|
|
for f in /etc/hosts \
|
290 |
|
|
/etc/resolv.conf \
|
291 |
|
|
/etc/resolvconf.conf \
|
292 |
|
|
/etc/syslog.conf; do
|
293 |
|
|
if [ -L "${f}" ]; then
|
294 |
|
|
rm -f ${f}
|
295 |
9e9bc51c
|
Ermal
|
fi
|
296 |
fc84b222
|
Renato Botelho
|
done
|
297 |
30501526
|
Warren Baker
|
|
298 |
4be3f6cf
|
Seth Mos
|
# Make sure our /tmp is 777 + Sticky
|
299 |
e8d0903d
|
Ermal
|
/bin/chmod 1777 /tmp
|
300 |
0652f3ae
|
Seth Mos
|
|
301 |
6484bb83
|
Scott Ullrich
|
if [ ! -L /etc/dhclient.conf ]; then
|
302 |
e173dd74
|
Phil Davis
|
/bin/rm -rf /etc/dhclient.conf
|
303 |
6484bb83
|
Scott Ullrich
|
fi
|
304 |
c8fcdb2f
|
Scott Ullrich
|
|
305 |
544156a7
|
Scott Ullrich
|
if [ ! -d /var/tmp ]; then
|
306 |
e8d0903d
|
Ermal
|
/bin/mkdir -p /var/tmp
|
307 |
544156a7
|
Scott Ullrich
|
fi
|
308 |
fc1caa41
|
Renato Botelho
|
# Make sure our /var/tmp is 777 + Sticky
|
309 |
bc8eedaa
|
Renato Botelho
|
/bin/chmod 1777 /var/tmp
|
310 |
4aa70cd8
|
Scott Ullrich
|
|
311 |
5b237745
|
Scott Ullrich
|
set -T
|
312 |
|
|
trap "echo 'Reboot interrupted'; exit 1" 3
|
313 |
|
|
|
314 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
315 |
a5c36eb2
|
Renato Botelho
|
DISABLESYSLOGCLOG=$(/usr/local/sbin/read_xml_tag.sh boolean system/disablesyslogclog)
|
316 |
586c623a
|
jim-p
|
LOG_FILES="system filter dhcpd vpn poes l2tps openvpn portalauth ipsec ppp wireless nginx ntpd gateways resolver routing"
|
317 |
c7a3356e
|
jim-p
|
|
318 |
a5c36eb2
|
Renato Botelho
|
DEFAULT_LOG_FILE_SIZE=$(/usr/local/sbin/read_xml_tag.sh string syslog/logfilesize)
|
319 |
|
|
DEFAULT_LOG_FILE_SIZE=${DEFAULT_LOG_FILE_SIZE:-"511488"}
|
320 |
c7a3356e
|
jim-p
|
|
321 |
973b2663
|
Ermal
|
for logfile in $LOG_FILES; do
|
322 |
a5c36eb2
|
Renato Botelho
|
if [ "$DISABLESYSLOGCLOG" = "true" ]; then
|
323 |
973b2663
|
Ermal
|
/usr/bin/touch /var/log/$logfile.log
|
324 |
e173dd74
|
Phil Davis
|
else
|
325 |
973b2663
|
Ermal
|
if [ ! -f /var/log/$logfile.log ]; then
|
326 |
41df62c1
|
jim-p
|
/usr/local/sbin/clog -i -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
|
327 |
e8197e56
|
Ermal
|
fi
|
328 |
e173dd74
|
Phil Davis
|
fi
|
329 |
973b2663
|
Ermal
|
done
|
330 |
|
|
|
331 |
41df62c1
|
jim-p
|
# change permissions on newly created log files.
|
332 |
e8d0903d
|
Ermal
|
/bin/chmod 0600 /var/log/*.log
|
333 |
8d418ca9
|
Scott Ullrich
|
|
334 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
335 |
6fa9f38c
|
Renato Botelho
|
DEVFS=`/sbin/mount | /usr/bin/grep devfs | /usr/bin/wc -l | /usr/bin/cut -d" " -f8`
|
336 |
|
|
if [ "$DEVFS" = "0" ]; then
|
337 |
|
|
mount_devfs devfs /dev
|
338 |
f93c5384
|
Scott Ullrich
|
fi
|
339 |
5b237745
|
Scott Ullrich
|
|
340 |
|
|
# Create an initial utmp file
|
341 |
7d3be92f
|
Ermal
|
cd $varrunpath && /bin/cp /dev/null utmp && /bin/chmod 644 utmp
|
342 |
5b237745
|
Scott Ullrich
|
|
343 |
2e269da2
|
Scott Ullrich
|
echo -n "."
|
344 |
6fe4f291
|
Scott Ullrich
|
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
|
345 |
05dd0c32
|
Ermal
|
/etc/rc.d/ldconfig start 2>/dev/null
|
346 |
c268f10f
|
Scott Ullrich
|
|
347 |
6fa9f38c
|
Renato Botelho
|
# Launching kbdmux(4)
|
348 |
|
|
if [ -f "/dev/kbdmux0" ]; then
|
349 |
|
|
echo -n "."
|
350 |
|
|
/usr/sbin/kbdcontrol -k /dev/kbdmux0 < /dev/console
|
351 |
|
|
[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
|
352 |
|
|
[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
|
353 |
|
|
fi
|
354 |
4e7b2b27
|
Scott Ullrich
|
|
355 |
6fa9f38c
|
Renato Botelho
|
# Fire up unionfs if mount points exist.
|
356 |
|
|
if [ -f /dist/uniondirs ]; then
|
357 |
|
|
echo -n "."
|
358 |
|
|
/etc/rc.d/unionfs start
|
359 |
b1ce7649
|
Scott Ullrich
|
fi
|
360 |
fa8f44ce
|
Scott Ullrich
|
|
361 |
2e269da2
|
Scott Ullrich
|
echo "done."
|
362 |
deff30cd
|
Scott Ullrich
|
|
363 |
ad0d7518
|
Scott Ullrich
|
# Recreate capabilities DB
|
364 |
416e6432
|
Ermal
|
/usr/bin/cap_mkdb /etc/login.conf
|
365 |
ad0d7518
|
Scott Ullrich
|
|
366 |
10511c3b
|
Renato Botelho
|
if [ -f /cf/conf/needs_package_sync ]; then
|
367 |
5f1becd8
|
Renato Botelho
|
skip_packages=1
|
368 |
747b31dc
|
Renato Botelho
|
fi
|
369 |
|
|
|
370 |
a5733f63
|
Renato Botelho
|
# Second upgrade stage
|
371 |
5f1becd8
|
Renato Botelho
|
[ -z "$skip_packages" ] \
|
372 |
8abca040
|
Renato Botelho
|
&& /usr/local/sbin/${product}-upgrade -y -U -b 2
|
373 |
842fc1e2
|
Renato Botelho
|
|
374 |
4ecaca5b
|
Renato Botelho
|
# Copy default openssl config file
|
375 |
|
|
[ -d /etc/ssl ] \
|
376 |
|
|
|| mkdir -p /etc/ssl
|
377 |
|
|
[ -f /usr/local/share/${product}/ssl/openssl.cnf ] \
|
378 |
|
|
&& cp -f /usr/local/share/${product}/ssl/openssl.cnf /etc/ssl
|
379 |
5051739d
|
Renato Botelho
|
mkdir -p /usr/local/openssl >/dev/null 2>&1
|
380 |
|
|
ln -sf /etc/ssl/openssl.cnf \
|
381 |
|
|
/usr/local/openssl/openssl.cnf
|
382 |
4ecaca5b
|
Renato Botelho
|
|
383 |
40e46009
|
Scott Ullrich
|
# Run the php.ini setup file and populate
|
384 |
3646fbcb
|
Renato Botelho
|
# /usr/local/etc/php.ini
|
385 |
aa840cf9
|
Scott Ullrich
|
/etc/rc.php_ini_setup 2>/tmp/php_errors.txt
|
386 |
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
|
387 |
0cf5aa69
|
Scott Ullrich
|
|
388 |
dc61252a
|
Renato Botelho
|
# Launch external configuration loader
|
389 |
|
|
/usr/local/sbin/fcgicli -f /etc/ecl.php
|
390 |
206f684d
|
Scott Ullrich
|
|
391 |
490615d3
|
Scott Ullrich
|
if [ -f /etc/rc.custom_boot_early ]; then
|
392 |
|
|
/bin/echo -n "Launching /etc/rc.custom_boot_early...";
|
393 |
|
|
/etc/rc.custom_boot_early
|
394 |
|
|
echo "Done"
|
395 |
|
|
fi
|
396 |
|
|
|
397 |
4aea91d8
|
Ermal
|
export fcgipath=/var/run/php-fpm.socket
|
398 |
01599e5e
|
Ermal
|
/usr/bin/nice -n20 /usr/local/sbin/check_reload_status
|
399 |
e8d0903d
|
Ermal
|
|
400 |
b406ae66
|
Scott Ullrich
|
# let the PHP-based configuration subsystem set up the system now
|
401 |
8e2eb65e
|
Scott Ullrich
|
echo -n "Launching the init system..."
|
402 |
e8d0903d
|
Ermal
|
/bin/rm -f /cf/conf/backup/backup.cache
|
403 |
|
|
/usr/bin/touch $varrunpath/booting
|
404 |
217935fe
|
Ermal LUÇI
|
|
405 |
ce9056f6
|
Renato Botelho
|
# Copy custom logo over if it's present
|
406 |
|
|
if [ -d /usr/local/share/${product}/custom_logos ]; then
|
407 |
c8735982
|
Renato Botelho
|
cp -f /usr/local/share/${product}/custom_logos/*svg \
|
408 |
ce9056f6
|
Renato Botelho
|
/usr/local/www
|
409 |
c8735982
|
Renato Botelho
|
cp -f /usr/local/share/${product}/custom_logos/*css \
|
410 |
|
|
/usr/local/www/css
|
411 |
ce9056f6
|
Renato Botelho
|
fi
|
412 |
|
|
|
413 |
1b20a4a6
|
Renato Botelho
|
# Apply CPU microcode update
|
414 |
|
|
[ -x /usr/local/etc/rc.d/microcode_update ] \
|
415 |
|
|
&& /usr/local/etc/rc.d/microcode_update onestart
|
416 |
|
|
|
417 |
b406ae66
|
Scott Ullrich
|
/etc/rc.bootup
|
418 |
|
|
|
419 |
f658bac7
|
Ermal LUÇI
|
# /etc/rc.bootup unset $g['booting'], and removes file
|
420 |
|
|
# Be sure the file is removed to not create troubles after
|
421 |
|
|
if [ -f $varrunpath/booting ]; then
|
422 |
|
|
/bin/rm $varrunpath/booting
|
423 |
|
|
fi
|
424 |
5551d818
|
Renato Botelho
|
|
425 |
0c5e431d
|
Scott Ullrich
|
echo -n "Starting CRON... "
|
426 |
ea83ac64
|
Scott Ullrich
|
cd /tmp && /usr/sbin/cron -s 2>/dev/null
|
427 |
0c5e431d
|
Scott Ullrich
|
echo "done."
|
428 |
3e08b3c1
|
Scott Ullrich
|
|
429 |
e8d0903d
|
Ermal
|
/bin/rm -rf /usr/local/pkg/pf/CVS
|
430 |
bc086d51
|
Scott Ullrich
|
|
431 |
0092b3bd
|
mgrooms
|
# Start ping handler every 240 seconds
|
432 |
7d3be92f
|
Ermal
|
/usr/local/bin/minicron 240 $varrunpath/ping_hosts.pid /usr/local/bin/ping_hosts.sh
|
433 |
f2025e91
|
Scott Ullrich
|
|
434 |
0092b3bd
|
mgrooms
|
# Start account expire handler every hour
|
435 |
1590947b
|
Ermal
|
/usr/local/bin/minicron 3600 $varrunpath/expire_accounts.pid '/usr/local/sbin/fcgicli -f /etc/rc.expireaccounts'
|
436 |
0092b3bd
|
mgrooms
|
|
437 |
f6ba4bd1
|
Scott Ullrich
|
# Start alias url updater every 24 hours
|
438 |
1590947b
|
Ermal
|
/usr/local/bin/minicron 86400 $varrunpath/update_alias_url_data.pid '/usr/local/sbin/fcgicli -f /etc/rc.update_alias_url_data'
|
439 |
f6ba4bd1
|
Scott Ullrich
|
|
440 |
c432da9c
|
Scott Ullrich
|
/bin/chmod a+rw /tmp/.
|
441 |
b569598b
|
Scott Ullrich
|
|
442 |
52398a6b
|
jim-p
|
# Check for GEOM mirrors
|
443 |
|
|
GMIRROR_STATUS=`/sbin/gmirror status`
|
444 |
|
|
if [ "${GMIRROR_STATUS}" != "" ]; then
|
445 |
|
|
# Using a flag file at bootup saves an expensive exec/check on each page load.
|
446 |
|
|
/usr/bin/touch /var/run/gmirror_active
|
447 |
|
|
# Setup monitoring/notifications
|
448 |
|
|
/usr/local/bin/minicron 60 /var/run/gmirror_status_check.pid /usr/local/sbin/gmirror_status_check.php
|
449 |
|
|
fi
|
450 |
|
|
|
451 |
5f1becd8
|
Renato Botelho
|
[ -z "$skip_packages" ] \
|
452 |
8abca040
|
Renato Botelho
|
&& /usr/local/sbin/${product}-upgrade -y -U -b 3
|
453 |
a5733f63
|
Renato Botelho
|
|
454 |
6f2bad18
|
Renato Botelho
|
# Start packages
|
455 |
5f1becd8
|
Renato Botelho
|
[ -z "$skip_packages" ] \
|
456 |
|
|
&& /usr/local/sbin/fcgicli -f /etc/rc.start_packages
|
457 |
6f2bad18
|
Renato Botelho
|
|
458 |
e506cc8a
|
Renato Botelho
|
# Update pkg metadata
|
459 |
|
|
/etc/rc.update_pkg_metadata now
|
460 |
|
|
|
461 |
dcafc712
|
Adam Gibson
|
# Log product version to syslog
|
462 |
55f81e30
|
Phil Davis
|
get_version
|
463 |
4982e61e
|
Adam Gibson
|
BUILDTIME=`cat /etc/version.buildtime`
|
464 |
|
|
ARCH=`uname -m`
|
465 |
dc61252a
|
Renato Botelho
|
echo "$product ${version}${version_patch} $ARCH $BUILDTIME"
|
466 |
4982e61e
|
Adam Gibson
|
|
467 |
e393a4a8
|
Scott Ullrich
|
echo "Bootup complete"
|
468 |
1ba9533c
|
Scott Ullrich
|
|
469 |
2d4be1c5
|
Scott Ullrich
|
/usr/local/bin/beep.sh start 2>&1 >/dev/null
|
470 |
e393a4a8
|
Scott Ullrich
|
|
471 |
4171fa68
|
Scott Ullrich
|
# Reset the cache. read-only requires this.
|
472 |
7734aea6
|
Andrew Thompson
|
/bin/rm -f /tmp/config.cache
|
473 |
4171fa68
|
Scott Ullrich
|
|
474 |
d35cf0de
|
Scott Ullrich
|
exit 0
|