2011-08-19, 21:18
So, I like to automate things, and I hate to type the same stuff over and over. The script below is what I just put together to simplify updating to the latest nightly build (from the official repository, that is http://mirrors.xbmc.org/nightlies/darwin/atv2/):
What this script does is to first download the file listing from the atv2 builds directory, parse out the name of the topmost build (which should be the newest), and then download and install this package.
I am sure there is plenty of room for improvement, I haven't really made a shell script in about 10 years, so my script-fu is kinda rusty... But hey, this works for me. :-)
The easiest way to get this script on your ATV2 is probably to ssh to the box (I use PuTTY for this) and simply paste the following into your terminal (everything in one go works fine) and press enter:
Do remember to press enter, or your script won't be executable.
Now, whenever you'd like to update, you just ssh to your ATV2 and type this:
With PuTTY, and probably other ssh clients aswell, you can even tell it to run the above command automatically when you connect to the ATV2, if you'd prefer not to type anything at all except login and password. In session settings, go to Connection > SSH and put ./xbmcup.sh in "Remote command" and save your session). Now, when you connect with this session, instead of an interactive shell, PuTTY will trigger the script, and then disconnect and close its window when the update is finished.
Here's a URL to a picture showing the correct spot in the settings dialog:
http://www.ats.ucla.edu/clusters/common/...ty_ssh.jpg
For absolutely no typing, pair this with ssh keys instead of a logon password and you've got a completely automated updater triggered from your PC.
I will be adapting the script for the iOS (iPad) builds later - if there is any interest I'll post that one, too.
Best regards,
Durniplot
Code:
#!/bin/sh
xbmcdir=http://mirrors.xbmc.org/nightlies/darwin/atv2
wget -q $xbmcdir
xbmcdeb=$(cat index.html | gawk 'match($0, ">(xbmc-.*-.*-master-atv2.deb)<", a) {print a[1]}' | head -n 1)
rm index.html
wget $xbmcdir/$xbmcdeb
dpkg -i $xbmcdeb
rm $xbmcdeb
What this script does is to first download the file listing from the atv2 builds directory, parse out the name of the topmost build (which should be the newest), and then download and install this package.
I am sure there is plenty of room for improvement, I haven't really made a shell script in about 10 years, so my script-fu is kinda rusty... But hey, this works for me. :-)
The easiest way to get this script on your ATV2 is probably to ssh to the box (I use PuTTY for this) and simply paste the following into your terminal (everything in one go works fine) and press enter:
Code:
rm xbmcup.sh
echo '#!/bin/sh' >> ./xbmcup.sh
echo "xbmcdir=http://mirrors.xbmc.org/nightlies/darwin/atv2" >> ./xbmcup.sh
echo "wget -q \$xbmcdir" >> ./xbmcup.sh
echo "xbmcdeb=\$(cat index.html | gawk 'match(\$0, \">(xbmc-.*-.*-master-atv2.deb)<\", a) {print a[1]}' | head -n 1)" >> ./xbmcup.sh
echo "rm index.html" >> ./xbmcup.sh
echo "wget \$xbmcdir/\$xbmcdeb" >> ./xbmcup.sh
echo "dpkg -i \$xbmcdeb" >> ./xbmcup.sh
echo "rm \$xbmcdeb" >> ./xbmcup.sh
chmod 755 ./xbmcup.sh
Do remember to press enter, or your script won't be executable.
Now, whenever you'd like to update, you just ssh to your ATV2 and type this:
Code:
./xbmcup.sh
With PuTTY, and probably other ssh clients aswell, you can even tell it to run the above command automatically when you connect to the ATV2, if you'd prefer not to type anything at all except login and password. In session settings, go to Connection > SSH and put ./xbmcup.sh in "Remote command" and save your session). Now, when you connect with this session, instead of an interactive shell, PuTTY will trigger the script, and then disconnect and close its window when the update is finished.
Here's a URL to a picture showing the correct spot in the settings dialog:
http://www.ats.ucla.edu/clusters/common/...ty_ssh.jpg
For absolutely no typing, pair this with ssh keys instead of a logon password and you've got a completely automated updater triggered from your PC.
I will be adapting the script for the iOS (iPad) builds later - if there is any interest I'll post that one, too.
Best regards,
Durniplot