new package:

- adding package autoupdate
This commit is contained in:
Stephan Raue 2010-04-13 00:46:06 +02:00
parent fb9f5248ae
commit ed2940b1d4
4 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# Setup autoupdate ( no / manually / auto )
#
# no: no popup-information about new updates, no automatically download,
# no autoupdate.
#
# manually: shows popupinformation about updates, you must manually download the
# and extract the update package. Copy the files "SYSTEM" and "KERNEL"
# locally or per SSH/SCP to /storage/.update or via SMB to the
# "Update" share. Then reboot the system to install the update.
#
# auto: shows popupinformation about updates, the autoupdater downloads the
# update package and shows an information that the system must
# manually rebooted to install the update.
AUTOUPDATE=manually

View File

@ -0,0 +1,19 @@
#!/bin/sh
. config/options
PKG_DIR=`find $PACKAGES -type d -name $1`
mkdir -p $INSTALL/usr/bin
if [ "$DEVTOOLS" = "yes" ]; then
cp -P $PKG_DIR/scripts/autoupdate.devel $INSTALL/usr/bin/autoupdate
else
cp -P $PKG_DIR/scripts/autoupdate.release $INSTALL/usr/bin/autoupdate
fi
mkdir -p $INSTALL/usr/config
cp -P $PKG_DIR/config/update.conf $INSTALL/usr/config
mkdir -p $INSTALL/etc/crontabs
echo -e "*/5 * * * *\t/usr/bin/autoupdate" >> $INSTALL/etc/crontabs/root

View File

