Files
Arch-R/packages/sysutils/autoupdate/scripts/autoupdate.devel
Stephan Raue 6df902f98d autoupdate:
- add copyright header
2010-05-16 10:05:31 +02:00

104 lines
3.4 KiB
Bash
Executable File

#!/bin/sh
################################################################################
# Copyright (C) 2009-2010 OpenELEC.tv
# http://www.openelec.tv
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
[ -f /storage/.config/update.conf ] && \
. /storage/.config/update.conf
if [ ! -f /var/lock/update.lock ]; then
if [ "$AUTOUPDATE" = "manually" -o "$AUTOUPDATE" = "auto" ]; then
# sleep a bit, maybe we have a lot of work ;-)
usleep 30000000
send_message () {
xbmc-send --host=127.0.0.1 -a "Notification(Automatic update service:,$1,20000)"
}
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"
elif [ "$AUTOUPDATE" = "auto" ]; then
# show a message if a new version is avaible
send_message "New update avaible: r$NEW_VERSION - downloading and extract the new version..."
# locking autoupdate
touch /var/lock/update.lock
# 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