From e3d8f3115c7a62b9f35bba367378b76c5e4e7e2d Mon Sep 17 00:00:00 2001
From: gavinhanson <gavin@cylo.io>
Date: Mon, 22 Jan 2018 12:27:13 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20Initial=20Commit.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Dockerfile                         |  21 ++++--
 configs/core.conf                  | 106 +++++++++++++++++++++++++++++
 configs/web.conf                   |  19 ++++++
 root/Entrypoint.sh                 |  21 ++++++
 root/deluge-pass.py                |  34 +++++++++
 root/etc/cont-init.d/30-config     |   7 --
 root/etc/services.d/deluge-web/run |   2 +-
 root/etc/services.d/deluged/run    |   4 +-
 8 files changed, 198 insertions(+), 16 deletions(-)
 create mode 100644 configs/core.conf
 create mode 100644 configs/web.conf
 create mode 100644 root/Entrypoint.sh
 create mode 100644 root/deluge-pass.py
 delete mode 100644 root/etc/cont-init.d/30-config

diff --git a/Dockerfile b/Dockerfile
index db7dfc8..f853de7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,8 +3,8 @@ FROM lsiobase/alpine:3.7
 # set version label
 ARG BUILD_DATE
 ARG VERSION
-LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
-LABEL maintainer="sparklyballs"
+LABEL build_version="Cylo.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
+LABEL maintainer="cylo"
 
 # environment variables
 ENV PYTHON_EGG_CACHE="/config/plugins/.python-eggs"
@@ -46,12 +46,21 @@ RUN \
  echo "**** cleanup ****" && \
  apk del --purge \
 	build-dependencies && \
- rm -rf \
-	/root/.cache
+ rm -rf /root/.cache && \
+ wget -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz && \
+ gunzip GeoIP.dat.gz && \
+ mkdir -p /usr/share/GeoIP && \
+ mv GeoIP.dat /usr/share/GeoIP/GeoIP.dat
 
 # add local files
 COPY root/ /
+RUN mkdir /configs
+COPY configs /configs
+RUN chmod +x /Entrypoint.sh
 
-# ports and volumes
+# ports
 EXPOSE 8112 58846 58946 58946/udp
