1#!/bin/sh
2
3config_path=$(config get green_download_path);
4app=transmission-daemon
5
6start()
7{
8	pidof $app && killall -9 $app && sleep 2
9
10	chmod 666 /dev/null
11
12	[ -d /tmp/admin ] && rm -r /tmp/admin;
13	ln -s $config_path /tmp/admin
14
15#	iptables -nvL fw2net | grep OWNER > /dev/null || iptables -I fw2net 3 -m owner --uid-owner admin -j ACCEPT
16#	su admin -c "/usr/bin/transmission-daemon -f -w $config_path &"
17	/usr/bin/transmission-daemon -o -f -w "$config_path" -g "/tmp/transmission/.config" &
18#	sleep 1
19#	transmission-remote --torrent-done-script /usr/bin/WhenDone.sh
20}
21
22stop()
23{
24	killall -9 $app
25	[ -d /tmp/admin ] && rm -r /tmp/admin
26	[ -d /tmp/transmission/.config ] && rm -r /tmp/transmission/.config
27}
28
29case $1 in
30	start)
31		start 
32		;;
33	stop)
34		stop
35		;;
36	restart)
37		start 
38		;;
39	*)
40		echo error arg, only start/stop/restart accept
41		;;
42esac
43
44