Last active
October 8, 2015 12:38
-
-
Save philcryer/3333039 to your computer and use it in GitHub Desktop.
Raspberry PI OpenELEC updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Distributed under the terms of the BSD License. | |
# Copyright (c) 2012 Phil Cryer [email protected] | |
# Source https://gist.github.com/gists/3333039 | |
# DESCRIPTION: | |
# This code updates OpenELEC on Raspberry PI to any available dev version you want | |
# The script to install the latest version did install the latest, but then failed to run :( | |
# This script allowed me to try another version (a few days older), which worked :) | |
# USAGE: | |
# SSH into your OpenELEC instance | |
# cd /storage/.config | |
# wget https://raw.github.com/gist/3333039/rpi-openelecup.sh | |
# chmod a+x rpi-openelecup.sh | |
# ./rpi-openelecup.sh | |
# DISCLAIMER: | |
# code based on http://pastebin.com/raw.php?i=v5592MFq | |
# linked to from this OpenELEC forum post: | |
# http://openelec.tv/forum/133-installation/42383-update-script-for-openelec-on-raspberry-pi#43081 | |
# while this worked for me, ask your doctor if rpi-openelecup.sh is right for you | |
# location of builds (note, this changes from time to time) | |
#url="http://sources.openelec.tv/tmp/image/openelec-rpi/" | |
# 20130131 files have moved, the devel versions are under a new URL (h/t alek) | |
#url="http://openelec.thestateofme.com/" | |
# 20130505 files have been moved to a subdirectory, adding /dev_builds/ to the $url | |
url="http://openelec.thestateofme.com/dev_builds/" | |
# list currently installed revision | |
#short | |
#this_revision=`cat /etc/version | sed 's/.*\(r[0-9]*\)/\1/'` | |
#full | |
this_revision=`cat /etc/version` | |
banner() | |
{ | |
# everybody loves banners! | |
clear | |
echo "##############################################" | |
echo "# OpenELEC - The living room PC for everyone #" | |
echo "# ...... visit http://www.openelec.tv ...... #" | |
echo "##############################################" | |
echo; echo -n "Current Version: $this_revision" | |
} | |
latest() | |
{ | |
# figure out latest available version | |
last_base=`curl -s $url | grep .tar.bz2 | sed 's/.*\(OpenELEC.*\).tar.bz2.*/\1/' | sort | tail -1` | |
# last_revision=`echo $last_base | sed 's/.*\(r[0-9]*\)/\1/'` | |
# last_revision=`echo $last_base` | |
last_revision=`echo $last_base | cut -d"-" -f3,4,5` | |
#new_filename=$last_base.tar.bz2 | |
echo; echo "Latest Version: $last_revision" | |
} | |
runninglatest(){ | |
# check if currently installed revision is up-to-date | |
if [ $this_revision == $last_revision ] | |
then | |
echo; echo "System is running the latest version." | |
else | |
echo; echo "System is not running the latest." | |
fi | |
} | |
available(){ | |
# report on available versions | |
echo; echo "Available versions:" | |
curl -s $url | grep "<li>" | grep -v upload | grep -v tmp | cut -d"\"" -f2 | |
} | |
question(){ | |
# ask which version to install | |
# echo; echo -n "Latest or version? (L) or (devel-2012xxxxxxxxxx-rxxxxx) : " | |
echo; echo -n "Version to install? (ie- devel-2012xxxxxxxxxx-rxxxxx) : " | |
read install_version | |
get_filename=$install_version.tar.bz2 | |
if [ "$install_version" == "L" ]; then | |
echo; echo "Will install $last_revision" | |
else | |
echo; echo -n "Will install $install_version, OK? (y/n) : " | |
read yn | |
if [ "$yn" == "y" ]; then | |
echo | |
else | |
echo "Not installing."; exit 0 | |
fi | |
fi | |
} | |
getit() | |
{ | |
# change working directory | |
cd /storage | |
# get base, revision and filename of last build | |
new_filename=OpenELEC-RPi.arm-$install_version.tar.bz2 | |
new_dirname=`echo $new_filename | cut -d"." -f1,2` | |
# folder name is set equal to base | |
oldername=$last_base | |
# download corresponding file to working directory | |
urltolast=$url/$new_filename | |
#echo "wget $urltolast" | |
wget $urltolast | |
echo -e "Download complete\n" | |
} | |
unpack(){ | |
# uncompressing the tarball | |
echo "Uncompressing tarball, files extracted:" | |
tar -xvjf $new_filename | |
# check if .update folder exists, otherwise create it | |
if [ ! -d /storage/.update ]; then | |
mkdir /storage/.update | |
fi | |
# move OpenELEC files (including .md5 files) to update folder | |
# mv $foldername/target/* /storage/.update/ | |
mv $new_dirname/target/* /storage/.update/ | |
echo -e "\nOpenELEC files succesfully moved to update directory" | |
} | |
cleanup(){ | |
# clean up | |
rm -r $new_dirname | |
rm $new_filename | |
echo "Temporary files deleted" | |
} | |
syncup(){ | |
# sync and reboot system to apply updates | |
echo -n "Install complete, press any key to reboot : " | |
read any | |
echo; echo "System rebooting and updating" | |
sleep 5s | |
sync | |
reboot | |
} | |
# let's rock it | |
banner | |
latest | |
runninglatest | |
available | |
question | |
getit | |
unpack | |
cleanup | |
syncup | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment