2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
#set -e
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
|
|
|
# Setup
|
|
|
|
rm -rf /tmp/mynode_release_latest.tar.gz
|
|
|
|
rm -rf /tmp/mynode_release.pub
|
|
|
|
rm -rf /tmp/upgrade/
|
|
|
|
mkdir -p /tmp/upgrade/
|
2019-11-05 02:16:55 +00:00
|
|
|
mkdir -p /home/admin/upgrade_logs/
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
# Download Latest
|
|
|
|
wget $UPGRADE_DOWNLOAD_URL -O /tmp/mynode_release_latest.tar.gz
|
|
|
|
wget $UPGRADE_DOWNLOAD_SIGNATURE_URL -O /tmp/mynode_release_latest.sha256
|
|
|
|
wget $UPGRADE_PUBKEY_URL -O /tmp/mynode_release.pub
|
|
|
|
|
|
|
|
openssl dgst -sha256 -verify /tmp/mynode_release.pub -signature /tmp/mynode_release_latest.sha256 /tmp/mynode_release_latest.tar.gz
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "UPGRADE FAILED! Hash did not match!" >> /var/log/upgrade.log
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Extract to temp location
|
|
|
|
tar -xvf /tmp/mynode_release_latest.tar.gz -C /tmp/upgrade/
|
|
|
|
|
|
|
|
# Install files
|
2019-11-09 15:34:55 +00:00
|
|
|
VERSION=$(cat /tmp/upgrade/out/rootfs_*/usr/share/mynode/version)
|
2019-10-07 23:39:54 +00:00
|
|
|
if [ $IS_X86 = 1 ]; then
|
2019-11-05 02:16:55 +00:00
|
|
|
rsync -r -K /tmp/upgrade/out/rootfs_${DEVICE_TYPE}/* / > /home/admin/upgrade_logs/upgrade_log_${VERSION}_copy.txt 2>&1
|
2019-10-07 23:39:54 +00:00
|
|
|
else
|
2019-11-05 02:16:55 +00:00
|
|
|
cp -rf /tmp/upgrade/out/rootfs_${DEVICE_TYPE}/* / > /home/admin/upgrade_logs/upgrade_log_${VERSION}_copy.txt 2>&1
|
2019-10-07 23:39:54 +00:00
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
sleep 1
|
|
|
|
sync
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# Run post upgrade script
|
2019-10-23 00:52:40 +00:00
|
|
|
VERSION=$(cat /usr/share/mynode/version)
|
2019-11-16 05:09:15 +00:00
|
|
|
for i in {1..5}
|
|
|
|
do
|
|
|
|
/bin/bash /usr/bin/mynode_post_upgrade.sh > /home/admin/upgrade_logs/upgrade_log_${VERSION}_post_${i}.txt 2>&1
|
|
|
|
RC=$?
|
|
|
|
if [ "${RC}" -eq "0" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 10s
|
|
|
|
done
|
2019-11-09 15:34:55 +00:00
|
|
|
chown -R admin:admin /home/admin/upgrade_logs
|