Project

General

Profile

Download (2.39 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 be3239e3 Scott Ullrich
# wait 5 seconds before beginning
10
sleep 5
11
12
logger -p daemon.info -i -t AutoUpgrade "Auto Upgrade started"
13
14 99970541 Scott Ullrich
HTTP_AUTH=""
15
16
# if username and password is passed, let fetch utilize.
17 f1b02597 Bill Marquette
if [ $# -gt 3 ]; then
18
HTTP_AUTH="basic:*:$3:$4"
19 99970541 Scott Ullrich
fi
20
21 48012bc2 Scott Ullrich
#echo "Downloading $FMFILENAME from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
22
#/usr/bin/fetch -o /tmp/latest.tgz $FETCHFILENAME | logger -p daemon.info -i -t AutoUpgrade
23
#echo "Downloading $FMFILENAME.md5 from $FMBASEURL ..."  | logger -p daemon.info -i -t AutoUpgrade
24
#/usr/bin/fetch -o /tmp/latest.tgz.md5 $FETCHFILENAME.md5 | logger -p daemon.info -i -t AutoUpgrade
25 18ff56f2 Scott Ullrich
26 7105aae8 Scott Ullrich
PMD=`/bin/cat /tmp/latest.tgz.md5 | cut -d" " -f4 `
27
MD=`/sbin/md5 /tmp/latest.tgz | cut -d" " -f4`
28
29
PLATFORM=`cat /etc/version`
30 18ff56f2 Scott Ullrich
31 be3239e3 Scott Ullrich
echo "   Package MD5: ${PMD}" | logger -p daemon.info -i -t AutoUpgrade
32
echo "Downloaded MD5: ${MD}"  | logger -p daemon.info -i -t AutoUpgrade
33 18ff56f2 Scott Ullrich
34 f3d37000 Scott Ullrich
if [ "$PMD" = "" ]; then
35
    echo "Package MD5 is null md5. Require proxy auth?"  | logger -p daemon.info -i -t AutoUpgrade
36 2b2de692 Scott Ullrich
    exit 1
37 f3d37000 Scott Ullrich
fi
38
39
if [ "$MD" = "" ]; then
40
    echo "Downloaded MD5 is null md5. Require proxy auth?"  | logger -p daemon.info -i -t AutoUpgrade
41 2b2de692 Scott Ullrich
    exit 1
42 f3d37000 Scott Ullrich
fi
43
44 be3239e3 Scott Ullrich
if [ "$PMD" = "$MD" ]; then
45 561dda51 Scott Ullrich
        echo "MD5's match."  | logger -p daemon.info -i -t AutoUpgrade
46 7105aae8 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
47
            /usr/local/bin/php /etc/rc.conf_mount_rw
48
        fi
49
        if [ "$PLATFORM" = "wrap" ]; then
50
            /usr/local/bin/php /etc/rc.conf_mount_rw
51
        fi
52 48111b40 Scott Ullrich
        if [ -r "/tmp/custom.tgz" ]; then
53 7105aae8 Scott Ullrich
            sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz /tmp/custom.tgz
54 cbd61550 Scott Ullrich
        else
55 7105aae8 Scott Ullrich
            sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz
56
        fi
57 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "wrap" ]; then
58
            /bin/sync
59
            sleep 5
60 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
61 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
62
                    sh /etc/init_bootloader.sh
63
            fi            
64 cbd61550 Scott Ullrich
        fi
65 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
66
            /bin/sync
67
            sleep 5
68 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
69 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
70
                    sh /etc/init_bootloader.sh
71
            fi            
72 7105aae8 Scott Ullrich
        fi        
73 18ff56f2 Scott Ullrich
        exit 0
74
fi
75
76 2b2de692 Scott Ullrich
echo "MD5's do not match.  Upgrade aborted."  | logger -p daemon.info -i -t AutoUpgrade
77 5e1fd336 Scott Ullrich
rm /tmp/latest*
78 2b2de692 Scott Ullrich
exit 1