From c88233ae8e76aaaac21b8755cf4a78d686e3f21c Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 4 Nov 2024 18:47:20 +0100
Subject: [PATCH] Upgrade Raspi setup.

---
 many_releases/scripts/_misc.sh | 24 +++++++++++++++++++-----
 testing/scripts/setup_raspi.sh | 17 +----------------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/many_releases/scripts/_misc.sh b/many_releases/scripts/_misc.sh
index 756c9f5..aed1526 100755
--- a/many_releases/scripts/_misc.sh
+++ b/many_releases/scripts/_misc.sh
@@ -105,9 +105,19 @@ add_my_public_key() {
     rm "${FILENAME_PUBLIC_KEY}"
 }
 
-setup_for_desktop() {
+setup_for_raspi() {
     # NB: vars expected to be pulled in from caller previously calling constants.sh!
 
+    # ensure we can log in
+    add_my_public_key
+    # (alternatively, or preceding this to reduce non-remote typing, TEMPORARILY
+    # (!) set password login:)
+    # passwd
+    # echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
+
+    # migrate to testing
+    upgrade_from_older_release
+
     # on installing console-setup, will guide it to do the right thing (including
     # re-writing /etc/default/keyboard)
     echo 'XKBLAYOUT=de' > /etc/default/keyboard
@@ -120,11 +130,11 @@ setup_for_desktop() {
     apt update
     mark_nonrequireds_auto
     for root in "${PATH_MANY}" '..'; do
-        install_for_modules "${root}${PATH_REL_APTMARK}" all $@
+        install_for_modules "${root}${PATH_REL_APTMARK}" all raspi
     done
     apt -y --purge autoremove
     for root in "${PATH_MANY}" '..'; do
-        copy_dirtree "${root}${PATH_REL_ETC}" '/etc' all $@
+        copy_dirtree "${root}${PATH_REL_ETC}" '/etc' all raspi
     done
 
     # Ensure our desired locale is available.
@@ -139,18 +149,22 @@ setup_for_desktop() {
 
     # Set up root environment.
     for root in "${PATH_MANY}" '..'; do
-        copy_dirtree "${root}${PATH_REL_HOME}" '/root' all root
+        copy_dirtree "${root}${PATH_REL_HOME}" '/root' all root raspi_root
     done
 
     # Set up user and their environment.
     adduser --disabled-password --gecos "" "${USERNAME}"
     usermod -a -G sudo "${USERNAME}"
     for root in "${PATH_MANY}" '..'; do
-        copy_dirtree "${root}${PATH_REL_HOME}" "${PATH_USER_HOME}" all desktop $@
+        copy_dirtree "${root}${PATH_REL_HOME}" "${PATH_USER_HOME}" all desktop raspi
     done
     mkdir "${PATH_USER_SSH}"
     cp "${PATH_AUTHORIZED_KEYS}" "${PATH_USER_SSH}"
     chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_HOME}"
     passwd "${USERNAME}"
     rm "${PATH_AUTHORIZED_KEYS}"
+
+    # Activate /root/throttle_cpu.sh daemonization.
+    systemctl enable throttle_cpu.service
+    systemctl start throttle_cpu.service
 }
diff --git a/testing/scripts/setup_raspi.sh b/testing/scripts/setup_raspi.sh
index 227bd4b..812f5b5 100755
--- a/testing/scripts/setup_raspi.sh
+++ b/testing/scripts/setup_raspi.sh
@@ -4,19 +4,4 @@ set -x
 . ../../constants.sh
 . "${PATH_MANY_MISC}"
 
-# ensure we can log in
-add_my_public_key
-# (alternatively, or preceding this to reduce non-remote typing, TEMPORARILY
-# (!) set password login:)
-# passwd
-# echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
-
-# migrate to testing
-upgrade_from_older_release
-
-# actual setup
-setup_for_desktop raspi
-
-copy_dirtree "${PATH_MANY}${PATH_REL_HOME}" '/root' raspi_root
-systemctl enable throttle_cpu.service
-# systemctl start throttle_cpu.service
+setup_for_raspi
-- 
2.30.2