View Full Version : Automatic Update Script?
nitroxeno
2008-06-14, 05:48
Hi, Just installed last week Ubuntu 8.04 Server for the first time and having lots of fun with XBMC. I'm trying to find the best method to get my box to automatically download the daily SVN PPA. Ideally I would like to have a script that would run every morning around 3am, kill the xbmc task, do an apt-get install xbmc, then reboot when done. From what I have been reading the crontab command is what I need to accomplish this but having some trouble getting started. Any help would be appreciated. Thanks!
rodalpho
2008-06-14, 08:38
Why do you want to reboot? Anyway, this is untested, but something like this should do it.
Save as ~/scripts/updatexbmc.sh and chmod +x, then add to root's crontab as
0 3 * * * /home/youruser/scripts/updatexbmc.sh >/dev/null 2>&1
If you don't want to run as root, you'll need to setup sudoers to run the stuff without a password and use sudo before each line except the kill command.
#!/bin/bash
#kill xbmc
ps aux|grep -i youruser|grep -v grep|grep -i xbmc.bin|awk '{print $2}'|xargs kill -9
# update/upgrade packages
apt-get update
apt-get upgrade
#reboot machine
reboot
Ought to work.
Hrm, won't this update and upgrade ALL Ubuntu packages? XBMC will have to be set to run automatically when the machine boots as well. I agree that the reboot is probably not necessary and in my case would cause no end of issues - my video doesn't come up correctly if my EDID data cannot be read from my display. That data can only be read if the panel is on and is an active source for my Linux box. I could tweak around this but it would be painful I think.
Anyway, rebooting without access to a systems monitor that might be off for the night or in use with another source might have poor results when the machine comes up. I'd simply cycle XBMC rather than the whole system and I'd be careful about updating\upgrading all packages <shrug>
althekiller
2008-06-14, 19:18
Since our PPA isn't an official Ubuntu repo I'm fairly certain you have to manually install the packages.
apt-get upgrade -y --force-yes
That will allow you to auto-upgrade from a script.
rodalpho
2008-06-14, 22:19
If you add the PPA to your sources.list, apt-get upgrade should do it. And yeah, use blubya's -y switch, forgot about that.
I don't know why he wanted to reboot either. Shrug.
althekiller
2008-06-14, 22:55
I don't know why he wanted to reboot either. Shrug.
Windows user ;)
gzusrawx
2008-06-15, 01:24
Using something like this
apt-get upgrade xbmc -y --force-yes
should limit it to only updating xbmc
nitroxeno
2008-06-15, 03:04
Windows user ;)
Lol you got me... Thanks for the suggestions guys!