From fd775924eb94791f7efb1f44a7d4935823bf0ee2 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 27 Sep 2024 00:27:39 +0200
Subject: [PATCH] Various updates.

---
 bookworm/apt-mark/all                                       | 4 ++++
 bookworm/setup_scripts/_setup.sh                            | 2 +-
 bookworm/setup_scripts/init_user_and_keybased_login.sh      | 4 ++--
 ...grade_from_bullseye.sh => upgrade_from_older_release.sh} | 0
 bullseye/setup_scripts/init_user_and_keybased_login.sh      | 6 +++---
 5 files changed, 10 insertions(+), 6 deletions(-)
 rename bookworm/setup_scripts/{upgrade_from_bullseye.sh => upgrade_from_older_release.sh} (100%)

diff --git a/bookworm/apt-mark/all b/bookworm/apt-mark/all
index 617b707..aa1b30d 100644
--- a/bookworm/apt-mark/all
+++ b/bookworm/apt-mark/all
@@ -10,3 +10,7 @@ locales
 # extremely useful for basic network debugging; missed these more than once in an emergency
 netcat-traditional
 iputils-ping
+# what would we do without this …
+apt
+# not only pull in systemd, but also /sbin/reboot and /sbin/shutdown
+systemd-sysv
diff --git a/bookworm/setup_scripts/_setup.sh b/bookworm/setup_scripts/_setup.sh
index 1b8cae2..5f4bfda 100755
--- a/bookworm/setup_scripts/_setup.sh
+++ b/bookworm/setup_scripts/_setup.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 set -e
 . ./misc.sh
-. ./../misc.sh
+. ../../misc.sh
 
 expect_n_args 2 "(hostname, FQDN)" "$@"
 hostname="$1"
diff --git a/bookworm/setup_scripts/init_user_and_keybased_login.sh b/bookworm/setup_scripts/init_user_and_keybased_login.sh
index ad45834..ed24e87 100755
--- a/bookworm/setup_scripts/init_user_and_keybased_login.sh
+++ b/bookworm/setup_scripts/init_user_and_keybased_login.sh
@@ -20,8 +20,8 @@ server="$1"
 ssh-keygen -f "/home/plom/.ssh/known_hosts" -R "${server}"
 
 # This will be used to log-in as root from plom account.
-echo 'First, enter the old root password; then enter new password three times.'
-ssh root@"${server}" "passwd"
+printf '\nFirst, enter the old root password; then enter new password three times.\n\n'
+ssh root@"${server}" 'printf "\n\n" && passwd'
 
 # Save root password for sshpass
 stty -echo
diff --git a/bookworm/setup_scripts/upgrade_from_bullseye.sh b/bookworm/setup_scripts/upgrade_from_older_release.sh
similarity index 100%
rename from bookworm/setup_scripts/upgrade_from_bullseye.sh
rename to bookworm/setup_scripts/upgrade_from_older_release.sh
diff --git a/bullseye/setup_scripts/init_user_and_keybased_login.sh b/bullseye/setup_scripts/init_user_and_keybased_login.sh
index 475b12f..b69a095 100755
--- a/bullseye/setup_scripts/init_user_and_keybased_login.sh
+++ b/bullseye/setup_scripts/init_user_and_keybased_login.sh
@@ -20,9 +20,8 @@ server="$1"
 ssh-keygen -f "/home/plom/.ssh/known_hosts" -R "${server}"
 
 # This will be used to log-in as root from plom account.
-echo 'First, enter the old root password; then enter new password three times.'
-#ssh root@"${server}" "passwd"
-ssh root@"${server}" "ls"
+printf '\nFirst, enter the old root password; then enter new password three times.\n\n'
+ssh root@"${server}" 'printf "\n\n" && passwd'
 
 # Save root password for sshpass
 stty -echo
@@ -41,6 +40,7 @@ export SSHPASS="${PW_ROOT}"
 # would require setting a password for user plom otherwise not needed.
 sshpass -e scp ~/.ssh/id_rsa.pub root@"${server}":/tmp/authorized_keys
 sshpass -e ssh root@"${server}" \
+        'useradd -m plom && '\
         'mkdir /home/plom/.ssh && '\
         'chown plom:plom /home/plom/.ssh && '\
         'chown plom:plom /tmp/authorized_keys && '\
-- 
2.30.2