Use rtorrent to seed the torrents (fails on systemd)
Cette révision appartient à :
Parent
dff098da6a
révision
aaf3bd05d3
7 fichiers modifiés avec 96 ajouts et 10 suppressions
|
@ -8,6 +8,8 @@ NYAAPANTSU_PASSWORD="$2"
|
|||
NYAAPANTSU_DB="$3"
|
||||
NYAAPANTSU_PASSPHRASE_FILE="$4"
|
||||
NYAAPANTSU_TRACKER="$5"
|
||||
NYAAPANTSU_DOWNLOADED_DIR="$6"
|
||||
NYAAPANTSU_WATCH_DIR="$7"
|
||||
|
||||
dump_file="${NYAAPANTSU_DB}_$(date +'%Y_%m_%d_%H_%M').backup"
|
||||
|
||||
|
@ -23,3 +25,6 @@ gpg2 --batch --yes --passphrase-fd 0 \
|
|||
--detach-sig "${compressed_dump_file}" < "${NYAAPANTSU_PASSPHRASE_FILE}"
|
||||
|
||||
mktorrent -a "${NYAAPANTSU_TRACKER}" "${compressed_dump_file}" "${signature_file}"
|
||||
|
||||
mv "${compressed_dump_file}" "${signature_file}" "${NYAAPANTSU_DOWNLOADED_DIR}"
|
||||
mv "${compressed_dump_file}.torrent" "${NYAAPANTSU_WATCH_DIR}/"
|
||||
|
|
14
deploy/ansible/roles/backup/files/rtorrent.service
Fichier normal
14
deploy/ansible/roles/backup/files/rtorrent.service
Fichier normal
|
@ -0,0 +1,14 @@
|
|||
Unit]
|
||||
Description=rTorrent
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
KillMode=none
|
||||
ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent
|
||||
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent
|
||||
WorkingDirectory=%h
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
# vim: ft=cfg
|
|
@ -19,13 +19,6 @@
|
|||
become: true
|
||||
when: pass_file.stat.exists == true
|
||||
|
||||
- name: Setup backup cron
|
||||
template:
|
||||
src: backup_cron.j2
|
||||
dest: "{{ backup_cron_job }}"
|
||||
become: true
|
||||
when: pass_file.stat.exists == true
|
||||
|
||||
- name: Add epel repository
|
||||
yum_repository:
|
||||
name: epel
|
||||
|
@ -35,8 +28,36 @@
|
|||
gpgkey: https://getfedora.org/static/352C64E5.txt
|
||||
become: true
|
||||
|
||||
- name: Install mktorrent
|
||||
- name: Install mktorrent and rtorrent
|
||||
yum:
|
||||
name: mktorrent
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
become: true
|
||||
with_items:
|
||||
- mktorrent
|
||||
- rtorrent
|
||||
|
||||
- name: Configure rtorrent
|
||||
template:
|
||||
src: rtorrent.rc.j2
|
||||
dest: ~/.rtorrent.rc
|
||||
|
||||
- name: Copy systemd rtorrent service
|
||||
template:
|
||||
src: rtorrent.service.j2
|
||||
dest: /etc/systemd/system/rtorrent.service
|
||||
become: true
|
||||
|
||||
- name: Enable and start rtorrent service
|
||||
systemd:
|
||||
enabled: yes
|
||||
name: rtorrent
|
||||
state: started
|
||||
become: true
|
||||
|
||||
- name: Setup backup cron
|
||||
template:
|
||||
src: backup_cron.j2
|
||||
dest: "{{ backup_cron_job }}"
|
||||
become: true
|
||||
when: pass_file.stat.exists == true
|
||||
|
|
|
@ -1 +1 @@
|
|||
0 {{ backup_cron_hours }} * * * {{ backup_script }} {{ nyaapantsu_user }} {{ nyaapantsu_password }} {{ nyaapantsu_dbname }} {{ nyaapantsu_gpg_passphrase_file }} {{ torrent_tracker }}
|
||||
0 {{ backup_cron_hours }} * * * {{ backup_script }} {{ nyaapantsu_user }} {{ nyaapantsu_password }} {{ nyaapantsu_dbname }} {{ nyaapantsu_gpg_passphrase_file }} {{ torrent_tracker }} {{ torrent_downloaded_directory }} {{ torrent_watch_directory }}
|
||||
|
|
28
deploy/ansible/roles/backup/templates/rtorrent.rc.j2
Fichier normal
28
deploy/ansible/roles/backup/templates/rtorrent.rc.j2
Fichier normal
|
@ -0,0 +1,28 @@
|
|||
min_peers = 40
|
||||
max_peers = 52
|
||||
min_peers_seed = 10
|
||||
max_peers_seed = 52
|
||||
max_uploads = 15
|
||||
upload_rate = 0
|
||||
|
||||
# Default directory to save the downloaded torrents.
|
||||
directory = {{ torrent_downloaded_directory }}
|
||||
|
||||
# Watch a directory for new torrents, and stop those that have been
|
||||
# deleted.
|
||||
schedule = watch_directory,5,5,load_start={{ torrent_watch_directory }}/*.torrent
|
||||
|
||||
#schedule = low_diskspace,5,60,close_low_diskspace=100M
|
||||
|
||||
check_hash = yes
|
||||
|
||||
# Set whether the client should try to connect to UDP trackers.
|
||||
#use_udp_trackers = yes
|
||||
|
||||
# Should be force it ?
|
||||
encryption = allow_incoming,enable_retry,prefer_plaintext
|
||||
|
||||
dht = auto
|
||||
dht_port = 6881
|
||||
peer_exchange = ye
|
||||
# vim: ft=cfg
|
16
deploy/ansible/roles/backup/templates/rtorrent.service.j2
Fichier normal
16
deploy/ansible/roles/backup/templates/rtorrent.service.j2
Fichier normal
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=rTorrent
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
KillMode=none
|
||||
User=rtorrent
|
||||
ExecStartPre=/usr/bin/bash -c "if test -e /home/{{ ansible_ssh_user }}/.rtorrent_session/rtorrent.lock && test -z `pidof rtorrent`; then rm -f /home/{{ ansible_ssh_user }}/.rtorrent_session/rtorrent.lock; fi"
|
||||
ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent
|
||||
ExecStop=/usr/bin/bash -c "test `pidof rtorrent` && killall -w -s 2 /usr/bin/rtorrent"
|
||||
WorkingDirectory=/home/{{ ansible_ssh_user }}
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -2,3 +2,5 @@ backup_script: /usr/bin/nyaapantsu_backup.sh
|
|||
backup_cron_hours: 0
|
||||
backup_cron_job: /etc/cron.d/nyaapantsu_backup
|
||||
torrent_tracker: udp://tracker.doko.moe:6969
|
||||
torrent_downloaded_directory: ~/downloaded/
|
||||
torrent_watch_directory: ~/watch/
|
||||
|
|
Référencer dans un nouveau ticket