1 |
18ff56f2
|
Scott Ullrich
|
#!/bin/sh
|
2 |
|
|
|
3 |
a34e9807
|
Chris Buechler
|
# /etc/rc.firmware_auto
|
4 |
|
|
# Copyright (C) 2005-2015 Electric Sheep Fencing LLC
|
5 |
|
|
# Part of pfSense
|
6 |
|
|
|
7 |
1b8df11b
|
Bill Marquette
|
# $Id$
|
8 |
|
|
|
9 |
f1b02597
|
Bill Marquette
|
FMBASEURL=$1
|
10 |
|
|
FMFILENAME=$2
|
11 |
93157ad8
|
Scott Ullrich
|
FETCHFILENAME=$1/$2
|
12 |
f1b02597
|
Bill Marquette
|
|
13 |
e4121dde
|
Renato Botelho
|
# Read product_name from $g, defaults to pfSense
|
14 |
|
|
product=$(/usr/local/sbin/read_global_var product_name pfSense)
|
15 |
f51db33f
|
Scott Ullrich
|
|
16 |
be3239e3
|
Scott Ullrich
|
# wait 5 seconds before beginning
|
17 |
|
|
sleep 5
|
18 |
|
|
|
19 |
|
|
logger -p daemon.info -i -t AutoUpgrade "Auto Upgrade started"
|
20 |
|
|
|
21 |
99970541
|
Scott Ullrich
|
HTTP_AUTH=""
|
22 |
|
|
|
23 |
|
|
# if username and password is passed, let fetch utilize.
|
24 |
f1b02597
|
Bill Marquette
|
if [ $# -gt 3 ]; then
|
25 |
|
|
HTTP_AUTH="basic:*:$3:$4"
|
26 |
99970541
|
Scott Ullrich
|
fi
|
27 |
|
|
|
28 |
a34e9807
|
Chris Buechler
|
if [ $# -gt 1 ]; then
|
29 |
|
|
echo "Downloading $FMFILENAME from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
|
30 |
|
|
/usr/bin/fetch -o /tmp/latest.tgz $FETCHFILENAME | logger -p daemon.info -i -t AutoUpgrade
|
31 |
|
|
echo "Downloading $FMFILENAME.sha256 from $FMBASEURL ..." | logger -p daemon.info -i -t AutoUpgrade
|
32 |
|
|
/usr/bin/fetch -o /tmp/latest.tgz.sha256 $FETCHFILENAME.sha256 | logger -p daemon.info -i -t AutoUpgrade
|
33 |
|
|
fi
|
34 |
18ff56f2
|
Scott Ullrich
|
|
35 |
a34e9807
|
Chris Buechler
|
DLHASH=`/bin/cat /tmp/latest.tgz.sha256 | cut -d" " -f4 `
|
36 |
|
|
FILEHASH=`/sbin/sha256 /tmp/latest.tgz | cut -d" " -f4`
|
37 |
7105aae8
|
Scott Ullrich
|
|
38 |
183d99c6
|
Scott Ullrich
|
PLATFORM=`cat /etc/platform`
|
39 |
18ff56f2
|
Scott Ullrich
|
|
40 |
a34e9807
|
Chris Buechler
|
echo " Package sha256: ${DLHASH}" | logger -p daemon.info -i -t AutoUpgrade
|
41 |
|
|
echo "Downloaded sha256: ${FILEHASH}" | logger -p daemon.info -i -t AutoUpgrade
|
42 |
18ff56f2
|
Scott Ullrich
|
|
43 |
a34e9807
|
Chris Buechler
|
if [ "$DLHASH" = "" ]; then
|
44 |
|
|
echo "Downloaded sha256 is null. Require proxy auth?" | logger -p daemon.info -i -t AutoUpgrade
|
45 |
e173dd74
|
Phil Davis
|
exit 1
|
46 |
f3d37000
|
Scott Ullrich
|
fi
|
47 |
|
|
|
48 |
a34e9807
|
Chris Buechler
|
if [ "$FILEHASH" = "" ]; then
|
49 |
|
|
echo "Downloaded file's sha256 is null." | logger -p daemon.info -i -t AutoUpgrade
|
50 |
e173dd74
|
Phil Davis
|
exit 1
|
51 |
f3d37000
|
Scott Ullrich
|
fi
|
52 |
|
|
|
53 |
a34e9807
|
Chris Buechler
|
if [ "$DLHASH" = "$FILEHASH" ]; then
|
54 |
|
|
echo "sha256 hashes match." | logger -p daemon.info -i -t AutoUpgrade
|
55 |
e173dd74
|
Phil Davis
|
echo "Beginning ${product} upgrade." | wall
|
56 |
|
|
if [ "$PLATFORM" = "nanobsd" ]; then
|
57 |
cb7d18d5
|
Renato Botelho
|
/usr/local/bin/php-cgi /etc/rc.conf_mount_rw
|
58 |
e173dd74
|
Phil Davis
|
fi
|
59 |
|
|
if [ -r "/tmp/custom.tgz" ]; then
|
60 |
c580e34c
|
Renato Botelho
|
sh /etc/rc.firmware ${product}upgrade /tmp/latest.tgz /tmp/custom.tgz
|
61 |
e173dd74
|
Phil Davis
|
else
|
62 |
|
|
if [ "$PLATFORM" = "nanobsd" ]; then
|
63 |
c580e34c
|
Renato Botelho
|
sh /etc/rc.firmware ${product}NanoBSDupgrade /tmp/latest.tgz
|
64 |
e173dd74
|
Phil Davis
|
else
|
65 |
c580e34c
|
Renato Botelho
|
sh /etc/rc.firmware ${product}upgrade /tmp/latest.tgz
|
66 |
e173dd74
|
Phil Davis
|
fi
|
67 |
|
|
fi
|
68 |
|
|
exit 0
|
69 |
18ff56f2
|
Scott Ullrich
|
fi
|
70 |
|
|
|
71 |
a34e9807
|
Chris Buechler
|
echo "sha256 hashes do not match. Upgrade aborted." | logger -p daemon.info -i -t AutoUpgrade
|
72 |
5e1fd336
|
Scott Ullrich
|
rm /tmp/latest*
|
73 |
2b2de692
|
Scott Ullrich
|
exit 1
|