@ -0,0 +1,84 @@
#!/bin/sh
. /storage/.config/update.conf
if [ ! -f /var/lock/update.lock ]; then
if [ "$AUTOUPDATE" = "manually" -o "$AUTOUPDATE" = "auto" ]; then
# locking autoupdate
touch /var/lock/update.lock
# sleep a bit, maybe we have a lot of work ;-)
sleep 30
send_message () {
xbmc-send --host=127.0.0.1 -a "Notification(Automatic update service:,$1)"
}
UPDATEURL="http://snapshots.openelec.tv"
# getting this version
THIS_DISTRIBUTION="`cat /etc/distribution`"
THIS_ARCH="`cat /etc/arch`"
THIS_VERSION="`cat /etc/version`"
# get infofile with the latest released version
rm -rf /tmp/latest
wget $UPDATEURL/latest -P /tmp
NEW_IMAGE="`cat /tmp/latest |grep "$THIS_DISTRIBUTION-$THIS_ARCH"`"
NEW_VERSION="`echo "$NEW_IMAGE" | cut -d "-" -f5 | tr -d "r"`"
rm -rf /tmp/latest
# compare installed version with latest released version
THIS_VERSION="`echo "$THIS_VERSION" | cut -d "-" -f3 | tr -d "r"`"
if [ "$THIS_VERSION" -lt "$NEW_VERSION" ]; then
if [ "$AUTOUPDATE" = "manually" ]; then
# show a message if a new version is avaible
send_message "New update avaible: r$NEW_VERSION - please update manually"
# remove locking
rm -rf /var/lock/update.lock
elif [ "$AUTOUPDATE" = "auto" ]; then
# show a message if a new version is avaible
send_message "New update avaible: r$NEW_VERSION - downloading the new version"
# downloading the new version
wget -c $UPDATEURL/$NEW_IMAGE.tar.bz2 -P /tmp
# extract the image
rm -rf /tmp/$NEW_IMAGE
tar -xjvf /tmp/$NEW_IMAGE.tar.bz2 -C /tmp
# move KERNEL and SYSTEM to an temporary file
mkdir -p /storage/.update
[ -f /tmp/$NEW_IMAGE/target/KERNEL ] && \
mv /tmp/$NEW_IMAGE/target/KERNEL /storage/.update/KERNEL.tmp
[ -f /tmp/$NEW_IMAGE/target/SYSTEM ] && \
mv /tmp/$NEW_IMAGE/target/SYSTEM /storage/.update/SYSTEM.tmp
sync
# move KERNEL and SYSTEM to the right place
mv /storage/.update/KERNEL.tmp /storage/.update/KERNEL
mv /storage/.update/SYSTEM.tmp /storage/.update/SYSTEM
# cleanup tmp files
rm -rf /tmp/$NEW_IMAGE
rm -rf /tmp/$NEW_IMAGE.tar.bz2
rm -rf /storage/.update/*.tmp
# we are ready (hopefully)
send_message "Update r$NEW_VERSION - downloaded and extracted - please reboot to install"
fi
fi
fi
fi

View File

@ -0,0 +1,92 @@
#!/bin/sh
. /storage/.config/update.conf
if [ ! -f /var/lock/update.lock ]; then
if [ "$AUTOUPDATE" = "manually" -o "$AUTOUPDATE" = "auto" ]; then
# locking autoupdate
touch /var/lock/update.lock
# sleep a bit, maybe we have a lot of work ;-)
sleep 30
send_message () {
xbmc-send --host=127.0.0.1 -a "Notification(Automatic update service:,$1)"
}
UPDATEURL="http://releases.openelec.tv"
# getting this version
THIS_DISTRIBUTION="`cat /etc/distribution`"
THIS_ARCH="`cat /etc/arch`"
THIS_VERSION="`cat /etc/version`"
THIS_MAJOR="`echo "$THIS_VERSION" | cut -d "." -f1`"
THIS_MINOR="`echo "$THIS_VERSION" | cut -d "." -f2`"
THIS_PATCH="`echo "$THIS_VERSION" | cut -d "." -f3`"
# get infofile with the latest released version
rm -rf /tmp/latest
wget $UPDATEURL/latest -P /tmp
NEW_IMAGE="`cat /tmp/latest |grep "$THIS_DISTRIBUTION-$THIS_ARCH"`"
NEW_VERSION="`echo "$NEW_IMAGE" | cut -d "-" -f3`"
rm -rf /tmp/latest
# compare installed version with latest released version
NEW_MAJOR="`echo "$NEW_VERSION" | cut -d "." -f1`"
NEW_MINOR="`echo "$NEW_VERSION" | cut -d "." -f2`"
NEW_PATCH="`echo "$NEW_VERSION" | cut -d "." -f3`"
if [ "$THIS_MAJOR" -lt "$NEW_MAJOR" -o \
"$THIS_MINOR" -lt "$NEW_MINOR" -o \
"$THIS_PATCH" -lt "$NEW_PATCH" ]; then
if [ "$AUTOUPDATE" = "manually" ]; then
# show a message if a new version is avaible
send_message "New update avaible: $NEW_VERSION - please update manually"
# remove locking
rm -rf /var/lock/update.lock
elif [ "$AUTOUPDATE" = "auto" ]; then
# show a message if a new version is avaible
send_message "New update avaible: $NEW_VERSION - downloading the new version"
# downloading the new version
wget -c $UPDATEURL/$NEW_IMAGE.tar.bz2 -P /tmp
# extract the image
rm -rf /tmp/$NEW_IMAGE
tar -xjvf /tmp/$NEW_IMAGE.tar.bz2 -C /tmp
# move KERNEL and SYSTEM to an temporary file
mkdir -p /storage/.update
[ -f /tmp/$NEW_IMAGE/target/KERNEL ] && \
mv /tmp/$NEW_IMAGE/target/KERNEL /storage/.update/KERNEL.tmp
[ -f /tmp/$NEW_IMAGE/target/SYSTEM ] && \
mv /tmp/$NEW_IMAGE/target/SYSTEM /storage/.update/SYSTEM.tmp
sync
# move KERNEL and SYSTEM to the right place
mv /storage/.update/KERNEL.tmp /storage/.update/KERNEL
mv /storage/.update/SYSTEM.tmp /storage/.update/SYSTEM
touch /var/
# cleanup tmp files
rm -rf /tmp/$NEW_IMAGE
rm -rf /tmp/$NEW_IMAGE.tar.bz2
rm -rf /storage/.update/*.tmp
# we are ready (hopefully)
send_message "Update $NEW_VERSION - downloaded and extracted - please reboot to install"
fi
fi
fi
fi