30 lines
989 B
Bash
Executable file
30 lines
989 B
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
set -eu
|
|
|
|
# if less than one arguments supplied, display usage
|
|
if [[ $# -ne 2 ]]; then
|
|
echo "This script takes as input the name of the VM " >&2
|
|
echo "Usage: $0 [start|stop] vm_name" >&2
|
|
exit 1
|
|
fi
|
|
|
|
COMMAND="$1"
|
|
VM_NAME="$2"
|
|
|
|
source /etc/lmn/vm.conf
|
|
|
|
if [[ "${COMMAND}" = "start" ]]; then
|
|
systemd-run --unit=aria2-"${VM_NAME}" \
|
|
--slice=system-aria2 \
|
|
--uid="$(id -u lmnsynci)" \
|
|
--gid="$(id -g lmnsynci)" \
|
|
--nice=19 \
|
|
--working-directory="${VM_SYSDIR}" \
|
|
--collect \
|
|
--property=Type=exec \
|
|
--property=SuccessExitStatus=1 \
|
|
aria2c --bt-hash-check-seed=true --check-integrity=true --seed-ratio=0.0 --dht-entry-point="${SEEDBOX_HOST}:${SEEDBOX_PORT}" "${VM_SYSDIR}/${VM_NAME}.qcow2.torrent"
|
|
elif [[ "${COMMAND}" = "stop" ]]; then
|
|
systemctl stop "aria2-${VM_NAME}.service" || echo "Aria2-Service not running"
|
|
fi
|