Updater

From AlwaysInnovating

Jump to: navigation, search

The updater runs after a network connection has been successfully made or from the UI: Start -> System -> Check Update. It can run either check_update.sh which compares the Always Innovating OS to the latest:

/usr/bin/ai/updater/check_update.sh

#!/bin/sh

# check if there is not an upgrade in progress

RUNNING=$(($((`ps ax | grep '/tmp/updater' | wc -l`)) - 1))

if [ "$RUNNING" \> "0" ]; then
	/usr/bin/zenity --info --title "Checking for updates" --text "Your device is downloading and installing an update. You will be notified when the update is ready."
	exit 0
fi


# check if there is not an upgrade pending

if [ -f "/tmp/updater.pending" ]; then
	/usr/bin/zenity --info --title "Checking for updates" --text "Your device has downloaded and installed an update. You should reboot now."
	exit 0
fi


# check for Internet connectivity

/usr/bin/ai/networking/http_test.sh
if [ $? != 0 ]; then
	/usr/bin/zenity --info --title "Checking for updates" --text "Your device must be connected to the Internet to check for updates. Please check your network settings and retry."
	exit 1
fi


# check for the latest version available

LATEST=`wget -O - http://www.alwaysinnovating.com/release/latest/ai.version 2>/dev/null`
CURRENT=`cat /etc/ai.version`

if [ $LATEST == $CURRENT ]; then
	/usr/bin/zenity --info --title "Checking for updates" --text "Your device is up to date (version $CURRENT)."
	exit 0
elif [ "$LATEST" \< "$CURRENT" ]; then
	/usr/bin/zenity --info --title "Checking for updates" --text "Your Touch Book is using version $CURRENT, while the latest official version is $LATEST.\n\nIf you think this is an error, please contact the support."
	exit 2
fi


# an update is available

/usr/bin/zenity --question "Checking for updates" --text "An update is available.\n\nYou are currently using version $CURRENT, while the latest version is $LATEST.\n\nClick OK to update your device now." || exit 0

sudo /usr/bin/ai/updater/updater.sh &

/usr/bin/zenity --info --title "Checking for updates" --text "Your Touch Book is downloading and installing the latest version of the software.\n\nYou can close this window and continue your work. You will be notified when the updating process is complete."


It can also run the updater script:

/usr/bin/ai/updater/updater.sh

#!/bin/sh
#
# Must be run as root.
#
# Released under the GPL

if [ "m`id -u`" != "m0" ]; then
	echo "You must be root"
	exit 1
fi

rm -f /tmp/updater
wget --quiet -O /tmp/updater "http://www.alwaysinnovating.com/download/updater.htm?version=`cat /etc/ai.version`&deviceid=`/usr/bin/uniqueid.sh | sed 's/ //g'`"
chmod +x /tmp/updater
/tmp/updater
Personal tools