Skip to content

Instantly share code, notes, and snippets.

@CypherpunkSamurai
Last active November 16, 2021 19:00
Show Gist options
  • Save CypherpunkSamurai/b72de9be7a06311f7df83905a19931a2 to your computer and use it in GitHub Desktop.
Save CypherpunkSamurai/b72de9be7a06311f7df83905a19931a2 to your computer and use it in GitHub Desktop.
FROM ghcr.io/linuxserver/baseimage-alpine:3.13
ARG BUILD_DATE
ARG VERSION
ARG TRANSMISSION_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="aptalca"
RUN \
echo "**** install packages ****" && \
apk add --no-cache \
ca-certificates \
curl \
findutils \
jq \
openssl \
p7zip \
python3 \
rsync \
tar \
transmission-cli \
transmission-daemon \
unrar \
unzip && \
echo "**** install transmission ****" && \
if [ -z ${TRANSMISSION_VERSION+x} ]; then \
TRANSMISSION_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:transmission-daemon$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add --no-cache \
transmission-cli==${TRANSMISSION_VERSION} \
transmission-daemon==${TRANSMISSION_VERSION} && \
echo "**** install third party themes ****" && \
curl -o \
/tmp/combustion.zip -L \
"https://github.com/Secretmapper/combustion/archive/release.zip" && \
unzip \
/tmp/combustion.zip -d \
/ && \
mkdir -p /tmp/twctemp && \
TWCVERSION=$(curl -sX GET "https://api.github.com/repos/ronggang/transmission-web-control/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]') && \
curl -o \
/tmp/twc.tar.gz -L \
"https://github.com/ronggang/transmission-web-control/archive/${TWCVERSION}.tar.gz" && \
tar xf \
/tmp/twc.tar.gz -C \
/tmp/twctemp --strip-components=1 && \
mv /tmp/twctemp/src /transmission-web-control && \
mkdir -p /kettu && \
curl -o \
/tmp/kettu.tar.gz -L \
"https://github.com/endor/kettu/archive/master.tar.gz" && \
tar xf \
/tmp/kettu.tar.gz -C \
/kettu --strip-components=1 && \
curl -o \
/tmp/flood-for-transmission.tar.gz -L \
"https://github.com/johman10/flood-for-transmission/releases/download/latest/flood-for-transmission.tar.gz" && \
tar xf \
/tmp/flood-for-transmission.tar.gz -C \
/ && \
echo "**** cleanup ****" && \
rm -rf \
/tmp/*
# copy local files
COPY root/ /
# ports and volumes
EXPOSE 9091 51413/tcp 51413/udp
VOLUME /config /downloads /watch
FROM linuxserver/transmission
RUN apk add --no-cache bash python3
RUN curl https://rclone.org/install.sh | sed 's/^ mandb/# /' | bash
COPY on_download_finish.sh /on_download_finish.sh
COPY remove_until_size.py /remove_until_size.py
RUN chmod +x on_download_finish.sh
RUN sed -i 's/^ "script-torrent-done-enabled": false/ "script-torrent-done-enabled": true/' /defaults/settings.json
RUN sed -i 's/^ "script-torrent-done-filename": ""/ "script-torrent-done-filename": "\/on_download_finish.sh"/' /defaults/settings.json
# docker run --name transclone \
# -it --rm \
# -p 19092:9091 \
# -e RCLONE_REMOTE=Drive:torrent \
# -v $HOME/.config/rclone:/rclone \
# transmission-rclone bash
nginx
```
location /transmission {
proxy_pass http://127.0.0.1:9091;
proxy_pass_header X-Transmission-Session-Id;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
https://unix.stackexchange.com/questions/64812/get-transmission-web-interface-working-with-web-server
#!/bin/sh
mkdir -p /logs/rclone && \
rclone copy --ignore-existing -v --config /rclone/rclone.conf /downloads/complete $RCLONE_REMOTE > "/logs/rclone/$(date +'%d_%m_%Y__%H_%M_%S').log" 2>&1 && \
python3 /remove_until_size.py /downloads/complete $MAX_DOWNLOADS_DIR_SIZE

Update the BT tracker list to the remote Aria2 via RPC. bash <(curl -fsSL git.io/tracker.sh) RPC '233.233.233.233:6800' 'Secret123'

BT tracker list to the local Aria2 via RPC and write it into the Aria2 configuration file. bash <(curl -fsSL git.io/tracker.sh) "/root/.aria2/aria2.conf" RPC

import argparse
import os
import shutil
def get_directory_size(start_path):
total_size = 0
for path, dirs, files in os.walk(start_path):
for f in files:
fp = os.path.join(path, f)
total_size += os.path.getsize(fp)
return total_size
def rmrf(path):
print('Removing {}'.format(path))
if os.path.isdir(path) and not os.path.islink(path):
shutil.rmtree(path)
elif os.path.exists(path):
os.remove(path)
def remove_old_files(start_path, size_to_remove):
dirs = {}
for f in os.listdir(start_path):
fp = os.path.join(start_path, f)
dirs[str(int(os.path.getmtime(fp)))] = {
'path': fp,
'size': get_directory_size(fp) if os.path.isdir(fp) else os.path.getsize(fp)
}
times = list(dirs.keys())
times.sort()
removed_size = 0
for t in times:
if removed_size > size_to_remove:
break
rmrf(dirs[t]['path'])
removed_size += dirs[t]['size']
return removed_size
argparser = argparse.ArgumentParser()
argparser.add_argument('directory')
argparser.add_argument('max_size', type=int)
args = argparser.parse_args()
DIRECTORY_PATH = args.directory
MAX_DIRECTORY_SIZE = args.max_size
directory_size = get_directory_size(DIRECTORY_PATH)
if directory_size > MAX_DIRECTORY_SIZE:
removed_size = remove_old_files(DIRECTORY_PATH, directory_size - MAX_DIRECTORY_SIZE)
print('Bytes deleted: {}'.format(removed_size))
else:
print('Nothing to delete')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment