home · contact · privacy
Improve testing setup.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 25 Feb 2025 02:18:40 +0000 (03:18 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 25 Feb 2025 02:18:40 +0000 (03:18 +0100)
constants.sh
many_releases/scripts/_misc.sh
testing/scripts/misc.sh [new file with mode: 0644]
testing/scripts/setup_desktop.sh [new file with mode: 0644]

index 2cf87181b63a1ae83ce4e58d09bae7956911c59c..3c52e617babaaee9cd6bd13b8177417505602a19 100755 (executable)
@@ -2,11 +2,11 @@
 set -e
 set -x
 
-PATH_REL_ETC="/etc"
-PATH_REL_APTMARK="/aptmark"
-PATH_REL_REPO="/config"
-PATH_REL_HOME="/home"
-PATH_REPO="${HOME}${PATH_REL_REPO}"
+PATH_REL_ETC="etc"
+PATH_REL_APTMARK="aptmark"
+PATH_REL_REPO="config"
+PATH_REL_HOME="home"
+PATH_REPO="${HOME}/${PATH_REL_REPO}"
 PATH_MANY="${PATH_REPO}/many_releases"
 PATH_MANY_MISC="${PATH_MANY}/scripts/_misc.sh"
 
@@ -15,8 +15,8 @@ PATH_USER_HOME="/home/${USERNAME}"
 
 FILENAME_PUBLIC_KEY='id_rsa.pub'
 URL_PUBLIC_KEY="https://dump.plomlompom.com/dump/${FILENAME_PUBLIC_KEY}"
-PATH_REL_LOCAL_SSH="/.ssh"
+PATH_REL_LOCAL_SSH=".ssh"
 PATH_REL_AUTHORIZED_KEYS="${PATH_REL_LOCAL_SSH}/authorized_keys"
-PATH_AUTHORIZED_KEYS="${HOME}${PATH_REL_AUTHORIZED_KEYS}"
-PATH_USER_SSH="${PATH_USER_HOME}${PATH_REL_LOCAL_SSH}"
+PATH_AUTHORIZED_KEYS="${HOME}/${PATH_REL_AUTHORIZED_KEYS}"
+PATH_USER_SSH="${PATH_USER_HOME}/${PATH_REL_LOCAL_SSH}"
 
index aed1526d4c07782d26ed834c55390abf30b3d523..8cf0ca7f3d2a9e8f5f5bfd252ee915705be7b997 100755 (executable)
@@ -125,16 +125,16 @@ setup_for_raspi() {
     # properly configure apt and reduce system to minimum that satisfies our own
     # aptmark/ package lists
     for root in "${PATH_MANY}" '..'; do
-        copy_dirtree "${root}${PATH_REL_ETC}/all" '/etc/apt' apt
+        copy_dirtree "${root}/${PATH_REL_ETC}/all" '/etc/apt' apt
     done
     apt update
     mark_nonrequireds_auto
     for root in "${PATH_MANY}" '..'; do
-        install_for_modules "${root}${PATH_REL_APTMARK}" all raspi
+        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 raspi
+        copy_dirtree "${root}/${PATH_REL_ETC}" '/etc' all raspi
     done
 
     # Ensure our desired locale is available.
@@ -149,14 +149,14 @@ setup_for_raspi() {
 
     # Set up root environment.
     for root in "${PATH_MANY}" '..'; do
-        copy_dirtree "${root}${PATH_REL_HOME}" '/root' all root raspi_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 raspi
+        copy_dirtree "${root}/${PATH_REL_HOME}" "${PATH_USER_HOME}" all desktop raspi
     done
     mkdir "${PATH_USER_SSH}"
     cp "${PATH_AUTHORIZED_KEYS}" "${PATH_USER_SSH}"
diff --git a/testing/scripts/misc.sh b/testing/scripts/misc.sh
new file mode 100644 (file)
index 0000000..ad1d4d6
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -e
+set -x
+
+. ../../constants.sh
+. "${PATH_MANY_MISC}"
+
+repo_path="${HOME}/public_repos/${PATH_REL_REPO}"
+if [ ! -d "${repo_path}" ]; then
+    repo_path="${HOME}/${PATH_REL_REPO}"
+fi
+config_tree_prefix="${repo_path}/testing"
+setup_scripts_dir="${config_tree_prefix}/scripts"
+
+get_system_name_arg() {
+    legal_system_names="t490s"
+    found=0
+    for system_name_i in $legal_system_names; do
+        if [ "$1" = "$system_name_i" ]; then
+            found=1
+            system_name="${system_name_i}"
+            continue   
+        fi
+    done
+    if [ "$found" = 0 ]; then
+        echo "Need legal system name."
+        false
+    fi
+}
diff --git a/testing/scripts/setup_desktop.sh b/testing/scripts/setup_desktop.sh
new file mode 100644 (file)
index 0000000..b3e5e11
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+set -e
+. ./misc.sh
+
+expect_n_args 1 "(system name)" "$@"
+get_system_name_arg "$1"
+
+# Adapt /etc/ to our needs by copying from ./etc_files. This will set
+# basic configurations affecting following steps, such as setup of APT
+# and the locale selection, so needs to be right at the beginning.
+copy_dirtree.sh "${config_tree_prefix}/${PATH_REL_ETC}" "" all
+
+# Migrate to testing.
+upgrade_from_older_release
+
+# Set hostname and FQDN.
+echo "${system_name}" > /etc/hostname
+hostname "${system_name}"
+final_ip="127.0.1.1"
+for ip in $(hostname -I); do
+    if [ $(echo "${ip}" | grep ':' | wc -l) -eq 1 ]; then
+        continue
+    fi
+    range_1=$(echo "${ip}" | cut -d "." -f 1)
+    range_2=$(echo "${ip}" | cut -d "." -f 2)
+    if [ "${range_1}" -eq 127 ]; then
+        continue
+    elif [ "${range_1}" -eq 10 ]; then
+        continue
+    elif [ "${range_1}" -eq 172 ]; then
+        if [ "${range_2}" -ge 16 ] && [ "${range_2}" -le 31 ]; then
+            continue
+        fi
+    elif [ "${range_1}" -eq 192 ]; then
+        if [ "${range_2}" -eq 168 ]; then
+            continue
+        fi
+    fi
+    final_ip="${ip}"
+done
+echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
+echo "${final_ip} ${system_name}" >> /etc/hosts
+
+# Ensure package installation state as defined by what packages are
+# defined as required by Debian policy and by settings in ./apt-mark/.
+mark_nonrequireds_auto
+for root in "${PATH_MANY}" '..'; do
+    install_for_modules "${root}/${PATH_REL_APTMARK}" all 
+done
+apt -y --purge autoremove
+for root in "${PATH_MANY}" '..'; do
+    copy_dirtree "${root}/${PATH_REL_ETC}" '/etc' all
+done
+
+# Ensure our desired locale is available.
+locale-gen
+
+# Set Berlin localtime.
+ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
+ntpdate-debian