Project

General

Profile

Download (16.2 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
# /etc/rc.firmware
4
# originally part of m0n0wall (http://neon1.net/m0n0wall)
5
# Copyright (C) 2005-2009 Scott Ullrich <sullrich@pfsense.org>.
6
# Copyright (C) 2003 Manuel Kasper <mk@neon1.net>.
7
# All rights reserved.
8

    
9
# mount /cf
10
/etc/rc.conf_mount_rw
11

    
12
# Reset file(s)
13
echo "" >/conf/upgrade_log.txt
14
echo "" >/conf/firmware_update_misc_log.txt
15
echo "" >/conf/fdisk_upgrade_log.txt
16

    
17
exec 3>&2 2>>/conf/firmware_update_misc_log.txt
18

    
19
export ACTION=$1
20
export IMG=$2
21
if [ $# -eq 3 ]; then
22
	export CUSTOMIMG=$3
23
fi
24

    
25
if [ $ACTION != "upgrade" ]; then
26
	/sbin/umount -f /ftmp > /dev/null 2>&1
27
fi
28

    
29
file_notice() {
30
	/usr/local/bin/php -q -d auto_prepend_file=config.inc <<ENDOFF
31
	<?php
32
		require_once("globals.inc");		
33
		require_once("functions.inc");
34
		file_notice("$1", "$2", "$1", "");
35
	?>
36
ENDOFF
37
}
38

    
39
output_env_to_log() {
40
	date >> /conf/upgrade_log.txt
41
	echo "" >> /conf/upgrade_log.txt
42
	
43
	ls -lah /dev/ >> /conf/upgrade_log.txt
44
	echo "" >> /conf/upgrade_log.txt
45

    
46
	ls -lah $IMG >> /conf/upgrade_log.txt
47
	echo "" >> /conf/upgrade_log.txt
48

    
49
	md5 $IMG >> /conf/upgrade_log.txt
50
	echo "" >> /conf/upgrade_log.txt
51

    
52
	mount >> /conf/upgrade_log.txt
53
	echo "" >> /conf/upgrade_log.txt
54

    
55
	top >> /conf/upgrade_log.txt
56
	echo "" >> /conf/upgrade_log.txt
57
}
58

    
59
backup_chflags() {
60
	TOPROCESS="bin lib libexec sbin usr"
61
	for files in $TOPROCESS; do
62
		/usr/sbin/mtree -Pcp /${files} | bzip2 -9 > /tmp/chflags.dist.${files}.bz2 2>> /conf/upgrade_log.txt 
63
	done
64
}
65

    
66
restore_chflags() {
67
	TOPROCESS="bin lib libexec sbin usr"
68
	for files in $TOPROCESS; do
69
		cd / && /usr/bin/bzcat /tmp/chflags.dist.${files}.bz2 | /usr/sbin/mtree -PU -p /${files} >> /conf/upgrade_log.txt 2>&1
70
	done
71
}
72

    
73
remove_chflags() {
74
	TOPROCESS="bin lib libexec sbin usr"
75
	for files in $TOPROCESS; do
76
		/bin/chflags -R noschg /${files}
77
		/bin/chmod -R u+rw /${files}
78
	done
79
}
80

    
81
binary_update() {
82
	TGZ=$1
83
	ERR_F="/tmp/bdiff.log"
84
	rm ${ERR_F} 2>/dev/null
85
	/bin/mkdir /tmp/patched /tmp/patches 2>>${ERR_F}
86
	# Save the old shutdown binary. If we switch from i386 to amd64 (or back) the reboot binary won't run at the end since it doesn't match up.
87
	/bin/cp -p /sbin/shutdown /sbin/shutdown.old
88
	backup_chflags
89
	remove_chflags
90
	cd /tmp/patches
91
	for i in `/usr/bin/tar tvzf $TGZ | egrep -v "(^d|_md5)" | nawk '{print $9;}'`;
92
	 do
93
	   FILE=`basename ${i}`
94
	   echo "Working on ${i}"
95
	   # Untar patch file and md5 files
96
	   /usr/bin/tar xzf ${TGZ} ${i} ${i}.old_file_md5 ${i}.new_patch_md5 ${i}.new_file_md5 2>>${ERR_F}
97

    
98
	   # Apply patch - oldfile newfile patchfile
99
	   /usr/local/bin/bspatch /${i} /tmp/patched/${FILE} /tmp/patches/${i} 2>>${ERR_F}
100

    
101
	   OLD_FILE_MD5=`cat /tmp/patches/${i}.old_file_md5 2>/dev/null`
102
	   NEW_PATCH_MD5=`cat /tmp/patches/${i}.new_patch_md5 2>/dev/null`
103
	   NEW_FILE_MD5=`cat /tmp/patches/${i}.new_file_md5 2>/dev/null`
104
	   PATCHED_MD5=`/sbin/md5 -q /tmp/patched/${FILE} 2>/dev/null`
105

    
106
	   if [ "$PATCHED_MD5" = "$NEW_PATCH_MD5" ]; then
107
		/usr/bin/install -S  /tmp/patched/${FILE} /${i}
108
	   else
109
		#echo "${i} file does not match intended final md5."
110
		echo "${i} file does not match intended final md5." >> ${ERR_F}
111
	   fi
112

    
113
	   /bin/rm /tmp/patched/${FILE} >> ${ERR_F}
114
	   /bin/rm /tmp/patches/${i} >> ${ERR_F}
115
	   /bin/rm /tmp/patches/${i}.* >> ${ERR_F}
116
	done
117
	/bin/rm -rf /tmp/patched /tmp/patches >> ${ERR_F}
118
	restore_chflags
119
}
120

    
121
case $ACTION in
122
enable)
123
	touch /conf/upgrade_log.txt
124
	echo "" >> /conf/upgrade_log.txt
125
	echo "Enable" >> /conf/upgrade_log.txt
126
	echo "" >> /conf/upgrade_log.txt		
127
	/etc/rc.conf_mount_ro
128
	;;
129
auto)
130
	touch /var/run/firmwarelock.dirty
