Here the file. I have also deleted the file and let it download again and I get the same error. The MD5 hash I get from the file is: 9bcfacb92757ff39e72105fd6151ea59 when I do a manually md5sum
Code: Select all
###! /bin/sh
# NOTE: do not prepend #! /bin/sh, this script is executed directly via execve()
#
# upgrade-qb2.sh
# script for testing several functions for automatic updates
#
# Shamelessly copied from one of the _opkg.qb2-ene-x.y.z.script.sh scripts by
# Quby, thanks, guys ;-).
#
#
# This script is invoked by the following URL, in two cases:
#
# preparation:
# http://<URL-of-your-toon>/hcb_config?action=checkFirmwareUpdate&version=9.9.99
#
# execution:
# http://<URL-of-your-toon>/hcb_config?action=doFirmwareUpdate&version=9.9.99
#
# texts for notification screens, edit according to your needs:
INSTALL_SUBJECT="Software installatie"
INSTALL_SUBTITLE="Deze software uit de ToonStore is geïnstalleerd:"
REMOVAL_SUBJECT="Software verwijdering"
REMOVAL_SUBTITLE="Deze software uit de ToonStore is verwijderd:"
################################################################################
#
# No user-serviceable parts beyond this line
#
################################################################################
TSC_FEED_URL="http://files.domoticaforum.eu/uploads/Toon/apps"
SYNC_FILE=/tmp/install_status
INSTALL_ACTIONS="
<actions>
<action>
<type>button</type>
<btnLabel>Instellingen</btnLabel>
<btnPos>left</btnPos>
<cmdName>maximize</cmdName>
<cmdArg>System.Software</cmdArg>
<cmdTarget>widget-settings</cmdTarget>
<returnAfterPress>false</returnAfterPress>
</action>
</actions>"
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
FEATURES="RTC_WRITE INITTAB_PREPARE EXEC_RESUME CLEAN_OLD_PACKAGES"
SCRIPTPATH=$0
SCRIPTDIR=`dirname $SCRIPTPATH`
SCRIPTNAME=`basename $SCRIPTPATH`
SCRIPTSTATUS=$0.res
# Not all of those are required, but leave them here to be able to see the logic
export HCB_ARCH="$1" # e.g., qb2
export HCB_FLAV="$2" # e.g., ene
export HCB_VERS="$3" # e.g., 3.2.18
export ACTION="$4" # e.g., execute (possible options:
# prepare execute execute-resume)
dropboxMessage()
{
SUBJ="$1"
SUBT="$2"
MESG="$3"
ACTS="$4"
echo ">> dropboxMessage $MESG"
time=`date +%s`
Message="
<Config>
<message>
<content>$MESG</content>
<subject>$SUBJ</subject>
<subtitle>$SUBT</subtitle>
<messageType>critical</messageType>
<received_t>$time</received_t>
<internalAddress>dropboxed_$time</internalAddress>
<read_t></read_t>
<readMsgSend>1</readMsgSend>
<hideOnRemove>0</hideOnRemove>
<package>happ_usermsg</package>
<type>message</type>
<name>upgrade_msg</name>
<visibility>1</visibility>$ACTS
</message>
</Config>"
echo "$Message" > /tmp/dropbox_msg.xml
mv /tmp/dropbox_msg.xml /HCBv2/config/dropbox/
}
statusSet()
{
# STATUS can be any of the following:
#
# preparing
# prepared
# executing
# executed
#
# after the STATUS has been set to executed, all stuff in the temporary
# directory can be removed.
STATUS="$1"
echo "$STATUS" > $SCRIPTSTATUS
echo "$STATUS" > $SYNC_FILE
echo ">> `date +'%Y-%m-%d %H:%M:%S %z'` (pid $$), status = $STATUS"
}
getCurrentFW()
{
# the current FW version is stored in the opkg package listings.
# Find the line containing the version number and take it apart:
REF_FILE1=/usr/lib/opkg/info/base-qb2-ene.control
REF_FILE2=/usr/lib/opkg/info/base-qb2-uni.control
if [ -f $REF_FILE1 ] ; then
REF_FILE=$REF_FILE1
else
REF_FILE=$REF_FILE2
fi
LINE=`grep Version $REF_FILE | awk {'print $2'}`
export FW_MAJOR=`echo $LINE | awk -F. {'print $1'}`
export FW_MINOR=`echo $LINE | awk -F. {'print $2'}`
LINE=`echo $LINE | awk -F. {'print $3'}`
export FW_PATCHLEVEL=`echo $LINE | awk -F- {'print $1'}`
export FW_BUILD=`echo $LINE | awk -F- {'print $2'}`
export FW_BUILD_REV=`echo $LINE | awk -F- {'print $3'}`
}
getFreeRAM()
{
# get memory usage from top output
# toon-specific (busybox, really).
LINE=`top -n 1 | grep Mem`
export RAM_USED=`echo $LINE | awk {'print $2'}`
export RAM_FREE=`echo $LINE | awk {'print $4'}`
RAM_SHARED=`echo $LINE | awk {'print $6'}`
RAM_BUFFERED=`echo $LINE | awk {'print $8'}`
RAM_CACHED=`echo $LINE | awk {'print $10'}`
}
getLoad()
{
# get load averages for the last 1, 5, and 15 minutes.
# toon-specific (busybox, really).
LINE=`uptime | awk -F: {'print $5'}`
export LOAD_1M=`echo $LINE | awk -F, {'print $1'}`
export LOAD_5M=`echo $LINE | awk -F, {'print $2'}`
export LOAD_15M=`echo $LINE | awk -F, {'print $3'}`
}
errorExit()
{
STATUS="$ACTION-error-$1"
STRING="$2"
echo "$STATUS" > $SCRIPTSTATUS
echo ">> `date +'%Y-%m-%d %H:%M:%S %z'` (pid $$) $STATUS '$STRING'"
exit 1
}
featureEnabled()
{
# test if this feature is enabled
echo "$FEATURES" | grep -q "$1"
}
################################################################################
#
# main routine
#
# hcb_config downloads this script and its signature from
# http://feed.hae.int/feeds/qb2/upgrade/upgrade-qb2.sh
#
# after a positive signature check, it gets renamed into
# _opkg.qb2-ene-9.9.99.script.sh, and stored in /mnt/data/update (or
# /HCBv2/tmp/opkg-cache on 3.x toons), and is executed.
#
# hcb_config then performs the first step, after a second call, the execution
# phase is started.
#
################################################################################
(
statusSet "$ACTION"
cd $SCRIPTDIR
PKGCACHE=$SCRIPTDIR
PACKAGES_TO_INSTALL_FILE=/tmp/packages_to_install.txt
DEPENDENCIES_TO_INSTALL_FILE=/tmp/dependencies_to_install.txt
PACKAGES_TO_REMOVE_FILE=/tmp/packages_to_delete.txt
################################################################################
case $ACTION in
prepare)
echo ""
echo ">> Welcome to the ToonStore updater,"
echo ">> brought to you by the Toonroot Software Collective (TSC)"
echo ">>"
echo ">> `date +'%Y-%m-%d %H:%M:%S %z'` (pid $$) $SCRIPTNAME $@"
echo ""
statusSet "preparing"
getCurrentFW ""
echo ">> Firmware version: $FW_MAJOR.$FW_MINOR.$FW_PATCHLEVEL, build $FW_BUILD, rev $FW_BUILD_REV."
getLoad ""
echo ">> System load : $LOAD_1M"
getFreeRAM ""
echo ">> Free RAM : $RAM_FREE"
echo ">> Flushing file system buffers and cache ..."
sync
echo 3 > /proc/sys/vm/drop_caches
getFreeRAM ""
echo ">> Free RAM now : $RAM_FREE"
# Hotfix for writing System Time to RTC (ET-794)
if featureEnabled RTC_WRITE
then
echo ">> Hotfix for writing System Time to RTC"
echo "Hardware Clock before: `hwclock --show`"
# here we know the system time is ok:
# script downloaded -> internet -> hae-timesync
hwclock --systohc --utc
echo "Hardware Clock after : `hwclock --show`"
fi
# Remove stale opkg cache entries
# All entries generated with this script start with tsc, entries
# from quby should remain intact.
rm /var/lib/opkg/tsc*
# make sure $PACKAGES_TO_INSTALL_FILE is written
sync
# Get packages to process, and download.
# Packages marked for deletion will be removed immediately,
# packages marked for installion will be installed in the execution
# phase.
INSTALL_PACKAGES=""
INSTALL_PACKAGE_LIST=""
INSTALL_DEPENDENCIES=""
REMOVAL_PACKAGES=""
REMOVAL_PACKAGE_LIST=""
if [ -f $PACKAGES_TO_INSTALL_FILE -o \
-f $PACKAGES_TO_REMOVE_FILE ] ; then
if [ -f $PACKAGES_TO_INSTALL_FILE ] ; then
INSTALL_PACKAGES=`cat $PACKAGES_TO_INSTALL_FILE`
echo ">> Installing $INSTALL_PACKAGES"
# set correct feed location for initial install, clean up
# before writing anew.
rm -f /etc/opkg/*-feed.conf /usr/lib/opkg/lists/*
sync
# opkg update reads the Packages info file(s) and
# signatures from the repositories defined below. The
# Packages and Packages.sig files are then transferred to
# /var/lib/opkg, and renamed to reflect the repository
# names (tsc1, tsc1.sig, tsc2, etc., in this case).
echo ">> Extracting packages from the following repo('s):"
COUNTER=0
for PACKAGE in $INSTALL_PACKAGES ;
do
let COUNTER=COUNTER+1
echo "src/gz tsc$COUNTER ${TSC_FEED_URL}/$PACKAGE"
echo "src/gz tsc$COUNTER ${TSC_FEED_URL}/$PACKAGE" \
>> /etc/opkg/tsc-feed.conf
INSTALL_PACKAGE_LIST="${INSTALL_PACKAGE_LIST}${PACKAGE}BR"
# check for presence of dependencies
DEPENDENCIES=""
DEPENDENCIES="`wget -q "${TSC_FEED_URL}/$PACKAGE/dependencies.txt" -O -`"
if [ "$DEPENDENCIES" ] ; then
echo">> dependencies found: $DEPENDENCIES"
for DEP in $DEPENDENCIES ;
do
let COUNTER=COUNTER+1
echo "src/gz tsc$COUNTER ${TSC_FEED_URL}/../pkgs/$DEP"
echo "src/gz tsc$COUNTER ${TSC_FEED_URL}/../pkgs/$DEP" \
>> /etc/opkg/tsc-feed.conf
echo -n "$DEP " >> $DEPENDENCIES_TO_INSTALL_FILE
done
fi
done
sync
echo ">> configured opkg feeds:"
cat /etc/opkg/*-feed.conf
# get package list(s)
echo ">> opkg update"
opkg update 2>&1; EXITCODE=$?
[ "$EXITCODE" != "0" ] && \
errorExit "opkg-update" \
"Exit code $EXITCODE for: opkg update"
# Package repodata read and stored, now get the packages
echo ">> Package cache: $PKGCACHE"
# merge packages and dependencies
for PACKAGE in $INSTALL_PACKAGES ;
do
PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- '{OFS="-";NF--;print $0;}' `
echo ">> opkg --cache $PKGCACHE install --download-only $PACKAGE_SHORT_NAME"
opkg --cache $PKGCACHE install --download-only \
$PACKAGE_SHORT_NAME 2>&1; \
EXITCODE=$?
done
INSTALL_PACKAGES=`cat $DEPENDENCIES_TO_INSTALL_FILE`
for PACKAGE in $INSTALL_PACKAGES ;
do
# PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- 'awk -F- '{ print $1 }' `
PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- '{OFS="-";NF--;print $0;}' `
echo ">> opkg --cache $PKGCACHE install --download-only $PACKAGE_SHORT_NAME"
opkg --cache $PKGCACHE install --download-only \
$PACKAGE_SHORT_NAME 2>&1; \
EXITCODE=$?
done
# intermediate cleanup
rm -rf /tmp/opkg-*
# ensure the log greps below always work
sync
# error handling
( # error handler subshell start
if [ "$EXITCODE" != "0" ]
then
# * opkg_install_pkg: Package xxx md5sum mismatch.
# Either the opkg or the package index are corrupt.
if tail -n20 $SCRIPTPATH.log | \
grep -q 'md5sum mismatch'
then
rm -f $PKGCACHE/*.ipk
errorExit "opkg-upgrade-md5sum" \
"opkg upgrade found an md5sum mismatch: removed *.ipk!"
fi
# * opkg_download: Failed to download http://...ipk:
# Timeout was reached.
# * opkg_download: Failed to download http://...ipk:
# Couldn't connect to server.
if tail -n20 $SCRIPTPATH.log | \
grep -q 'Failed to download'
then
errorExit "opkg-update-download" \
"opkg update download failed"
fi
if tail -n20 $SCRIPTPATH.log | grep -q \
'Cannot satisfy the following dependencies for'
then
# never mind, dependencies should be fulfilled
# through proper packaging.
echo "dependency check failed, carrying on ..."
exit
fi
# generic error
errorExit "opkg-update" \
"Exit code $EXITCODE for: opkg install --download-only"
fi
) #error handler subshell end
echo ">> downloaded:"
du -ch $PKGCACHE/*.ipk | grep total
# notify the user
INSTALL_MESSAGE="${INSTALL_PACKAGE_LIST}BRBekijk de berichten voor deze software voor informatie over eventuele configuratie."
dropboxMessage "$INSTALL_SUBJECT" "$INSTALL_SUBTITLE" \
"$INSTALL_MESSAGE" "$INSTALL_ACTIONS"
else
echo ">> no packages to be installed"
fi
if [ -f $PACKAGES_TO_REMOVE_FILE ] ; then
REMOVAL_PACKAGES=`cat $PACKAGES_TO_REMOVE_FILE`
echo ">> Removing $REMOVAL_PACKAGES"
# do more or less the same for the removal of packages:
for PACKAGE in $REMOVAL_PACKAGES ;
do
PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- '{OFS="-";NF--;print $0;}' `
REMOVAL_PACKAGE_LIST="${REMOVAL_PACKAGE_LIST}${PACKAGE}BR"
echo ">> opkg remove $PACKAGE_SHORT_NAME"
opkg remove $PACKAGE_SHORT_NAME 2>&1; \
EXITCODE=$?
done
# Error handling not yet implemented
sync
# post a message, and yes, $INSTALL_ACTIONS is correct here:
REMOVAL_MESSAGE="${REMOVAL_PACKAGE_LIST}BR"
dropboxMessage "$REMOVAL_SUBJECT" "$REMOVAL_SUBTITLE" \
"$REMOVAL_MESSAGE" "$INSTALL_ACTIONS"
else
echo ">> no packages to be removed"
fi
else
echo ">> no packages to process, exiting .. "
exit
fi
sync
statusSet "prepared"
;;
###############################################################################
execute|execute-resume)
statusSet "executing"
# Handle dependencies first, main packages follow later on.
if [ -f $DEPENDENCIES_TO_INSTALL_FILE ] ; then
INSTALL_PACKAGES=`cat $DEPENDENCIES_TO_INSTALL_FILE`
for PACKAGE in $INSTALL_PACKAGES ;
do
PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- '{OFS="-";NF--;print $0;}' `
echo ">> opkg --cache $PKGCACHE install $PACKAGE_SHORT_NAME"
opkg --cache $PKGCACHE install $PACKAGE_SHORT_NAME 2>&1; \
EXITCODE=$?
done
# Hmm, needs some error handling ...
fi
# re-read install packages list, and install.
if [ -f $PACKAGES_TO_INSTALL_FILE ] ; then
INSTALL_PACKAGES=`cat $PACKAGES_TO_INSTALL_FILE`
for PACKAGE in $INSTALL_PACKAGES ;
do
PACKAGE_SHORT_NAME=`echo $PACKAGE | awk -F- '{OFS="-";NF--;print $0;}' `
echo ">> opkg --cache $PKGCACHE install $PACKAGE_SHORT_NAME"
opkg --cache $PKGCACHE install $PACKAGE_SHORT_NAME 2>&1; \
EXITCODE=$?
done
# Hmm, needs some error handling ...
fi
# clean up
if [ -f $DEPENDENCIES_TO_INSTALL_FILE ] ; then
echo ">> deleting $DEPENDENCIES_TO_INSTALL_FILE"
rm $DEPENDENCIES_TO_INSTALL_FILE
fi
if [ -f $PACKAGES_TO_INSTALL_FILE ] ; then
echo ">> deleting $PACKAGES_TO_INSTALL_FILE"
rm $PACKAGES_TO_INSTALL_FILE
fi
if [ -f $PACKAGES_TO_REMOVE_FILE ] ; then
echo ">> deleting $PACKAGES_TO_REMOVE_FILE"
rm $PACKAGES_TO_REMOVE_FILE
fi
echo ">> reinstating cache handling (default 0)"
echo 0 > /proc/sys/vm/drop_caches
if [ -f $SYNC_FILE ] ; then
echo ">> deleting $SYNC_FILE"
rm $SYNC_FILE
else
echo ">> no $SYNC_FILE found, shouldn't happen"
fi
echo ">> deleting all in $PKGCACHE"
echo ">> (this may give some errors, no problem here ...)"
rm $PKGCACHE/*.ipk
rm $PKGCACHE/*.sh
rm $PKGCACHE/*.sh.sig
# rm $PKGCACHE/*
statusSet "executed"
rm $PKGCACHE/*.sh.res
sync
# Restart http daemon, qt-gui and hcb_config, to activate the
# new installations/removals. Needs to be the last comand in the
# update. These commands need to remain on a SINGLE line
echo ">> Restarting qt-gui and hcb_config ..."
killall qt-gui ; killall hcb_config
;;
###############################################################################
*)
echo ">> Unknown ACTION arg! Aborting."
errorExit "unknown-action" "Unknown ACTION arg! Aborting."
;;
esac
) </dev/null >>$SCRIPTPATH.log 2>&1