Configure external storage for saving and loading deluge settings

From WikiDLXTV
Revision as of 18:07, 13 March 2010 by Larsar4 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Problem

There is problem that deluge client only save settings while device is plugged in. On next time then device is plug in you need to set up deluge again.

Solution

  1. Enable startup of deluge on your device
  2. Configure settings you want in deluge.
  3. Stop deluge daemon.
  4. Copy deluge settings folder from "/tmp/deluge" to your external storage folder, i.e, "-deluge". Store this path in variable DELUGECONFIG (i.e. replace $2 in the script to -deluge).
  5. Create deluge modified start/stop script "deluge.script", type source code, and place it in DELUGECONFIG folder. Source code:
#!/bin/sh

DELUGECONFIG="$2"

case "$1" in
start)
      	online.delayer 60 # pause until online
	add.webplugin deluge /etc/deluge/deluge
	deluged -c $DELUGECONFIG
	if [ "`grep -i \^DELUGEWEBUI=\'OFF\' /conf/config`" == "" ] ; then 
  		[ -w /var/www -a ! -d /var/www/deluge ] && ln -s  $DELUGECONFIG /var/www/deluge		
		sleep 3 && deluge -c $DELUGECONFIG -u web &
	fi
  ;;
stop)
  [ "`pidof deluged`" != "" ] && killall deluged && sleep 5
  [ "`pidof deluge`" != "" ] && killall deluge && sleep 5
  ;;
*)
  echo "Usage: $0 (start|stop)"
  ;;
esac
  1. Create script "S00custom-options", type source code, and place it in root folder of your external storage. Source code:
#!/bin/sh

#type external storage id
#to see it, type command "mount" in ssh on you device
#you will see string like "/tmp/media/usb/USB1/8d29b444-7459-41c2-a12a-c2a97087aef4"
#"8d29b444-7459-41c2-a12a-c2a97087aef4" - id 
DEVID="<external storage id>"

#type deluge config folder
DELUGECONFIG="<deluge config folder>"

case "$1" in
start|restart)
	$0 waitfordevice&
	;;
waitfordevice)
	DEVROOT=""
	while [ "$DEVROOT" = "" ] ; do
		DEVROOT="`mount | grep $DEVID | sed 's/^[/]dev[/].*[ ]on[ ]//g' | sed 's/[ ]type[ ].*//g'`"
		sleep 3
	done
	$DEVROOT/$DELUGECONFIG/deluge.script start $DEVROOT/$DELUGECONFIG
	config_tool -c POWER_DOWN_ACTION10="$DEVROOT/power.down $DELUGECONFIG"
	;;
esac

You need to set up DEVICEID variable in "S00custom-options" (replace <external storage id> with your external storage id), and DELUGECONFIG variable with value you selected earlier. In this tip it is "-deluge"

  1. Create script "power.down", type source code, and place it in root folder of your external storage. Source code:
#!/bin/sh
DEVROOT=`dirname $0`
DELUGECONFIG="$1"

$DEVROOT/$DELUGECONFIG/deluge.script stop
umount -l $DEVROOT
  1. Disable startup of deluge on your device

Content of external storage at end

..
$DELUGECONFIG
$DELUGECONFIG/deluge.script
power.down
S00custom-options

<other files and folders>

Usage

Well, there is ways to using torrent on external storage:

Loading with torrent

  1. Plug off device
  2. Connect external storage
  3. Plug on device
  4. Wait about 1-2 mins, device will load and start deluge

For safe eject of external storage, push OFF button on remote. Script will close deluge and unmount filesystem. It is better to set usb power off option - in this case then script close deluge, usb power will off, and you will see it.

Loading without torrent

  1. Plug off device
  2. Plug on device
  3. Wait for end of loading (you will see OSD main screen)
  4. Connect external storage