131
	backup_chflags
132
	remove_chflags
133
	/etc/rc.firmware_auto
134
	restore_chflags
135
	/etc/rc.conf_mount_ro
136
	;;
137
pfSenseNanoBSDupgrade)
138

    
139
	# Sanity check - bail early if there's no firmware file!
140
	if [ ! -r $IMG ]; then
141
		echo "2nd parameter has not been passed or file does not exist. Exiting." >> /conf/upgrade_log.txt 2>&1
142
		/etc/rc.conf_mount_ro
143
		exit 1
144
	fi
145

    
146
	# Prevent full upgrade file from being used to upgrade
147
	if [ `echo $IMG | grep "full"` ]; then
148
		echo "You cannot use a full file for upgrade.  Please use a file labeled nanobsd upgrade."
149
		file_notice "NanoBSDUpgradeFailure" "You have attemped to use a full NanoBSD installation file as an upgrade.  Please use a NanoBSD file labeled 'upgrade' instead."
150
		rm -f $IMG
151
		/etc/rc.conf_mount_ro		
152
		exit 1
153
	fi
154

    
155
	touch /var/run/firmwarelock.dirty
156

    
157
	echo "NanoBSD Firmware upgrade in progress..."  >> /conf/upgrade_log.txt 2>&1
158
	echo "NanoBSD Firmware upgrade in progress..." | wall
159
	/etc/rc.firmware_notify -e -g -m "NanoBSD Firmware upgrade in progress..."
160
	
161
	# backup config
162
	/bin/mkdir -p /tmp/configbak
