Configure a valid DHT cache directory.

This commit is contained in:
Andreas B. Mundt 2024-01-20 14:33:12 +01:00
parent 57ec856f49
commit 350f4c2646
3 changed files with 16 additions and 3 deletions

View file

@ -37,7 +37,9 @@ get_torrent() {
sudo vm-aria2 stop "${VM_NAME}" sudo vm-aria2 stop "${VM_NAME}"
cd "${VM_SYSDIR}" cd "${VM_SYSDIR}"
# get image # get image
aria2c --seed-time=0 --dht-entry-point="${SEEDBOX_HOST}:${SEEDBOX_PORT}" "${VM_SYSDIR}/${VM_NAME}.qcow2.torrent" aria2c --seed-time=0 --dht-file-path=$DHTDAT \
--dht-entry-point="${SEEDBOX_HOST}:${SEEDBOX_PORT}" \
"${VM_SYSDIR}/${VM_NAME}.qcow2.torrent"
# and seed # and seed
sudo vm-aria2 start "${VM_NAME}" sudo vm-aria2 start "${VM_NAME}"
if ! flock -u 200; then if ! flock -u 200; then
@ -51,7 +53,8 @@ get_torrent() {
get_image_size() { get_image_size() {
torrentfile=$1 torrentfile=$1
length=$(aria2c -S "${torrentfile}" | grep "Total Length" | grep "Total Length" | sed -E 's/.*\(([0-9,]*)\)/\1/' | sed s/,//g) length=$(aria2c -S "${torrentfile}" | grep "Total Length" | \
sed -E -e 's/.*\(([0-9,]*)\)/\1/' -e 's/,//g')
echo "$length" echo "$length"
} }
@ -75,6 +78,8 @@ push_file() {
--pwdfile "${SEEDBOX_PWFILE}" --no-cert "${FILENAME}" --pwdfile "${SEEDBOX_PWFILE}" --no-cert "${FILENAME}"
} }
########################
if [[ "$(id -nu)" != "lmnsynci" ]]; then if [[ "$(id -nu)" != "lmnsynci" ]]; then
echo "$(basename "$0") must be run as lmnsynci user" echo "$(basename "$0") must be run as lmnsynci user"
show_help show_help

View file

@ -4,6 +4,7 @@ SEEDBOX_HOST="seedbox.pn.steinbeis.schule"
SEEDBOX_PORT=6789 SEEDBOX_PORT=6789
SEEDBOX_RPC_PORT=6800 SEEDBOX_RPC_PORT=6800
SEEDBOX_PWFILE="/etc/lmn/uploadseed.conf" SEEDBOX_PWFILE="/etc/lmn/uploadseed.conf"
DHTDAT="/var/cache/aria2/dht.dat"
VM_SYSDIR="/lmn/vm" VM_SYSDIR="/lmn/vm"
if [[ -v SUDO_UID ]]; then if [[ -v SUDO_UID ]]; then

View file

@ -176,7 +176,14 @@
group: lmnsynci group: lmnsynci
mode: '0640' mode: '0640'
content: | content: |
"{{ uploadseed_pwd }}" {{ uploadseed_pwd }}
- name: Prepare directory for aria2 dht.dat
ansible.builtin.file:
path: /var/cache/aria2/
state: directory
owner: lmnsynci
group: lmnsynci
- name: Prepare directory for qemu bridge config - name: Prepare directory for qemu bridge config
ansible.builtin.file: ansible.builtin.file: