Pogoplug V4에 Debian Jessie가 깔려있는 상태에서 Seedbox 만들기


전체적인 방향은 링크된 Seedbox 구축 관련 글(https://jes.sc/kb/rTorrent-ruTorrent-Seedbox-Guide.php)을 참고했으며, 참고한 문서는 rTorrent+ruTorrent로 seedbox를 구축했으나 나는 손에 익은 transmission으로 대체함.


전체 흐름은 아래와 같음

- Debian Install 후 기본설정

- Transmission 설치: https://wiki.debian.org/BitTorrent/Transmission

- Transmission web client 변경: Shift

- Remote client 설정: 데탑용 transmission-remote-gui, 안드로이드용 Transmission Remote

- Web server 설치: lighttpd (독립 게시물로 정리 예정)

- 서버 모니터링 webui 설치: webmin (독립 게시물로 정리 예정)



1. 기본설정

- Debian 설치 참고: 포고플러그: Debian Stretch 설치 및 기본 설정


- 필수는 아니지만 리포지토리를 국내미러로 변경
   : http://ftp.us.debian.org/debian --> http://ftp.kaist.ac.kr/debian


- 일반유저 생성: http://notme.tistory.com/45


- time zone, locale, 키보드: http://notme.tistory.com/46


- TAB 자동완성: bash-completion 설치 후 다시 로그인. 이게 bash 기본 기능이 아니었다니!



2. Transmission 설치

- Debian Wiki에 소개된 네개의 package 중 내가 필요한 것은 transmission-daemon

$ sudo apt-get install transmission-daemon



3. Transmission 설정
- 설정 파일 수정 전 transmission-daemon을 죽여야 함.

 $ sudo systemctl stop transmission-daemon

재시작 하기 전에 변경한 설정 파일을 백업해놓는게 좋음. daemon 재시작은 이렇게

 $ sudo systemctl start transmission-daemon


- 설정파일 위치는 여기: /etc/transmission-daemon/settings.json
  옵션에 대한 참고는 여기: https://github.com/transmission/transmission/wiki/Editing-Configuration-Files


3.1 내가 생각하는 특이하거나 주요한 설정은 아래와 같음. 기본설정을 유지한 것은 중요해도 기록하지 않음.
- "peer-congestion-algorithm": "lp"
  : 토렌트 통신의 우선순위를 낮춰서, 웹브라우징 등 다른 통신이 끊기지 않도록 함. 단, 업로드에만 적용
  뭐, 업로드 속도를 확 낮춰놓는 것이 간단한 방법이기는 하다만.. 미안하잖아 ^^

  참조 링크 및 설정방법: https://www.irif.fr/~jch//software/bittorrent/tcp-congestion-control.html


- peer-port
  : Local network 상에 다른 서버가 또 있어서 포트 바꿔줌. 공유기 upnp 기능에 기대서 랜덤 설정도 가능하겠음.


- "peer-socket-tos": "default"
  : 이것도 공유기에 전달하는 우선순위. congestion-algorithm과 어떻게 다른지는 모르겠고, 공유기가 이걸 처리해주는지도 아직은 모르겠음.


- "port-forwarding-enabled": true
  : 공유기에 upnp로 포트 전달 요청함.


- "queue-stalled-minutes": 10
  : 마른 씨드를 queue-download-size와 seed-queue-size에서 제외하는데 까지 대기 시간(분) 즉, 10분간 전송 없으면 count에서 제외


- "ratio-limit": 1, "ratio-limit-enabled": true
  : 업로드 ratio 기본값 및 활성화


- "rpc-password": "원하는 비밀번호로 변경", "rpc-username": "원하는 ID로 변경"
  : password는 저장 후 transmission-daemon 실행하면 알아서 암호화됨


- "rpc-whitelist": "127.0.0.1, 192.168.0.*", "rpc-whitelist-enabled": false
  : rpc 접속(webui 또는 remote client)을 whitelist에만 허용(whitelist 설정 + enabled = true)하거나, 아예 몽땅 허용함(enabled = false)


- "script-torrent-done-enabled": false, "script-torrent-done-filename": ""
  : 다운로드 완료 후 스크립트 실행여부와 스크립트 위치. 나중에 쏠쏠히 써먹겠음. 파일명 변경, 잡파일 정리, remux 등..


- "seed-queue-enabled": true, "seed-queue-size": 5
  : 데이터 전송이 더 이상 없는 마른 seed(stalled)를 제외하고 5개 까지만 seeding함.


- 다운로드/업로드 속도 제한 설정
  : 단위는 KB/s임. 이건 보조 seedbox이므로 욕심내지 말자.
  "speed-limit-down": 1024,
  "speed-limit-down-enabled": true,
  "speed-limit-up": 1024,
  "speed-limit-up-enabled": true,


- "umask": 2
  : 파일 접근권한 관련 바로 그 umask인데, 10진수로 표기함. 친근한 umask는 8진수.. 즉, 18 = 2x8+2 = 022임.
    따라서 18이 magic number기는 한데, 나는 2를 사용함.


- "upload-slots-per-torrent": 14
  : speed-limit-up / seed-queue-size / seed-queue-size = peer 당 최저 업로드 속도라는 관계를 가지고 있음.
    너무 짜게 줄 경우 양심에 걸리기도 하고, 진지한 분들은 block하실테니 한번 쯤은 계산해볼만 함.
    곰곰히 생각해보면 upload-slots-per-torrent 숫자가 높다고 꼭 남들에게 후한거는 아님.


3.2 transmission-daemon 유저명 확인
- /lib/systemd/system/transmission-daemon.service 파일을 열어보면 User=debian-transmission 라고 적혀있음.
  debian-transmission group에 속해있음.
  umask와 group 관계를 곰곰히 생각해봐야 토렌트로 받은 파일 관리를 일반 유저가 쉽게 할 수 있음.
  umask를 0으로 설정해서 토렌트로 받은 파일은 777로 사용하는 사람들도 많아보임.



4. Web client 변경 (Shift)

기본 web client는 깔끔하기는 한데, 기능이 좀 심심하여 사제 client로 변경함.
물론 Shift의 디자인이 적응하기 쉽지 않았던 것은 사실이고, tracker 추가 기능 때문에 선택했음.

설치 방법 참조: https://forum.transmissionbt.com/viewtopic.php?f=8&t=12555


그런데, 써 보니 tracker 추가는 제대로 안되고, UI는 기본 클라이언트가 편하다.


- 다운로드
덜 익숙하지만 git clone으로 가져와보기로 함. git pull로 업데이트 할 때 좋다나..

$ sudo apt-get install git-core
$ cd /opt
$ git clone https://github.com/killemov/Shift.git fatal: unable to access 'https://github.com/killemov/Shift.git/': Problem with the SSL CA cert (path? access rights?)

ssl용 certificate가 없어서 curl이 거부하는거라고 함.

 $ sudo apt-get install openssl ca-certificates
$ git clone https://github.com/killemov/Shift.git

transmission-deamon이 /opt/Shift 내의 파일을 접근할 수 있는 적절한 권한이 있어야 한다는데, 어디까지가 적절한지 몰라서 일단 읽기/실행만 가능한 상태로 다음 과정 진행


- web client 변경
TRANSMISSION_WEB_HOME라는 환경 변수에 다운로드한 Shift의 위치를 기록해주라고 함.
내 경우엔 systemd가 transmission-daemon 실행하기 때문에 systemd script 내에 기록해준다네.

/lib/systemd/system/transmission-daemon.service 에 아래와 같이 환경변수 추가

[Service]
....원래 있던 내용 제일 아래에 아래 줄 추가 (/opt/Shift는 git clone으로 다운받은 바로 그 디렉토리)
Environment=TRANSMISSION_WEB_HOME=/opt/Shift

- transmission-daemon 재시작

$ sudo systemctl daemon-reload
$ sudo systemctl restart transmission-daemon.service


- http://시드박스ip:9091 로 접속해서 web cient 확인

  마그넷, 시드파일 모두 잘 다운 받는다. /opt/Shift는 역시 읽기/실행 권한만 있으면 되는 거였음.


일단 오늘은 여기까지..