Issue 25: Adding script auto-upate
Status:  Fixed
Owner:
Closed:  Dec 2011
Project Member Reported by login...@gmail.com, Nov 27, 2011
It would be very useful, expecially for non-GUI appliances.
Nov 28, 2011
Project Member #1 addicted...@gmail.com
I'll need to find a way to detach a process from the script so that update runs smoothly.

Update process would then be :
Detect current build of the script
Use wget or curl to download the latest build and check it against the current one
If more recent, detach a process that would inject content of the new script to the current one.
Of course right after detaching this process we would exit torrentexpander.sh

This way we wouldn't have to deal with permissions...

... but I have no idea right now on how to do all that (especially the detach part)
Labels: -Priority-Low Priority-Medium
Nov 29, 2011
Project Member #2 login...@gmail.com
Dirty code for NMT PLATFORM

$crontab=/etc/cront/root.cron
$path_torrentexpander_update_script=/share/Apps/Transmission/bin/torrentexpander_update.sh

if [[ $auto_update == "yes" ]]; then
    already_planned = crontab -l | grep torrentexpander
	if [[ $already_planned == "" ]]; then
		echo '@reboot $path_torrentexpander_update_script >> $crontab'
	fi
fi

if [[ $auto_update == "no" ]]; then
 cat $crontab | sed 'g/@reboot $path_torrentexpander_update_script//s > $crontab
fi
Nov 29, 2011
Project Member #3 addicted...@gmail.com
Thanks for this
I'll do some tweaking... I'd really like to include auto update in the script without using cron
Dec 1, 2011
Project Member #4 login...@gmail.com
Another ideas:
torrentexpander create a script to autoupdating himself; it run torrentexpander_update.sh and ends. 
torrentexpander_update.sh take some time to ping google (we could use to very connection aslo!) while main program ends. 
Then the update starts.

if [[ $auto_update == "yes" && $is_outdated == "yes" ]]; then
	echo "#!/bin/sh
	ping -w 10 google.it;
	wget -o torrentexpander.sh http://torrentexpander.googlecode.com/svn/trunk/torrentexpander.sh
	chmod +x torrentexpander.sh
	" > torrentexpander_update.sh
	chmod +x torrentexpander_update.sh
	./torrentexpander_update.sh
fi
Dec 2, 2011
Project Member #5 addicted...@gmail.com
I had something similar in mind
I'm pretty sure we can do this without creating a new script (on other platforms than the NMT, chmod +x may not work)
We can use something like screen to launch a command in a parallel process.
This update routine will be at the beginning of the script, right after torrentexpander knows what the torrent source and destination are.
This command will start by a 1 second pause, torrentexpander will exit, torrentexpander will be rewritten with the latest version of the script, then be relaunched with the path to the source and destination.
We'll use the settings to store current version of the script and the last updated at

In order not to have to increment version number of the script, I'll also try to parse this page for the SVN revision number
https://code.google.com/p/torrentexpander/source/browse/trunk

Thanks
Dec 3, 2011
Project Member #6 addicted...@gmail.com
Current SVN release has auto update built-in
Script will update daily, weekly, monthly or never, based on your settings.
In the future I may need to add a branch to the project so that the trunk release is exempt of any bug
Dec 3, 2011
Project Member #7 login...@gmail.com
Thanks for this, but look  issue 26 
Dec 4, 2011
Project Member #8 addicted...@gmail.com
New SVN build
I'm using a temp text file instead of a variable to store the new script
My NMT fucks up right now so I can't test it

Also, I added support for vi text editor, so you can directly edit your settings by using /path/to/torrentexpander.sh -c

Let me know if it works for you
Dec 4, 2011
Project Member #9 login...@gmail.com
Excellent
Dec 4, 2011
Project Member #10 login...@gmail.com
(No comment was entered for this change.)
Status: Fixed