Project

General

Profile

Download (2.43 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 cba9c643 Scott Ullrich
		echo "Beginning pfSense upgrade." | wall
47 7105aae8 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
48
            /usr/local/bin/php /etc/rc.conf_mount_rw
49
        fi
50
        if [ "$PLATFORM" = "wrap" ]; then
51
            /usr/local/bin/php /etc/rc.conf_mount_rw
52
        fi
53 48111b40 Scott Ullrich
        if [ -r "/tmp/custom.tgz" ]; then
54 7105aae8 Scott Ullrich
            sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz /tmp/custom.tgz
55 cbd61550 Scott Ullrich
        else
56 7105aae8 Scott Ullrich
            sh /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz
57
        fi
58 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "wrap" ]; then
59
            /bin/sync
60
            sleep 5
61 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
62 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
63
                    sh /etc/init_bootloader.sh
64
            fi            
65 cbd61550 Scott Ullrich
        fi
66 21fbee83 Scott Ullrich
        if [ "$PLATFORM" = "net45xx" ]; then
67
            /bin/sync
68
            sleep 5
69 7105aae8 Scott Ullrich
            /usr/local/bin/php /etc/rc.conf_mount_ro
70 7a35466c Scott Ullrich
            if [ -e /etc/init_bootloader.sh ]; then
71
                    sh /etc/init_bootloader.sh
72
            fi            
73 7105aae8 Scott Ullrich
        fi        
74 18ff56f2 Scott Ullrich
        exit 0
75
fi
76
77 2b2de692 Scott Ullrich
echo "MD5's do not match.  Upgrade aborted."  | logger -p daemon.info -i -t AutoUpgrade
78 5e1fd336 Scott Ullrich
rm /tmp/latest*
79 2b2de692 Scott Ullrich
exit 1