Project

General

Profile

Download (15.7 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
15
echo "" >/conf/fdisk_upgrade_log.txt
16

    
17
exec 3>&2 2>>/conf/firmware_update_misc.log
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
	backup_chflags
87
	remove_chflags
88
	cd /tmp/patches
89
	for i in `/usr/bin/tar tvzf $TGZ | egrep -v "(^d|_md5)" | nawk '{print $9;}'`;
90
	 do
91
	   FILE=`basename ${i}`
92
	   echo "Working on ${i}"
93
	   # Untar patch file and md5 files
94
	   /usr/bin/tar xzf ${TGZ} ${i} ${i}.old_file_md5 ${i}.new_patch_md5 ${i}.new_file_md5 2>>${ERR_F}
95

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

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

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

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

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

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

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

    
151
	touch /var/run/firmwarelock.dirty
152

    
153
	echo "NanoBSD Firmware upgrade in progress..."  >> /conf/upgrade_log.txt 2>&1
154
	echo "NanoBSD Firmware upgrade in progress..." | wall
155

    
156
	# backup config
157
	/bin/mkdir -p /tmp/configbak
158
	cp -p /conf/* /tmp/configbak 2>/dev/null
159

    
160
	echo "" >> /conf/upgrade_log.txt
161

    
162
	echo "Installing $IMG." >> /conf/upgrade_log.txt 2>&1
163
	echo "Installing $IMG." | wall
164

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

    
190
	# Output specifc information that this script is using
191
	echo "SLICE $SLICE" >> /conf/upgrade_log.txt
192
	echo "OLDSLICE $OLDSLICE" >> /conf/upgrade_log.txt
193
	echo "TOFLASH $TOFLASH" >> /conf/upgrade_log.txt
194
	echo "COMPLETE_PATH $COMPLETE_PATH" >> /conf/upgrade_log.txt
195
	echo "GLABEL_SLICE $GLABEL_SLICE" >> /conf/upgrade_log.txt
196

    
197
	# First ensure the new file can fit inside the 
198
	# slice that we are going to be operating on.
199
	NEW_IMG_SIZE=`echo $((\`gzip -l ${IMG} | grep -v compressed | awk '{ print $2}'\` / 1024 / 1024))`
200
	SIZE=`/sbin/fdisk ${COMPLETE_PATH} | /usr/bin/grep Meg | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d"(" -f2`
201
	SIZE=`expr $SIZE + 1`
202
	if [ "$SIZE" -lt "$NEW_IMG_SIZE" ]; then
203
		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"
204
		rm -f $IMG
205
		rm -f /var/run/firmwarelock.dirty
206
		rm -f /var/run/firmware.lock
207
		/etc/rc.conf_mount_ro
208
		exit 1
209
	fi
210

    
211
	# Output environment information to log file
212
	output_env_to_log
213
	
214
	# Grab a before upgrade look at fdisk
215
	echo "" >> /conf/fdisk_upgrade_log.txt
216
	echo "Before upgrade fdisk/bsdlabel" >> /conf/fdisk_upgrade_log.txt
217
	fdisk $BOOT_DRIVE >> /conf/fdisk_upgrade_log.txt
218
	fdisk $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
219
	fdisk $BOOT_DRIVEs1a >> /conf/fdisk_upgrade_log.txt
220
	fdisk $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
221
	fdisk $BOOT_DRIVEs2a >> /conf/fdisk_upgrade_log.txt		
222
	fdisk $BOOT_DRIVEs3 >> /conf/fdisk_upgrade_log.txt
223
	bsdlabel -A $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
224
	bsdlabel -A $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
225
	bsdlabel -A $BOOT_DRIVEs3 >> /conf/fdisk_upgrade_log.txt
226
	echo "---------------------------------------------------------------" >> /conf/fdisk_upgrade_log.txt
227
	echo "" >> /conf/fdisk_upgrade_log.txt
228
	
229
	# Log that we are really doing a NanoBSD upgrade
230
	echo "" >> /conf/upgrade_log.txt
231
	echo "NanoBSD upgrade starting" >> /conf/upgrade_log.txt
232
	echo "" >> /conf/upgrade_log.txt
233

    
234
	# Remove TOFLASH and get ready for new flash image
235
	echo "" >> /conf/upgrade_log.txt
236
	echo "dd if=/dev/zero of=/dev/${TOFLASH} bs=1m count=1" >> /conf/upgrade_log.txt	
237
	dd if=/dev/zero of=/dev/${TOFLASH} bs=1m count=1 >> /conf/upgrade_log.txt 2>&1
238

    
239
	# Stream gzipped image to dd and explode image to new area
240
	echo "" >> /conf/upgrade_log.txt
241
	echo "/usr/bin/gzip -dc $IMG | /bin/dd of=/dev/${TOFLASH} obs=64k" >> /conf/upgrade_log.txt
242
	/usr/bin/gzip -dc $IMG | /bin/dd of=/dev/${TOFLASH} obs=64k >> /conf/upgrade_log.txt 2>&1
243

    
244
	# Grab a after upgrade look at fdisk
245
	echo "" >> /conf/fdisk_upgrade_log.txt
246
	echo "After upgrade fdisk/bsdlabel" >> /conf/upgrade_log.txt
247
	fdisk $BOOT_DRIVE >> /conf/fdisk_upgrade_log.txt
248
	fdisk $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
249
	fdisk $BOOT_DRIVEs1a >> /conf/fdisk_upgrade_log.txt
250
	fdisk $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
251
	fdisk $BOOT_DRIVEs2a >> /conf/fdisk_upgrade_log.txt		
252
	fdisk $BOOT_DRIVEs3 >> /conf/fdisk_upgrade_log.txt
253
	bsdlabel -A $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
254
	bsdlabel -A $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
255
	bsdlabel -A $BOOT_DRIVEs3 >> /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 -p /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
	fdisk $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
342
	fdisk $BOOT_DRIVEs1a >> /conf/fdisk_upgrade_log.txt
343
	fdisk $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
344
	fdisk $BOOT_DRIVEs2a >> /conf/fdisk_upgrade_log.txt		
345
	fdisk $BOOT_DRIVEs3 >> /conf/fdisk_upgrade_log.txt
346
	bsdlabel -A $BOOT_DRIVEs1 >> /conf/fdisk_upgrade_log.txt
347
	bsdlabel -A $BOOT_DRIVEs2 >> /conf/fdisk_upgrade_log.txt
348
	bsdlabel -A $BOOT_DRIVEs3 >> /conf/fdisk_upgrade_log.txt
349
	echo "---------------------------------------------------------------" >> /conf/fdisk_upgrade_log.txt
350
	echo "" >> /conf/fdisk_upgrade_log.txt
351

    
352
	# Remove extra stuff
353
	rm -rf /etc/rc.conf
354
	rm -rf /etc/motd
355
	rm -rf /usr/savecore/*
356

    
357
	date >> /conf/upgrade_log.txt
358
	echo "" >> /conf/upgrade_log.txt
359

    
360
	# Trigger a package reinstallation on reobot
361
	touch /conf/needs_package_sync
362

    
363
	# remount /cf ro
364
	/etc/rc.conf_mount_ro
365
	/bin/sync
366

    
367
	sleep 10
368

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

    
373
	;;
374
pfSenseupgrade)
375

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

    
383
	# wait 1 seconds before beginning
384
	sleep 1
385

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

    
391
	touch /var/run/firmwarelock.dirty
392

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

    
396
	# Output environment information to log file
397
	output_env_to_log
398

    
399
	backup_chflags
400
	remove_chflags
401

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

    
409
	echo "Firmware upgrade in progress..."  >> /conf/upgrade_log.txt 2>&1
410
	echo "Firmware upgrade in progress..."  | wall
411

    
412
	# backup config
413
	/bin/mkdir -p /tmp/configbak
414
	cp -p /conf/* /tmp/configbak 2>/dev/null
415

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

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

    
434
	# restore config
435
	cp -p /tmp/configbak/* /conf 2>/dev/null
436

    
437
	# restore /etc symlinks
438
	rm /etc/hosts
439
	ln -s /var/etc/hosts /etc/hosts
440

    
441
	restore_chflags
442

    
443
	# Remove upgrade file
444
	rm -f $IMG
445

    
446
	if [ -e /etc/init_bootloader.sh ]; then
447
		sh /etc/init_bootloader.sh >> /conf/upgrade_log.txt 2>&1
448
	fi
449

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

    
456
	# remove unused files
457
	rm -rf /etc/rc.conf
458
	rm -rf /etc/motd
459
	rm -rf /usr/savecore/*
460

    
461
	date >> /conf/upgrade_log.txt
462
	echo "" >> /conf/upgrade_log.txt
463

    
464
	# remount /cf ro
465
	/etc/rc.conf_mount_ro
466

    
467
	# release the firmware lock
468
	rm -f /var/run/firmwarelock.dirty
469
	rm -f /var/run/firmware.lock
470
	/bin/sync
471

    
472
	# Sleep and allow disks to catch up
473
	sleep 10
474

    
475
	# If the archive has unpacked a file called
476
	# /tmp/no_upgrade_reboot_required then do
477
	# not reboot after upgrade.
478
	if [ -f /tmp/no_upgrade_reboot_required ]; then
479
		rm /tmp/no_upgrade_reboot_required
480
	else
481
		rm -f /var/run/config.lock
482
		sh /etc/rc.reboot
483
	fi
484

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

    
505
	;;
506
esac
507

    
508

    
(40-40/82)