Project

General

Profile

Download (2.03 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/bin/sh
2
3
# /etc/rc.firmware
4
# part of m0n0wall (http://neon1.net/m0n0wall)
5
#
6
# Copyright (C) 2003 Manuel Kasper <mk@neon1.net>.
7
# All rights reserved.
8
9 18ff56f2 Scott Ullrich
#CFDEVICE=`cat /var/etc/cfdevice`
10 5b237745 Scott Ullrich
11
if [ $1 != "upgrade" ]; then
12
	/sbin/umount -f /ftmp > /dev/null 2>&1
13
fi
14
15
case $1 in
16
enable)
17
	/sbin/mount_mfs -s 15360 -T qp120at -b 8192 -f 1024 dummy /ftmp \
18
		> /dev/null 2>&1
19
	;;
20 18ff56f2 Scott Ullrich
auto)
21
	/etc/rc.firmware_auto
22
	;;
23 5b237745 Scott Ullrich
upgrade)
24
	# wait 5 seconds before beginning
25
	sleep 5
26
27
	exec </dev/console >/dev/console 2>/dev/console
28
29
	echo
30 be3239e3 Scott Ullrich
	echo "Firmware upgrade in progress..."  | logger -p daemon.info -i -t Upgrade
31 5b237745 Scott Ullrich
32
	# backup config
33
	mkdir /tmp/configbak
34
	cp -p /conf/* /tmp/configbak
35
36
	# unmount /cf
37
	/sbin/umount -f /cf
38
39
	# dd image onto card
40
	if [ -r $2 ]; then
41
		/usr/bin/gunzip -S "" -c $2 | dd of=/dev/r$CFDEVICE bs=16k > /dev/null 2>&1
42
		echo "Image installed."
43
	fi
44
45
	# mount /cf
46
	/sbin/mount -w -o noatime /cf
47
48
	# restore config
49
	cp -p /tmp/configbak/* /conf
50
51
	# remount /cf ro
52
	/sbin/umount -f /cf
53
	/sbin/mount -r /cf
54
55 4668f9f7 Scott Ullrich
	echo "Done - rebooting system..."
56
	/sbin/reboot
57
	;;
58
pfSenseupgrade)
59
	# wait 5 seconds before beginning
60
	sleep 5
61
62
	exec </dev/console >/dev/console 2>/dev/console
63 be3239e3 Scott Ullrich
	
64
	echo "Firmware upgrade in progress..."  | logger -p daemon.info -i -t Upgrade
65 4668f9f7 Scott Ullrich
66
	# backup config
67
	mkdir /tmp/configbak
68
	cp -p /conf/* /tmp/configbak
69
	# mount /cf
70
	/sbin/mount -w -o noatime /cf
71
72
	# tar explode image onto hd
73
	if [ -r $2 ]; then
74 be3239e3 Scott Ullrich
		tar xzPf $2 -U -C / | logger -p daemon.info -i -t Upgrade
75
		echo "Image installed." | logger -p daemon.info -i -t Upgrade
76 4668f9f7 Scott Ullrich
	fi
77
78 cbd61550 Scott Ullrich
        # process custom image if its passed
79
        if [ -r $3 ]; then
80
            echo "Custom image $3 found." | logger -p daemon.info -i -t Upgrade
81
            tar xzPf $3 -U -C / | logger -p daemon.info -i -t Upgrade
82
            echo "Custom image $3 installed." | logger -p daemon.info -i -t Upgrade
83
        fi
84
85 4668f9f7 Scott Ullrich
	# restore config
86
	cp -p /tmp/configbak/* /conf
87
88
	# remount /cf ro
89
	/sbin/umount -f /cf
90
	/sbin/mount -r /cf
91
92 be3239e3 Scott Ullrich
	echo "Done - rebooting system..." | logger -p daemon.info -i -t Upgrade
93
	/sbin/shutdown -r now
94 5b237745 Scott Ullrich
	;;
95
esac