-VOLUME /config /downloads
+
+ENTRYPOINT /Entrypoint.sh
+
+CMD ["/init"]
\ No newline at end of file
diff --git a/configs/core.conf b/configs/core.conf
new file mode 100644
index 0000000..26b3dda
--- /dev/null
+++ b/configs/core.conf
@@ -0,0 +1,106 @@
+{
+"file": 1,
+"format": 1
+}{
+"info_sent": 0.0,
+"lsd": true,
+"send_info": false,
+"enc_in_policy": 1,
+"queue_new_to_top": false,
+"ignore_limits_on_local_network": true,
+"rate_limit_ip_overhead": true,
+"daemon_port": 58846,
+"natpmp": true,
+"max_active_limit": 999,
+"utpex": true,
+"max_active_downloading": 999,
+"max_active_seeding": 999,
+"allow_remote": true,
+"max_half_open_connections": 50,
+"download_location": "/torrents/downloading",
+"move_completed_path": "/torrents/completed",
+"compact_allocation": false,
+"max_upload_speed": -1.0,
+"cache_expiry": 60,
+"prioritize_first_last_pieces": false,
+"auto_managed": true,
+"enc_level": 2,
+"max_connections_per_second": 20,
+"dont_count_slow_torrents": false,
+"random_outgoing_ports": true,
+"max_upload_slots_per_torrent": -1,
+"new_release_check": false,
+"enc_out_policy": 1,
+"outgoing_ports": [
+0,
+0
+],
+"seed_time_limit": 0,
+"cache_size": 32768,
+"share_ratio_limit": 0.0,
+"max_download_speed": -1.0,
+"geoip_db_location": "/usr/share/GeoIP/GeoIP.dat",
+"torrentfiles_location": "/torrents/config/torrents",
+"stop_seed_at_ratio": false,
+"peer_tos": "0x00",
+"listen_interface": "",
+"upnp": true,
+"max_download_speed_per_torrent": -1,
+"max_upload_slots_global": -1,
+"enabled_plugins": [
+"AutoAdd",
+"Scheduler",
+"Label",
+"Notifications"
+],
+"random_port": false,
+"autoadd_enable": false,
+"max_connections_global": -1,
+"enc_prefer_rc4": true,
+"listen_ports": [
+6881,
+6891
+],
+"dht": true,
+"stop_seed_ratio": 2.0,
+"seed_time_ratio_limit": 0.0,
+"max_upload_speed_per_torrent": -1,
+"copy_torrent_file": true,
+"del_copy_torrent_file": true,
+"move_completed": true,
+"proxies": {
+"peer": {
+"username": "",
+"password": "",
+"type": 0,
+"hostname": "",
+"port": 8080
+},
+"web_seed": {
+"username": "",
+"password": "",
+"type": 0,
+"hostname": "",
+"port": 8080
+},
+"tracker": {
+"username": "",
+"password": "",
+"type": 0,
+"hostname": "",
+"port": 8080
+},
+"dht": {
+"username": "",
+"password": "",
+"type": 0,
+"hostname": "",
+"port": 8080
+}
+},
+"add_paused": false,
+"max_connections_per_torrent": -1,
+"remove_seed_at_ratio": false,
+"autoadd_location": "/torrents/config/watch",
+"plugins_location": "/torrents/config/deluge/plugins"
+}
\ No newline at end of file
diff --git a/configs/web.conf b/configs/web.conf
new file mode 100644
index 0000000..eb4d63e
--- /dev/null
+++ b/configs/web.conf
@@ -0,0 +1,19 @@
+{
+  "file": 1,
+  "format": 1
+}{
+  "sidebar_show_zero": false,
+  "pwd_sha1": "4f496c6a4e555132a1cc4034127a6af4bff88644",
+  "show_sidebar": true,
+  "enabled_plugins": [],
+  "first_login": false,
+  "theme": "gray",
+  "session_timeout": 3600,
+  "base": "/",
+  "show_session_speed": false,
+  "https": false,
+  "default_daemon": "127.0.0.1:58846",
+  "sidebar_multiple_filters": true,
+  "pwd_salt": "5588bea86a36353faf34c488a54e81a39a8fab27",
+  "port": 8112
+}
\ No newline at end of file
diff --git a/root/Entrypoint.sh b/root/Entrypoint.sh
new file mode 100644
index 0000000..47d6051
--- /dev/null
+++ b/root/Entrypoint.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+
+set -x
+
+mkdir -p /torrents/downloading
+mkdir -p /torrents/completed
+mkdir -p /torrents/config/deluge
+mkdir -p /torrents/config/deluge/plugins
+mkdir -p /torrents/config/log
+mkdir -p /torrents/config/torrents
+mkdir -p /torrents/config/watch
+
+mv /configs/* /torrents/config/deluge/
+rm -fr /configs
+
+chown -R abc:abc /torrents
+
+chmod +x /deluge-pass.py
+/deluge-pass.py /torrents/config/deluge ${DELUGE_PASSWORD}
+
+exec "/init"
diff --git a/root/deluge-pass.py b/root/deluge-pass.py
new file mode 100644
index 0000000..fa9ff5d
--- /dev/null
+++ b/root/deluge-pass.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# Changes the password for Deluge's Web UI
+
+from deluge.config import Config
+import hashlib
+import os.path
+import sys
+import subprocess
+
+if len(sys.argv) == 3:
+    deluge_dir = os.path.expanduser(sys.argv[1])
+
+    if os.path.isdir(deluge_dir):
+        try:
+            config = Config("web.conf", config_dir=deluge_dir)
+        except IOError, e:
+            print "Can't open web ui config file: ", e
+        else:
+            p = sys.argv[2]
+            password = sys.argv[2]
+            s = hashlib.sha1()
+            s.update(config['pwd_salt'])
+            s.update(password)
+            config['pwd_sha1'] = s.hexdigest()
+            try:
+                config.save()
+            except IOError, e:
+                print "Couldn't save new password: ", e
+            else:
+                print "New password successfully set!"
+    else:
+	print "%s is not a directory!" % deluge_dir
+else:
+    print "Usage: %s <deluge config dir> <pass>" % (os.path.basename(sys.argv[0]))
\ No newline at end of file
diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config
deleted file mode 100644
index 3c84a24..0000000
--- a/root/etc/cont-init.d/30-config
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/with-contenv bash
-
-# permissions
-chown -R abc:abc \
-	/config
-chown abc:abc \
-	/downloads
diff --git a/root/etc/services.d/deluge-web/run b/root/etc/services.d/deluge-web/run
index 7566762..83aadee 100644
--- a/root/etc/services.d/deluge-web/run
+++ b/root/etc/services.d/deluge-web/run
@@ -6,4 +6,4 @@ umask "$UMASK_SET"
 
 exec \
 	s6-setuidgid abc /usr/bin/deluge-web \
-	-c /config --loglevel=info
+	-c /torrents/config/deluge/ --loglevel=info
diff --git a/root/etc/services.d/deluged/run b/root/etc/services.d/deluged/run
index 00781cf..0469502 100644
--- a/root/etc/services.d/deluged/run
+++ b/root/etc/services.d/deluged/run
@@ -5,5 +5,5 @@ UMASK_SET=${UMASK_SET:-022}
 umask "$UMASK_SET"
 
 exec \
-	s6-setuidgid abc /usr/bin/deluged -c /config \
-	-d --loglevel=info -l /config/deluged.log
+	s6-setuidgid abc /usr/bin/deluged -c /torrents/config/deluge/ \
+	-d --loglevel=info -l /torrents/config/log/deluged.log
-- 
GitLab