163
	cp -Rp /conf/* /tmp/configbak 2>/dev/null
164

    
165
	# Remove logs from backup dir to avoid clobbering upon restore.
166
	rm /tmp/configbak/*_log.txt 2>/dev/null
167

    
168
	echo "" >> /conf/upgrade_log.txt
169

    
170
	echo "Installing ${IMG}." >> /conf/upgrade_log.txt 2>&1
171
	echo "Installing ${IMG}." | wall
172

    
173
	# resolve glabel label that we booted from
174
	BOOT_DEVICE=`/sbin/mount | /usr/bin/grep pfsense | /usr/bin/cut -d'/' -f4 | /usr/bin/cut -d' ' -f1`
175
	# resolve glabel to the real boot dev entry
176
	REAL_BOOT_DEVICE=`/sbin/glabel list | /usr/bin/grep -B2 ufs/${BOOT_DEVICE} | /usr/bin/head -n 1 | /usr/bin/cut -f3 -d' '`
177
	# grab the boot device, example ad1, ad0
178
	BOOT_DRIVE=`/sbin/glabel list | /usr/bin/grep -B2 ufs/pfsense | /usr/bin/head -n 1 | /usr/bin/cut -f3 -d' ' | /usr/bin/cut -d's' -f1`
179
	# test the slice.  if we are on slice 1 we need to flash 2 and vica versa
180
	if [ `echo $REAL_BOOT_DEVICE | /usr/bin/grep "s1"` ]; then 
181
		SLICE="2"
182
		OLDSLICE="1"
183
		TOFLASH="${BOOT_DRIVE}s${SLICE}"
184
		COMPLETE_PATH="${BOOT_DRIVE}s${SLICE}a"
185
		GLABEL_SLICE="pfsense1"
186
		UFS_ID="1"
187
		OLD_UFS_ID="0"
188
	else
189
		SLICE="1"
190
		OLDSLICE="2"		
191
		TOFLASH="${BOOT_DRIVE}s${SLICE}"
192
		COMPLETE_PATH="${BOOT_DRIVE}s${SLICE}a"
193
		GLABEL_SLICE="pfsense0"
194
		UFS_ID="0"
195
		OLD_UFS_ID="1"
196
	fi
197

    
198
	# Output specifc information that this script is using
199
	echo "SLICE         ${SLICE}" >> /conf/upgrade_log.txt
200
	echo "OLDSLICE      ${OLDSLICE}" >> /conf/upgrade_log.txt
201
	echo "TOFLASH       ${TOFLASH}" >> /conf/upgrade_log.txt
202
	echo "COMPLETE_PATH ${COMPLETE_PATH}" >> /conf/upgrade_log.txt
203
	echo "GLABEL_SLICE  ${GLABEL_SLICE}" >> /conf/upgrade_log.txt
204

    
205
	# First ensure the new file can fit inside the 
206
	# slice that we are going to be operating on.
207
	NEW_IMG_SIZE=`echo $((\`gzip -l ${IMG} | grep -v compressed | awk '{ print $2}'\` / 1024 / 1024))`
208
	SIZE=`/sbin/fdisk ${COMPLETE_PATH} | /usr/bin/grep Meg | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d"(" -f2`
209
	SIZE=`expr $SIZE + 1`
210
	if [ "$SIZE" -lt "$NEW_IMG_SIZE" ]; then
211
		file_notice "UpgradeFailure" "Upgrade failed due to the upgrade image being larger than the partition that is configured on disk.  Halting. Size on disk: $SIZE < Size of new image: $NEW_IMG_SIZE"
212
		echo "Upgrade failed.  Please check the system log file for more information" | wall
213
		rm -f $IMG
214
		rm -f /var/run/firmwarelock.dirty
215
		rm -f /var/run/firmware.lock
216
		rm -f ${IMG}
217
		/etc/rc.conf_mount_ro		
218
		exit 1
219
	fi
220

    
221
	# Output environment information to log file
222
	output_env_to_log
223
	
224
	# Grab a before upgrade look at fdisk
225
	echo "" >> /conf/fdisk_upgrade_log.txt
226
	echo "Before upgrade fdisk/bsdlabel" >> /conf/fdisk_upgrade_log.txt
227
	fdisk $BOOT_DRIVE >> /conf/fdisk_upgrade_log.txt
228
	bsdlabel -A ${BOOT_DRIVE}s1 >> /conf/fdisk_upgrade_log.txt
229
	bsdlabel -A ${BOOT_DRIVE}s2 >> /conf/fdisk_upgrade_log.txt
230
	bsdlabel -A ${BOOT_DRIVE}s3 >> /conf/fdisk_upgrade_log.txt
231
	echo "---------------------------------------------------------------" >> /conf/fdisk_upgrade_log.txt
232
	echo "" >> /conf/fdisk_upgrade_log.txt
233
	
234
	# Log that we are really doing a NanoBSD upgrade
235
	echo "" >> /conf/upgrade_log.txt
236
	echo "NanoBSD upgrade starting" >> /conf/upgrade_log.txt
237
	echo "" >> /conf/upgrade_log.txt
238

    
239
	# Remove TOFLASH and get ready for new flash image
240
	echo "" >> /conf/upgrade_log.txt
241
	echo "dd if=/dev/zero of=/dev/${TOFLASH} bs=1m count=1" >> /conf/upgrade_log.txt	
242
	dd if=/dev/zero of=/dev/${TOFLASH} bs=1m count=1 >> /conf/upgrade_log.txt 2>&1
243

    
244
	# Stream gzipped image to dd and explode image to new area
245
	echo "" >> /conf/upgrade_log.txt
246
	echo "/usr/bin/gzip -dc $IMG | /bin/dd of=/dev/${TOFLASH} obs=64k" >> /conf/upgrade_log.txt
247
	/usr/bin/gzip -dc $IMG | /bin/dd of=/dev/${TOFLASH} obs=64k >> /conf/upgrade_log.txt 2>&1
248

    
249
	# Grab a after upgrade look at fdisk
250
	echo "" >> /conf/fdisk_upgrade_log.txt
251
	echo "After upgrade fdisk/bsdlabel" >> /conf/upgrade_log.txt
252
	fdisk $BOOT_DRIVE >> /conf/fdisk_upgrade_log.txt
253
	bsdlabel -A ${BOOT_DRIVE}s1 >> /conf/fdisk_upgrade_log.txt
254
	bsdlabel -A ${BOOT_DRIVE}s2 >> /conf/fdisk_upgrade_log.txt
255
	bsdlabel -A ${BOOT_DRIVE}s3 >> /conf/fdisk_upgrade_log.txt
256
	echo "---------------------------------------------------------------" >> /conf/fdisk_upgrade_log.txt
257
	echo "" >> /conf/fdisk_upgrade_log.txt
258
	
259
	# Ensure that our new system is sound and bail if it is not and file a notice
260
	echo "" >> /conf/upgrade_log.txt
261
	echo "/sbin/fsck_ufs -y /dev/${COMPLETE_PATH}" >> /conf/upgrade_log.txt
262
	/sbin/fsck_ufs -y /dev/${COMPLETE_PATH} >> /conf/upgrade_log.txt 2>&1
263
	if [ $? != 0 ]; then
264
		file_notice "UpgradeFailure" "{\$g['product_name']} upgrade has failed.   Your system has been left in a usable state."
265
		rm -f $IMG
266
		rm -f /var/run/firmwarelock.dirty
267
		rm -f /var/run/firmware.lock
268
		/etc/rc.conf_mount_ro		
269
		exit 1
270
	fi
271

    
272
	# Enable foot shooting
273
	sysctl kern.geom.debugflags=16
274

    
275
	# Add back the corresponding glabel
276
	echo "" >> /conf/upgrade_log.txt
277
	echo "/sbin/tunefs -L ${GLABEL_SLICE} /dev/${COMPLETE_PATH}" >> /conf/upgrade_log.txt
278
	/sbin/tunefs -L ${GLABEL_SLICE} /dev/${COMPLETE_PATH} >> /conf/upgrade_log.txt 2>&1
279

    
280
	# restore config
281
	cp -Rp /tmp/configbak/* /conf 2>/dev/null
282

    
283
	# Remove upgrade file
284
	rm -f $IMG
285

    
286
	# Mount newly prepared slice
287
	mkdir /tmp/$GLABEL_SLICE
288
	mount /dev/ufs/$GLABEL_SLICE /tmp/$GLABEL_SLICE
289

    
290
	# If /tmp/$GLABEL_SLICE/tmp/post_upgrade_command exists 
291
	# after update then execute the command.
292
	if [ -f /tmp/$GLABEL_SLICE/tmp/post_upgrade_command ]; then
293
		sh /tmp/$GLABEL_SLICE/tmp/post_upgrade_command >> /conf/upgrade_log.txt 2>&1
294
	fi
295

    
296
	# Update fstab
297
	cp /etc/fstab /tmp/$GLABEL_SLICE/etc/fstab
298
	sed -i "" "s/pfsense${OLD_UFS_ID}/pfsense${UFS_ID}/g" /tmp/$GLABEL_SLICE/etc/fstab
299
	if [ $? != 0 ]; then
300
		echo "Something went wrong when trying to update the fstab entry.  Aborting upgrade."
301
		file_notice "UpgradeFailure" "Something went wrong when trying to update the fstab entry.  Aborting upgrade."
302
		rm -f $IMG
303
		rm -f /var/run/firmwarelock.dirty
304
		rm -f /var/run/firmware.lock
305
		umount /tmp/$GLABEL_SLICE
306
		/etc/rc.conf_mount_ro
307
		exit 1
308
	fi
309
	echo "" >> /conf/upgrade_log.txt
310
	cat /tmp/$GLABEL_SLICE/etc/fstab >> /conf/upgrade_log.txt
311

    
312
	echo "" >> /conf/upgrade_log.txt
313
	find /tmp/$GLABEL_SLICE >/conf/file_upgrade_log.txt
314
	echo "" >> /conf/upgrade_log.txt
315

    
316
	# Unmount newly prepared slice
317
	umount /tmp/$GLABEL_SLICE
318
	
319
	sync
320

    
321
	# Set active mount slice in fdisk
322
	echo "" >> /conf/upgrade_log.txt
323
	echo "gpart set -a active -i ${SLICE} ${BOOT_DRIVE}" >> /conf/upgrade_log.txt
324
	gpart set -a active -i ${SLICE} ${BOOT_DRIVE} >> /conf/upgrade_log.txt 2>&1
325

    
326
	sync
327

    
328
	# Set active boot source - NanoBSD does not do this but otherwise we
329
	# end up with the wrong partition being active.
330
	echo "" >> /conf/upgrade_log.txt
331
	echo "/usr/sbin/boot0cfg -s ${SLICE} -v /dev/${BOOT_DRIVE}" >> /conf/upgrade_log.txt
332
	/usr/sbin/boot0cfg -s ${SLICE} -v /dev/${BOOT_DRIVE} >> /conf/upgrade_log.txt 2>&1
333

    
334
	# Disable foot shooting
335
	sysctl kern.geom.debugflags=0
336

    
337
	# Grab a final look at fdisk
338
	echo "" >> /conf/fdisk_upgrade_log.txt
339
	echo "Final upgrade fdisk/bsdlabel" >> /conf/fdisk_upgrade_log.txt
340
	fdisk $BOOT_DRIVE >> /conf/fdisk_upgrade_log.txt
341
	bsdlabel -A ${BOOT_DRIVE}s1 >> /conf/fdisk_upgrade_log.txt
342
	bsdlabel -A ${BOOT_DRIVE}s2 >> /conf/fdisk_upgrade_log.txt
343
	bsdlabel -A ${BOOT_DRIVE}s3 >> /conf/fdisk_upgrade_log.txt
344
	echo "---------------------------------------------------------------" >> /conf/fdisk_upgrade_log.txt
345
	echo "" >> /conf/fdisk_upgrade_log.txt
346

    
347
	# Remove extra stuff
348
	rm -rf /etc/rc.conf
349
	rm -rf /etc/motd
350
	rm -rf /usr/savecore/*
351

    
352
	date >> /conf/upgrade_log.txt
353
	echo "" >> /conf/upgrade_log.txt
354

    
355
	# Trigger a package reinstallation on reobot
356
	touch /conf/needs_package_sync
357

    
358
	# remount /cf ro
359
	/etc/rc.conf_mount_ro
360
	/bin/sync
361

    
362
	echo "NanoBSD Firmware upgrade is complete.  Rebooting in 10 seconds."  >> /conf/upgrade_log.txt 2>&1
363
	echo "NanoBSD Firmware upgrade is complete.  Rebooting in 10 seconds." | wall
364
	/etc/rc.firmware_notify -e -g -m "NanoBSD Firmware upgrade is complete.  Rebooting in 10 seconds."
365

    
366
	sleep 10
367

    
368
	rm -f /var/run/firmwarelock.dirty
369
	rm -f /var/run/firmware.lock
370
	sh /etc/rc.reboot
371

    
372
	;;
373
pfSenseupgrade)
374

    
375
	# Sanity check - bail early if there's no firmware file!
376
	if [ ! -r $IMG ]; then
377
		echo "2nd parameter has not been passed or file does not exist. Exiting." >> /conf/upgrade_log.txt 2>&1
378
		/etc/rc.conf_mount_ro
379
		exit
380
	fi
381

    
382
	# wait 1 seconds before beginning
383
	sleep 1
384

    
385
	# Log that we are really doing a pfSense upgrade
386
	echo "" >> /conf/upgrade_log.txt
387
	echo "pfSenseupgrade upgrade starting" >> /conf/upgrade_log.txt
388
	echo "" >> /conf/upgrade_log.txt
389

    
390
	touch /var/run/firmwarelock.dirty
391

    
392
	touch /conf/upgrade_log.txt
393
	echo "" >> /conf/upgrade_log.txt
394

    
395
	# Output environment information to log file
396
	output_env_to_log
397

    
398
	backup_chflags
399
	remove_chflags
400

    
401
	# Do we have a pre-upgrade hook in the update file?
402
	if [ `tar tvzf $IMG | grep /tmp/pre_upgrade_command | wc -l` -gt 0 ]; then 
403
		tar xzvf $IMG -C / ./tmp/pre_upgrade_command >> /conf/upgrade_log.txt 2>&1
404
		chmod a+rx /tmp/pre_upgrade_command >> /conf/upgrade_log.txt 2>&1
405
		sh /tmp/pre_upgrade_command >> /conf/upgrade_log.txt 2>&1
406
	fi
407

    
408
	echo "Firmware upgrade in progress..."  >> /conf/upgrade_log.txt 2>&1
409
	echo "Firmware upgrade in progress..."  | wall
410
	/etc/rc.firmware_notify -e -g -m "Firmware upgrade in progress..."
411
	
412
	# backup config
413
	/bin/mkdir -p /tmp/configbak
414
	cp -Rp /conf/* /tmp/configbak 2>/dev/null
415

    
416
	# Remove logs from backup dir to avoid clobbering upon restore.
417
	rm /tmp/configbak/*_log.txt 2>/dev/null
418

    
419
	# tar explode image onto hd
420
	echo "Installing $IMG." >> /conf/upgrade_log.txt 2>&1
421
	cd / && /usr/bin/tar xzUPf $IMG >> /conf/upgrade_log.txt 2>&1
422
	/usr/bin/find / -name CVS -exec rm -fr {} \;
423
	echo "Image installed $IMG." >> /conf/upgrade_log.txt 2>&1
424

    
425
    # process custom image if its passed
426
    if [ $# -eq 3 ]; then
427
	    if [ -f $CUSTOMIMG ]; then
428
	        echo "Custom image $CUSTOMIMG found." >> /conf/upgrade_log.txt 2>&1
429
	        echo "Custom image ($CUSTOMIMG) found." >> /conf/upgrade_log.txt 2>&1
430
	        PWD_DIR=`pwd`
431
	        cd / && /usr/bin/tar xzPUf $CUSTOMIMG >> /conf/upgrade_log.txt 2>&1
432
	        cd $PWD_DIR
433
	        echo "Custom image $CUSTOMIMG installed." >> /conf/upgrade_log.txt 2>&1
434
	    fi
435
    fi
436

    
437
	# restore config
438
	cp -Rp /tmp/configbak/* /conf 2>/dev/null
439

    
440
	# restore /etc symlinks
441
	rm /etc/hosts
442
	ln -s /var/etc/hosts /etc/hosts
443

    
444
	restore_chflags
445

    
446
	# Remove upgrade file
447
	rm -f $IMG
448

    
449
	if [ -e /etc/init_bootloader.sh ]; then
450
		sh /etc/init_bootloader.sh >> /conf/upgrade_log.txt 2>&1
451
	fi
452

    
453
	# If /tmp/post_upgrade_command exists after update
454
	# then execute the command.
455
	if [ -f /tmp/post_upgrade_command ]; then
456
		sh /tmp/post_upgrade_command >> /conf/upgrade_log.txt 2>&1
457
	fi
458

    
459
	# remove unused files
460
	rm -rf /etc/rc.conf
461
	rm -rf /etc/motd
462
	rm -rf /usr/savecore/*
463

    
464
	date >> /conf/upgrade_log.txt
465
	echo "" >> /conf/upgrade_log.txt
466

    
467
	# remount /cf ro
468
	/etc/rc.conf_mount_ro
469

    
470
	# release the firmware lock
471
	rm -f /var/run/firmwarelock.dirty
472
	rm -f /var/run/firmware.lock
473
	/bin/sync
474

    
475
	echo "Firmware upgrade is complete. Rebooting in 10 seconds."  >> /conf/upgrade_log.txt 2>&1
476
	echo "Firmware upgrade is complete. Rebooting in 10 seconds."  | wall
477
	/etc/rc.firmware_notify -e -g -m "Firmware upgrade is complete. Rebooting in 10 seconds."
478

    
479
	# Sleep and allow disks to catch up
480
	sleep 10
481

    
482
	# If the archive has unpacked a file called
483
	# /tmp/no_upgrade_reboot_required then do
484
	# not reboot after upgrade.
485
	if [ -f /tmp/no_upgrade_reboot_required ]; then
486
		rm /tmp/no_upgrade_reboot_required
487
	else
488
		rm -f /var/run/config.lock
489
		sh /etc/rc.reboot
490
	fi
491

    
492
	;;
493
delta_update)
494
	touch /var/run/firmwarelock.dirty
495
	backup_chflags
496
	remove_chflags
497
	binary_update $IMG
498
	restore_chflags
499
	rm -rf /etc/rc.conf
500
	rm -rf /etc/motd
501
	find / -name CVS -type d -exec rm {} \;
502
	rm -rf /usr/savecore/*
503
	/etc/rc.conf_mount_ro
504
	/sbin/umount -f /cf 2>/dev/null
505
	/sbin/mount -r /cf 2>/dev/null
506
	/sbin/umount -f / 2>/dev/null
507
	/sbin/mount -r / 2>/dev/null
508
	if [ -e /etc/init_bootloader.sh ]; then
509
		sh /etc/init_bootloader.sh
510
	fi
511

    
512
	;;
513
esac
514

    
(48-48/95)