summaryrefslogtreecommitdiffstats
path: root/etc/rc.firmware_auto
blob: 7ef1830ebb557237c9ced2249a01552326c26ee7 (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
#!/bin/sh

# 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 1 ]; then
HTTP_AUTH="basic:*:$1:$2"
fi

echo "Downloading latest.tgz ..." | logger -p daemon.info -i -t AutoUpgrade
cd /tmp && fetch http://www.pfSense.com/latest.tgz  | logger -p daemon.info -i -t AutoUpgrade
echo "Downloading latest.tgz.md5 ..."  | logger -p daemon.info -i -t AutoUpgrade
cd /tmp && fetch http://www.pfSense.com/latest.tgz.md5  | logger -p daemon.info -i -t AutoUpgrade

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

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 0
fi

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

if [ "$PMD" = "$MD" ]; then
        echo "MD5's match."  | logger -p daemon.info -i -t AutoUpgrade
        /etc/rc.firmware pfSenseupgrade /tmp/latest.tgz
        exit 0
fi

echo "MD5's do not match."  | logger -p daemon.info -i -t AutoUpgrade
exit 0
OpenPOWER on IntegriCloud