From a2073781a171ec663debb5f4db5d3f390ab4fbb6 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sat, 15 Dec 2018 00:53:10 +0100
Subject: [PATCH] Fix web server migration script bugs.

---
 all_new_2018/mirror_dir.sh       | 2 +-
 all_new_2018/setup_plomlombot.sh | 6 ++++--
 all_new_2018/setup_web.sh        | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/all_new_2018/mirror_dir.sh b/all_new_2018/mirror_dir.sh
index 688b2b8..cb943c9 100755
--- a/all_new_2018/mirror_dir.sh
+++ b/all_new_2018/mirror_dir.sh
@@ -13,7 +13,7 @@ eval `ssh-agent`
 ssh-add
 cd
 ssh plom@"${server}" "cd \"${dir}\" && tar cf ${path_package} ."
-scp plom@"${server}":"${path_package}" .
+scp plom@"${server}":"${path_package}" "${path_package}"
 mkdir -p "${dir}"
 cd "${dir}"
 tar xf "${path_package}"
diff --git a/all_new_2018/setup_plomlombot.sh b/all_new_2018/setup_plomlombot.sh
index 1de8ae2..135bbd2 100755
--- a/all_new_2018/setup_plomlombot.sh
+++ b/all_new_2018/setup_plomlombot.sh
@@ -13,23 +13,25 @@ irclogs_dir=/var/www/html/irclogs
 irclogs_pw_dir=/var/www/irclogs_pw
 cp "${config_tree_prefix}"/user_scripts/plomlombot_daemon.sh /home/plom/
 chown plom:plom /home/plom/plomlombot_daemon.sh
-apt -y install screen python3-venv gnupg
+apt -y install screen python3-venv gnupg dirmngr
 keyservers='sks-keyservers.net/ keys.gnupg.net'
 set +e
 while true; do
     do_break=0
-    for keyserver in $(echo "${keyservers}"; do
+    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."
+    done
     if [ "${do_break}" -eq "1" ]; then
         break
     fi
 done
 set -e
+# TODO: We may remove dirmngr here if only this script installed it.
 su plom -c "cd && git clone /var/public_repos/plomlombot-irc"
 systemctl enable /etc/systemd/system/plomlombot.service
 service plomlombot start
diff --git a/all_new_2018/setup_web.sh b/all_new_2018/setup_web.sh
index e81b105..661aa74 100755
--- a/all_new_2018/setup_web.sh
+++ b/all_new_2018/setup_web.sh
@@ -4,10 +4,10 @@ set -e
 ./hardlink_etc.sh web
 sed -i "s/REPLACE_fqdn_ECALPER/$(hostname -f)/g" /etc/nginx/nginx.conf
 sed -i "s/REPLACE_fqdn_ECALPER/$(hostname -f)/g" /etc/gitweb.conf
-apt -y -o Dpkg::Options::=--force-confold install nginx gitweb fcgiwrap
 cd /var/
 rm -rf www
 git clone plom@core.plomlompom.com:repos/website www
+apt -y -o Dpkg::Options::=--force-confold install nginx gitweb fcgiwrap
 mkdir /var/public_repos
 chown plom:plom /var/public_repos
 iptables-restore /etc/iptables/rules.v4
-- 
2.30.2