From 229bf1d61b7c115094a2c065ecdb9df4f04ed4dd Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 15 Apr 2020 23:53:53 +0200
Subject: [PATCH] Fix.

---
 buster/other_files/plomlombot_daemon.sh | 8 +++++++-
 buster/setup_scripts/setup_website.sh   | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/buster/other_files/plomlombot_daemon.sh b/buster/other_files/plomlombot_daemon.sh
index 2f267bd..7847d25 100755
--- a/buster/other_files/plomlombot_daemon.sh
+++ b/buster/other_files/plomlombot_daemon.sh
@@ -6,6 +6,7 @@ path=~/.plomlombot
 db_dir="${HOME}/plomlombot_db"
 irclogs_dir=/var/www/html/irclogs
 irclogs_pw_dir=/var/www/irclogs_pw
+hostname_mod_epoch=$(stat -c%Y /etc/hostname)
 while true; do
     if [ -f "${path}" ]; then
         cat "${path}" | while read line; do
@@ -46,7 +47,12 @@ while true; do
                 key=$(echo -n "${line}" | cut -d' ' -f2)
                 mkdir -p ~/plomlombot_db
                 cd ~/plomlombot_db
-                find . -path '*/*/raw_logs/*.txt' -mtime +1 -type f -exec gpg --recipient "${key}" --trust-model always --encrypt {} \; -exec rm {} \;
+                # Dirty hack: To avoid trouble with GPG key expiration, fake
+                # system to something reasonbly old (younger than key creation,
+                # older than expiration) by taking the mod datetime of
+                # /etc/hostname, which should have last be changed when the
+                # system was set up.
+                find . -path '*/*/raw_logs/*.txt' -mtime +1 -type f -exec gpg --recipient "${key}" --trust-model always --faked-system-time="${hostname_mod_epoch}" --encrypt {} \; -exec rm {} \;
             fi
 
         done
diff --git a/buster/setup_scripts/setup_website.sh b/buster/setup_scripts/setup_website.sh
index 84896bf..ac2d731 100755
--- a/buster/setup_scripts/setup_website.sh
+++ b/buster/setup_scripts/setup_website.sh
@@ -58,6 +58,7 @@ rm -rf /var/www
 mkdir /var/www
 chown plom:plom /var/www
 if [ "${init_state}" = "new" ]; then
+  # This assumes the old core.plomlompom.com filesystem hierarchy.
   su -lc "cd /var/repos && git clone --mirror ${old_server}:repos/website" plom
   cp "${config_tree_prefix}/other_files/website_hook_post-receive" /var/repos/website.git/hooks/post-receive
 fi
@@ -90,6 +91,8 @@ chown -R plom:plom "${irclogs_dir}"
 mkdir -p "${irclogs_pw_dir}"
 chown -R plom:plom "${irclogs_pw_dir}"
 if [ "${init_state}" = "new" ]; then
+    # Handle the case that the repo is in the old pre-buster server setup –
+    # even then, the URL should be the same.
   su -lc "cd /var/repos && git clone --mirror https://plomlompom.com/repos/clone/plomlombot-irc" plom
   su -lc "touch /var/repos/plomlombot-irc.git/git-daemon-export-ok" plom
   cp "${config_tree_prefix}/other_files/plomlombot_hook_post-receive" /var/repos/plomlombot-irc.git/hooks/post-receive
-- 
2.30.2