본문 바로가기
Synology/Docker(in Synology)

시놀로지 Docker transmission+ VPN + telegram (갱신 24.04.08)

by kage2k 2024. 4. 8.
728x90
반응형

시놀로지 Transmission + 100% complete send a message to Telegram.

필자는 ExpressVPN을 사용하고 있습니다. 아래의 링크에 설치법과 대략 비슷하게 진행하였습니다. 

 

참고 블로그 : https://blog.naver.com/locusok/223300437185

 

Transmission openvpn (surfshark) torrent 자동삭제

synology docker 에 transmission 을 설치했다. 기존에 download station 으로 사용하였지만, torrent 에 ...

blog.naver.com

 

자동삭제및 텔레그램 전송용 sh 파일

 

#!/bin/sh
# telegram configuration
# SERVER="[port] --auth [id]:[pass]"
SERVER="container-Port --auth id:password"
# token
TOKEN='텔레그램토큰'  
# CHAT_ID
CHAT_ID="텔레그램챗아이디"
URL='https://api.telegram.org/bot'$TOKEN
MSG_URL=$URL'/sendMessage?chat_id='

sleep 1s

# torrent remove

TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut -s -d " " -f 1`
for TORRENTID in $TORRENTLIST

do
   
    DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`
    STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
    if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
        
        # telegram message send
        curl --data-urlencode "text=Download Complete :  $TR_TORRENT_NAME " "$MSG_URL"$CHAT_ID"&"
        transmission-remote $SERVER --torrent $TORRENTID --remove
    fi
done

 

 

더보기

과거글...

 

현재 아래와 같이 세팅하고 사용하고 있습니다. 

Expressvpn + docker Transmission (in Synology)

vpn 연결은 ovpn 파일을 연결하여 쉽게 이루어져있습니다. 

 

집에서 너무 구형이 되버린 노트북에 해놀로지를 설치하고 토렌트 머신으로 만들어고

위에 처럼 vpn연결 및 외부에서도 접속하여 사용할 수 있도록 몇가지 구성을 변경하여서 사용합니다. 

 

Docker compose

version: "2.1"
services:
  transmission:
    image: lscr.io/linuxserver/transmission:latest
    container_name: transmission
    environment:
      - LOCAL_NETWORK=192.168.1.0/24
      - PUID=1026   # 시놀로지에 맞도록 
      - PGID=100    # 시놀로지에 맞도록
      - TZ=Asia/Seoul
      - TRANSMISSION_WEB_HOME=/transmissionic/ 
      - USER=id
      - PASS=pssword 
    volumes:
      - /volume1/docker/transmission/auto_del_to_telegram.sh:/confing/auto_del_to_telegram.sh
      - /volume1/docker/transmission:/config
      - /volume1/share4/transmission/downloads:/downloads
      - /volume1/share4/transmission/watch:/watch
    ports:
      - 9091:9091   # 원하는 포트로 변경합니다.예) 12343:9091 
      - 51413:51413
      - 51413:51413/udp
    restart: unless-stopped

TRANSMISSION_WEB_HOME 종류 

- TRANSMISSION_WEB_HOME=/combustion-release/

- TRANSMISSION_WEB_HOME=/transmission-web-control/

- TRANSMISSION_WEB_HOME=/kettu/

- TRANSMISSION_WEB_HOME=/flood-for-transmission/

- TRANSMISSION_WEB_HOME=/transmissionic/

 

 

Sh file

텔레그램으로 100% 메시지 전송용

!! 텔레그램 메시지 방은 본인이 만들어둔다.

#!/bin/sh
# telegram configuration
# SERVER="[port] --auth [id]:[pass]"
SERVER="port --auth id:password"    # need change your 
# token
TOKEN='telegram TOKEN'  # need change token
# CHAT_ID
CHAT_ID="telegram ID"   # need change id
URL='https://api.telegram.org/bot'$TOKEN
MSG_URL=$URL'/sendMessage?chat_id='

sleep 1s

# torrent remove

TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut -s -d " " -f 1`
for TORRENTID in $TORRENTLIST

do
    FILENAME=`/usr/bin/transmission-remote $SERVER --torrent $TORRENTID --info | grep Name | cut -c 9-60`
    DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`
    STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
    if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
        transmission-remote $SERVER --torrent $TORRENTID --remove
        # telegram message send
        /usr/bin/curl --data-urlencode "text=Download Complete :  $FILENAME" "$MSG_URL"$CHAT_ID"&"
       
    fi
done

파일명 .sh 로 만들어서 시놀로지에 올려둡니다.

- /volume1/docker/transmission/auto_del_to_telegram.sh:/confing/auto_del_to_telegram.sh

위 볼륨으로 연결하면 해당 파일이 도커 해당폴더안에 복사를 안해도 존재하는 것으로 인식합니다.

 


한번 실행하면 docker/transmission 폴더안에 settings.json 파일이 생성됩니다.

그리고 도커 트랜스미션을 실행  off한뒤에 해당 파일을 수정합니다.

 

{
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": true,
    "blocklist-url": "https://github.com/Naunter/BT_BlockLists/raw/master/bt_blocklists.gz",
    "cache-size-mb": 4,
    "dht-enabled": true,
    "download-dir": "/downloads/complete",
    "download-queue-enabled": true,
    "download-queue-size": 100,
    "encryption": 2,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/downloads/incomplete",
    "incomplete-dir-enabled": true,
    "lpd-enabled": false,
    "message-level": 2,
    "peer-congestion-algorithm": "",
    "peer-id-ttl-hours": 6,
    "peer-limit-global": 200,
    "peer-limit-per-torrent": 50,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": "default",
    "pex-enabled": true,
    "port-forwarding-enabled": true,
    "preallocation": 1,
    "prefetch-enabled": true,
    "queue-stalled-enabled": false,
    "queue-stalled-minutes": 30,
    "ratio-limit": 0,
    "ratio-limit-enabled": true,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-host-whitelist": "",
    "rpc-host-whitelist-enabled": false,
    "rpc-password": "웹 접속 암호 암호화 되었음",
    "rpc-port": 9091,
    "rpc-url": "/transmission/",
    "rpc-username": "웹 접속 아이디",
    "rpc-whitelist": "",
    "rpc-whitelist-enabled": false,
    "scrape-paused-torrents-enabled": true,
    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/confing/auto_del_to_telegram.sh",
    "seed-queue-enabled": false,
    "seed-queue-size": 10,
    "speed-limit-down": 0,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "start-added-torrents": true,
    "trash-original-torrent-files": true,
    "umask": 2,
    "upload-slots-per-torrent": 14,
    "utp-enabled": false,
    "watch-dir": "/watch",
    "watch-dir-enabled": true
}

위 settings.json 파일을 비교하고 본인이 원하는 부분을 수정합니다. (요즘 업로드 잘못 하다가 큰일 나는 경우도 있으니 조심)

sh 파일을  사용하는 부분은 아래 입니다.

    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/confing/auto_del_to_telegram.sh",

 

나머지는 100% 뒤 토렌트파일이 삭제되고 텔레그램으로 메시지가 전송되는지 확인하시면됩니다. 

 

끝.

 

 

 


* Setapp on Mac invite link flutterkage2k

https://go.setapp.com/invite/jinheesung

*  If it helps, buy me a cup of coffee.

https://www.buymeacoffee.com/flutterkage2k

감사합니다.

300x250
반응형