diff --git a/roles/lmn_vm/files/vm-sync b/roles/lmn_vm/files/vm-sync index 0e3646e..e84b68b 100755 --- a/roles/lmn_vm/files/vm-sync +++ b/roles/lmn_vm/files/vm-sync @@ -37,7 +37,9 @@ get_torrent() { sudo vm-aria2 stop "${VM_NAME}" cd "${VM_SYSDIR}" # 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 sudo vm-aria2 start "${VM_NAME}" if ! flock -u 200; then @@ -51,7 +53,8 @@ get_torrent() { get_image_size() { 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" } @@ -75,6 +78,8 @@ push_file() { --pwdfile "${SEEDBOX_PWFILE}" --no-cert "${FILENAME}" } +######################## + if [[ "$(id -nu)" != "lmnsynci" ]]; then echo "$(basename "$0") must be run as lmnsynci user" show_help diff --git a/roles/lmn_vm/files/vm.conf b/roles/lmn_vm/files/vm.conf index 2a50b69..d774c3c 100644 --- a/roles/lmn_vm/files/vm.conf +++ b/roles/lmn_vm/files/vm.conf @@ -4,6 +4,7 @@ SEEDBOX_HOST="seedbox.pn.steinbeis.schule" SEEDBOX_PORT=6789 SEEDBOX_RPC_PORT=6800 SEEDBOX_PWFILE="/etc/lmn/uploadseed.conf" +DHTDAT="/var/cache/aria2/dht.dat" VM_SYSDIR="/lmn/vm" if [[ -v SUDO_UID ]]; then diff --git a/roles/lmn_vm/tasks/main.yml b/roles/lmn_vm/tasks/main.yml index 7b4adc3..8a73e3f 100644 --- a/roles/lmn_vm/tasks/main.yml +++ b/roles/lmn_vm/tasks/main.yml @@ -176,7 +176,14 @@ group: lmnsynci mode: '0640' 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 ansible.builtin.file: