summaryrefslogtreecommitdiffstats
path: root/etc/rc.firmware_auto
blob: e7247cb591eb2ab8f431fff9498dc70f274df7fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh

# $Id$

FMBASEURL=$1
FMFILENAME=$2
FETCHFILENAME=$1/$2

product=`cat /etc/inc/globals.inc | grep product_name | cut -d'"' -f4`

# wait 5 seconds before beginning
sleep 5

logger -p daemon.info -i -t AutoUpgrade "Auto Upgrade started"

HTTP_AUTH=""

# if username and password is passed, let fetch utilize.
if [ $# -gt 3 ]; then
HTTP_AUTH="basic:*:$3:$4"
fi

#echo "Downloading $FMFILENAME from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
#/usr/bin/fetch -o /tmp/latest.tgz $FETCHFILENAME | logger -p daemon.info -i -t AutoUpgrade
#echo "Downloading $FMFILENAME.md5 from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
#/usr/bin/fetch -o /tmp/latest.tgz.md5 $FETCHFILENAME.md5 | logger -p daemon.info -i -t AutoUpgrade

PMD=`/bin/cat /tmp/latest.tgz.md5 | cut -d" " -f4 `
MD=`/sbin/md5 /tmp/latest.tgz | cut -d" " -f4`

PLATFORM=`cat /etc/platform`

echo "   Package MD5: ${PMD}" | logger -p daemon.info -i -t AutoUpgrade
echo "Downloaded MD5: ${MD}" | logger -p daemon.info -i -t AutoUpgrade

if [ "$PMD" = "" ]; then
	echo "Package MD5 is null md5. Require proxy auth?" | logger -p daemon.info -i -t AutoUpgrade
	exit 1
fi

if [ "$MD" = "" ]; then
	echo "Downloaded MD5 is null md5. Require proxy auth?" | logger -p daemon.info -i -t AutoUpgrade
	exit 1
fi

if [ "$PMD" = "$MD" ]; then
	echo "MD5's match." | logger -p daemon.info -i -t AutoUpgrade
	echo "Beginning ${product} upgrade." | wall
	if [ "$PLATFORM" = "net45xx" ]; then
		/usr/local/bin/php /etc/rc.conf_mount_rw
	fi
	if [ "$PLATFORM" = "wrap" ]; then
		/usr/local/bin/php /etc/rc.conf_mount_rw
	fi
	if [ "$PLATFORM" = "nanobsd" ]; then
		/usr/local/bin/php /etc/rc.conf_mount_rw
	fi
	if [ -r "/tmp/custom.tgz" ]; then
		sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz /tmp/custom.tgz
	else
		if [ "$PLATFORM" = "nanobsd" ]; then
			sh /etc/rc.firmware pfSenseNanoBSDupgrade /tmp/latest.tgz
		else
			sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz
		fi
	fi
	if [ "$PLATFORM" = "wrap" ]; then
		/bin/sync
		sleep 5
		/usr/local/bin/php /etc/rc.conf_mount_ro
		if [ -e /etc/init_bootloader.sh ]; then
			sh /etc/init_bootloader.sh
		fi
	fi
	if [ "$PLATFORM" = "net45xx" ]; then
		/bin/sync
		sleep 5
		/usr/local/bin/php /etc/rc.conf_mount_ro
		if [ -e /etc/init_bootloader.sh ]; then
			sh /etc/init_bootloader.sh
		fi
	fi
	exit 0
fi

echo "MD5's do not match.  Upgrade aborted." | logger -p daemon.info -i -t AutoUpgrade
rm /tmp/latest*
exit 1
OpenPOWER on IntegriCloud