Project

General

Profile

Download (2.74 KB) Statistics
| Branch: | Tag: | Revision:
1 18ff56f2 Scott Ullrich
#!/bin/sh
2
3 1b8df11b Bill Marquette
# $Id$
4
5 f1b02597 Bill Marquette
FMBASEURL=$1
6
FMFILENAME=$2
7 93157ad8 Scott Ullrich
FETCHFILENAME=$1/$2
8 f1b02597 Bill Marquette
9 92a5e926 Renato Botelho
product=`cat /etc/inc/globals.inc | grep product_name | cut -d'"' -f4`
10 f51db33f Scott Ullrich
11 be3239e3 Scott Ullrich
# wait 5 seconds before beginning
12
sleep 5
13
14
logger -p daemon.info -i -t AutoUpgrade "Auto Upgrade started"
15
16 99970541 Scott Ullrich
HTTP_AUTH=""
17
18
# if username and password is passed, let fetch utilize.
19 f1b02597 Bill Marquette
if [ $# -gt 3 ]; then
20
HTTP_AUTH="basic:*:$3:$4"
21 99970541 Scott Ullrich
fi
22
23 48012bc2 Scott Ullrich
#echo "Downloading $FMFILENAME from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
24
#/usr/bin/fetch -o /tmp/latest.tgz $FETCHFILENAME | logger -p daemon.info -i -t AutoUpgrade
25
#echo "Downloading $FMFILENAME.md5 from $FMBASEURL ..."  | logger -p daemon.info -i -t AutoUpgrade
26
#/usr/bin/fetch -o /tmp/latest.tgz.md5 $FETCHFILENAME.md5 | logger -p daemon.info -i -t AutoUpgrade
27 18ff56f2 Scott Ullrich
28 7105aae8 Scott Ullrich
PMD=`/bin/cat /tmp/latest.tgz.md5 | cut -d" " -f4 `
29
MD=`/sbin/md5 /tmp/latest.tgz | cut -d" " -f4`
30
31 183d99c6 Scott Ullrich
PLATFORM=`cat /etc/platform`
32 18ff56f2 Scott Ullrich
33 be3239e3 Scott Ullrich
echo "   Package MD5: ${PMD}" | logger -p daemon.info -i -t AutoUpgrade
34
echo "Downloaded MD5: ${MD}"  | logger -p daemon.info -i -t AutoUpgrade
35 18ff56f2 Scott Ullrich
36 f3d37000 Scott Ullrich
if [ "$PMD" = "" ]; then
37
    echo "Package MD5 is null md5. Require proxy auth?"  | logger -p daemon.info -i -t AutoUpgrade
38 2b2de692 Scott Ullrich
    exit 1
39 f3d37000 Scott Ullrich
fi
40
41
if [ "$MD" = "" ]; then
42
    echo "Downloaded MD5 is null md5. Require proxy auth?"  | logger -p daemon.info -i -t AutoUpgrade
43 2b2de692 Scott Ullrich
    exit 1
44 f3d37000 Scott Ullrich
fi
45
46 be3239e3 Scott Ullrich
if [ "$PMD" = "$MD" ]; then
47 561dda51 Scott Ullrich
        echo "MD5's match."  | logger -p daemon.info -i -t AutoUpgrade
48 f51db33f Scott Ullrich
		echo "Beginning ${product} upgrade." | wall
49 7105aae8 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
50
            /usr/local/bin/php /etc/rc.conf_mount_rw
51
        fi
52
        if [ "$PLATFORM" = "wrap" ]; then
53
            /usr/local/bin/php /etc/rc.conf_mount_rw
54
        fi
55 585fafb2 Scott Ullrich
        if [ "$PLATFORM" = "nanobsd" ]; then
56
            /usr/local/bin/php /etc/rc.conf_mount_rw
57
        fi
58 48111b40 Scott Ullrich
        if [ -r "/tmp/custom.tgz" ]; then
59 7105aae8 Scott Ullrich
            sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz /tmp/custom.tgz
60 cbd61550 Scott Ullrich
        else
61 585fafb2 Scott Ullrich
        	if [ "$PLATFORM" = "nanobsd" ]; then
62
				sh /etc/rc.firmware pfSenseNanoBSDupgrade /tmp/latest.tgz            
63
			else 
64
				sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz
65
			fi
66 7105aae8 Scott Ullrich
        fi
67 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "wrap" ]; then
68
            /bin/sync
69
            sleep 5
70 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
71 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
72
                    sh /etc/init_bootloader.sh
73
            fi            
74 cbd61550 Scott Ullrich
        fi
75 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
76
            /bin/sync
77
            sleep 5
78 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
79 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
80
                    sh /etc/init_bootloader.sh
81
            fi            
82 7105aae8 Scott Ullrich
        fi        
83 18ff56f2 Scott Ullrich
        exit 0
84
fi
85
86 2b2de692 Scott Ullrich
echo "MD5's do not match.  Upgrade aborted."  | logger -p daemon.info -i -t AutoUpgrade
87 5e1fd336 Scott Ullrich
rm /tmp/latest*
88 2b2de692 Scott Ullrich
exit 1