-apt -y install screen python3-venv gpg dirmngr apache2-utils
-su plom -c "gpg --recv-key ${gpg_key}"
-# TODO: After this, we could in theory remove dirmngr if we only installed it just now.
+apt -y install screen python3-venv gnupg
+keyservers='sks-keyservers.net/ keys.gnupg.net'
+set +e
+while true; do
+ do_break=0
+ for keyserver in $(echo "${keyservers}"; do
+ su plom -c "gpg --no-tty --keyserver $keyserver --recv-key ${gpg_key}"
+ if [ $? -eq "0" ]; then
+ do_break=1
+ break
+ fi
+ echo "Attempt with keyserver ${keyserver} unsuccessful, trying other."
+ if [ "${do_break}" -eq "1" ]; then
+ break
+ fi
+done
+set -e