├── LICENSE
├── README.md
├── etc
├── deluge-daemon
├── deluge.conf
└── deluge.service
└── install-deluge.sh
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 sayem314
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # My-Deluge-Installer
2 |
3 | Make a seedbox using deluge torrent client
4 |
5 | Tested on Ubuntu and Debian
6 |
7 | Download this installer
8 |
9 | wget -q --no-check-certificate raw.githubusercontent.com/sayem314/My-Deluge-Installer/master/install-deluge.sh -O install-deluge.sh && chmod +x install-deluge.sh
10 |
11 | To install, run
12 |
13 | ./install-deluge.sh -install
14 |
15 | To uninstall, run
16 |
17 | ./install-deluge.sh -uninstall
18 |
--------------------------------------------------------------------------------
/etc/deluge-daemon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ### BEGIN INIT INFO
3 | # Provides: deluge-daemon
4 | # Required-Start: $local_fs $remote_fs
5 | # Required-Stop: $local_fs $remote_fs
6 | # Should-Start: $network
7 | # Should-Stop: $network
8 | # Default-Start: 2 3 4 5
9 | # Default-Stop: 0 1 6
10 | # Short-Description: Daemonized version of deluge and webui.
11 | # Description: Starts the deluge daemon with the user specified in
12 | # /etc/default/deluge-daemon.
13 | ### END INIT INFO
14 |
15 | # Author: Adolfo R. Brandes
16 | # Updated by: Jean-Philippe "Orax" Roemer
17 |
18 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
19 | DESC="Deluge Daemon"
20 | NAME1="deluged"
21 | NAME2="deluge"
22 | DAEMON1=/usr/bin/deluged
23 | DAEMON1_ARGS="-d" # Consult `man deluged` for more options
24 | DAEMON2=/usr/bin/deluge-web
25 | DAEMON2_ARGS="" # Consult `man deluge-web` for more options
26 | PIDFILE1=/var/run/$NAME1.pid
27 | PIDFILE2=/var/run/$NAME2.pid
28 | UMASK=022 # Change this to 0 if running deluged as its own user
29 | PKGNAME=deluge-daemon
30 | SCRIPTNAME=/etc/init.d/$PKGNAME
31 |
32 | # Exit if the package is not installed
33 | [ -x "$DAEMON1" -a -x "$DAEMON2" ] || exit 0
34 |
35 | # Read configuration variable file if it is present
36 | [ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
37 |
38 | # Load the VERBOSE setting and other rcS variables
39 | [ -f /etc/default/rcS ] && . /etc/default/rcS
40 |
41 | # Define LSB log_* functions.
42 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
43 | . /lib/lsb/init-functions
44 |
45 | if [ -z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES" ]
46 | then
47 | log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
48 | exit 0
49 | fi
50 |
51 | if [ -z "$DELUGED_USER" ]
52 | then
53 | log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME."
54 | exit 0
55 | fi
56 |
57 | #
58 | # Function to verify if a pid is alive
59 | #
60 | is_alive()
61 | {
62 | pid=`cat $1` > /dev/null 2>&1
63 | kill -0 $pid > /dev/null 2>&1
64 | return $?
65 | }
66 |
67 | #
68 | # Function that starts the daemon/service
69 | #
70 | do_start()
71 | {
72 | # Return
73 | # 0 if daemon has been started
74 | # 1 if daemon was already running
75 | # 2 if daemon could not be started
76 |
77 | is_alive $PIDFILE1
78 | RETVAL1="$?"
79 |
80 | if [ $RETVAL1 != 0 ]; then
81 | rm -f $PIDFILE1
82 | start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile \
83 | --exec $DAEMON1 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS
84 | RETVAL1="$?"
85 | else
86 | is_alive $PIDFILE2
87 | RETVAL2="$?"
88 | [ "$RETVAL2" = "0" -a "$RETVAL1" = "0" ] && return 1
89 | fi
90 |
91 | is_alive $PIDFILE2
92 | RETVAL2="$?"
93 |
94 | if [ $RETVAL2 != 0 ]; then
95 | sleep 2
96 | rm -f $PIDFILE2
97 | start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile \
98 | --exec $DAEMON2 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS
99 | RETVAL2="$?"
100 | fi
101 | [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2
102 | }
103 |
104 | #
105 | # Function that stops the daemon/service
106 | #
107 | do_stop()
108 | {
109 | # Return
110 | # 0 if daemon has been stopped
111 | # 1 if daemon was already stopped
112 | # 2 if daemon could not be stopped
113 | # other if a failure occurred
114 |
115 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2
116 | RETVAL2="$?"
117 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
118 | RETVAL1="$?"
119 | [ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2
120 |
121 | rm -f $PIDFILE1 $PIDFILE2
122 |
123 | [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] && return 0 || return 1
124 | }
125 |
126 | case "$1" in
127 | start)
128 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1"
129 | do_start
130 | case "$?" in
131 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
132 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
133 | esac
134 | ;;
135 | stop)
136 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1"
137 | do_stop
138 | case "$?" in
139 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
140 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
141 | esac
142 | ;;
143 | restart|force-reload)
144 | log_daemon_msg "Restarting $DESC" "$NAME1"
145 | do_stop
146 | case "$?" in
147 | 0|1)
148 | do_start
149 | case "$?" in
150 | 0) log_end_msg 0 ;;
151 | 1) log_end_msg 1 ;; # Old process is still running
152 | *) log_end_msg 1 ;; # Failed to start
153 | esac
154 | ;;
155 | *)
156 | # Failed to stop
157 | log_end_msg 1
158 | ;;
159 | esac
160 | ;;
161 | *)
162 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
163 | exit 3
164 | ;;
165 | esac
166 |
167 |
--------------------------------------------------------------------------------
/etc/deluge.conf:
--------------------------------------------------------------------------------
1 | start on started deluge
2 | stop on stopping deluge
3 |
4 | env uid=root
5 | env gid=root
6 | env umask=027
7 |
8 | exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluge-web
9 |
--------------------------------------------------------------------------------
/etc/deluge.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Deluge Bittorrent Client Web Interface
3 | After=network-online.target
4 |
5 | [Service]
6 | Type=simple
7 |
8 | User=root
9 | Group=root
10 | UMask=027
11 |
12 | ExecStart=/usr/bin/deluge-web
13 |
14 | Restart=on-failure
15 |
16 | [Install]
17 | WantedBy=multi-user.target
18 |
--------------------------------------------------------------------------------
/install-deluge.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # My Deluge Installer
4 | #
5 |
6 | #Global Config
7 | init=`cat /proc/1/comm`
8 | ip=`wget -qO- ipv4.icanhazip.com`
9 | user=`whoami`
10 | nocert="--no-check-certificate"
11 | bashname=$(basename $BASH_SOURCE)
12 |
13 | howto () {
14 | echo ""
15 | echo " To install, run"
16 | echo " $bashname -install"
17 | echo ""
18 | echo " To uninstall, run"
19 | echo " $bashname -uninstall"
20 | echo ""
21 | }
22 |
23 | chksudo () {
24 | if [[ "$EUID" -ne 0 ]]; then
25 | echo ""
26 | echo " Sorry, you need to run this as root"
27 | echo ""
28 | exit
29 | fi
30 | }
31 |
32 | installdeluge () {
33 | if [[ -e /etc/systemd/system/deluge.service || -e /etc/init/deluge.conf|| -e /etc/default/deluge-daemon ]]; then
34 | echo ""
35 | echo " Deluge is already installed"
36 | echo ""
37 | exit
38 | fi
39 |
40 | echo ""
41 | echo -n " Installing python-software-properties..."
42 | apt-get install python-software-properties -y &>/dev/null || apt-get install software-properties-common -y &>/dev/null
43 | echo " $(tput setaf 2)DONE$(tput sgr0)"
44 | echo -n " Addning repository ppa:deluge-team/ppa..."
45 | yes ENTER | add-apt-repository ppa:deluge-team/ppa &>/dev/null
46 | echo " $(tput setaf 2)DONE$(tput sgr0)"
47 | echo -n " Upadting repository..."
48 | apt-get update -y &>/dev/null
49 | echo " $(tput setaf 2)DONE$(tput sgr0)"
50 | echo -n " Installing deluged deluge-webui..."
51 | apt-get install deluged deluge-webui -y &>/dev/null
52 | echo " $(tput setaf 2)DONE$(tput sgr0)"
53 | echo ""
54 |
55 | # Starting Service
56 | makeservice;
57 | #deluged
58 | #deluge-web --fork
59 | echo ""
60 | invoke-rc.d deluge-daemon start
61 | echo ""
62 | echo " Access deluge at $(tput setaf 3)http://$ip:8112$(tput sgr0)"
63 | echo " Default deluge password is $(tput setaf 3)deluge$(tput sgr0)"
64 | echo ""
65 |
66 | }
67 |
68 | makeservice () {
69 | rm -f /etc/default/deluge-daemon
70 | cat < /etc/default/deluge-daemon
71 | # Configuration for /etc/init.d/deluge-daemon
72 | # The init.d script will only run if this variable non-empty.
73 | DELUGED_USER="root"
74 | # Should we run at startup?
75 | RUN_AT_STARTUP="YES"
76 | EOF
77 | wget -q $nocert https://raw.githubusercontent.com/sayem314/My-Deluge-Installer/master/etc/deluge-daemon -O /etc/init.d/deluge-daemon
78 | chmod +x /etc/init.d/deluge-daemon
79 | update-rc.d deluge-daemon defaults
80 | }
81 |
82 | uninstalldeluge () {
83 | if [[ -e /etc/systemd/system/deluge.service || -e /etc/init/deluge.conf|| -e /etc/default/deluge-daemon ]]; then
84 | echo ""
85 | echo " Are you sure you want to uninstall Deluge? [y/N]"
86 | read -p " Select an option: " option
87 | case $option in
88 | [yY][eE][sS]|[yY])
89 | echo ""
90 | echo " Stopping deluge process"
91 | killall deluged
92 | killall deluge-web
93 | if [ "$init" == 'systemd' ]; then
94 | systemctl disable deluge
95 | rm -f /etc/systemd/system/deluge.service
96 | elif [ "$init" == 'init' ]; then
97 | rm -f /etc/init/deluge.conf
98 | fi
99 | echo ""
100 | echo " Uninstalling deluge"
101 | rm -f /etc/default/deluge-daemon
102 | rm -f /etc/init.d/deluge-daemon
103 | update-rc.d -f deluge-daemon remove
104 | apt-get remove --purge deluged deluge-webui -y &>/dev/null
105 | apt-get autoremove -y &>/dev/null
106 | apt-get autoclean -y &>/dev/null
107 | echo " Deluge Uninstalled"
108 | echo ""
109 | exit
110 | ;;
111 | [nN][oO]|[nN]) echo ""; exit;;
112 | *) echo ""; echo " Incorrect input, exiting! "; echo "";;
113 | esac
114 | else
115 | echo ""
116 | echo " Looks like Deluge is not installed"
117 | echo ""
118 | fi
119 | }
120 |
121 | # See how we were called.
122 | case $1 in
123 | '-install'|'install' )
124 | chksudo; installdeluge;;
125 | '-del'|'delete'|'-rm'|'-uninstall'|'uninstall' )
126 | chksudo; uninstalldeluge;;
127 | *)
128 | howto;;
129 | esac
130 | exit 1
131 |
--------------------------------------------------------------------------------