Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Distribute the database with daily backups

Daily cron job that dump the database, xz it, sign it with GPG,
create a torrent file and seed it with rtorrent.
Cette révision appartient à :
tomleb 2017-05-10 14:28:20 -04:00
Parent 6610074bcd
révision d8b82b52e0
6 fichiers modifiés avec 25 ajouts et 25 suppressions

Voir le fichier

@ -24,7 +24,9 @@ gpg2 --batch --yes --passphrase-fd 0 \
--output "${signature_file}" \ --output "${signature_file}" \
--detach-sig "${compressed_dump_file}" < "${NYAAPANTSU_PASSPHRASE_FILE}" --detach-sig "${compressed_dump_file}" < "${NYAAPANTSU_PASSPHRASE_FILE}"
mktorrent -a "${NYAAPANTSU_TRACKER}" "${compressed_dump_file}" "${signature_file}" mktorrent -a "${NYAAPANTSU_TRACKER}" \
-c "Official nyaapantsu database release ($(date +'%Y-%m-%d'))" \
"${compressed_dump_file}" "${signature_file}"
mv "${compressed_dump_file}" "${signature_file}" "${NYAAPANTSU_DOWNLOADED_DIR}" mv "${compressed_dump_file}" "${signature_file}" "${NYAAPANTSU_DOWNLOADED_DIR}"
mv "${compressed_dump_file}.torrent" "${NYAAPANTSU_WATCH_DIR}/" mv "${compressed_dump_file}.torrent" "${NYAAPANTSU_WATCH_DIR}/"

Voir le fichier

@ -1,14 +0,0 @@
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

Voir le fichier

@ -37,6 +37,15 @@
- mktorrent - mktorrent
- rtorrent - rtorrent
- name: Create download and watch directory
file:
path: "{{ item }}"
state: directory
with_items:
- "~/.rtorrent_session/"
- "{{ torrent_downloaded_directory }}"
- "{{ torrent_watch_directory }}"
- name: Configure rtorrent - name: Configure rtorrent
template: template:
src: rtorrent.rc.j2 src: rtorrent.rc.j2
@ -48,12 +57,12 @@
dest: /etc/systemd/system/rtorrent.service dest: /etc/systemd/system/rtorrent.service
become: true become: true
#- name: Enable and start rtorrent service - name: Enable and start rtorrent service
# systemd: systemd:
# enabled: yes enabled: yes
# name: rtorrent name: rtorrent
# state: started state: started
# become: true become: true
- name: Setup backup cron - name: Setup backup cron
template: template:

Voir le fichier

@ -1,3 +1,4 @@
port_range = {{ torrent_port_range }}
min_peers = 40 min_peers = 40
max_peers = 52 max_peers = 52
min_peers_seed = 10 min_peers_seed = 10
@ -24,5 +25,5 @@ encryption = allow_incoming,enable_retry,prefer_plaintext
dht = auto dht = auto
dht_port = 6881 dht_port = 6881
peer_exchange = ye peer_exchange = yes
# vim: ft=cfg # vim: ft=cfg

Voir le fichier

@ -5,11 +5,12 @@ After=network.target
[Service] [Service]
Type=forking Type=forking
KillMode=none KillMode=none
User=rtorrent User={{ ansible_ssh_user }}
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" # FIXME Start-pre gives an 'Operation not supported error'
#ExecStartPre=/usr/bin/bash -c "if test -e %h/.rtorrent_session/rtorrent.lock && test -z `pidof rtorrent`; then rm -f %h/.rtorrent_session/rtorrent.lock; fi"
ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent 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" ExecStop=/usr/bin/bash -c "test `pidof rtorrent` && killall -w -s 2 /usr/bin/rtorrent"
WorkingDirectory=/home/{{ ansible_ssh_user }} WorkingDirectory=%h
Restart=on-failure Restart=on-failure
[Install] [Install]

Voir le fichier

@ -4,3 +4,4 @@ backup_cron_job: /etc/cron.d/nyaapantsu_backup
torrent_tracker: udp://tracker.doko.moe:6969 torrent_tracker: udp://tracker.doko.moe:6969
torrent_downloaded_directory: ~/downloaded/ torrent_downloaded_directory: ~/downloaded/
torrent_watch_directory: ~/watch/ torrent_watch_directory: ~/watch/
torrent_port_range: 49164-49164