home · contact · privacy
Enhance bookworm setup.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 1 Aug 2023 21:47:04 +0000 (23:47 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 1 Aug 2023 21:47:04 +0000 (23:47 +0200)
bookworm/setup_scripts/copy_dirtree.sh
bookworm/setup_scripts/install_for_target.sh
bookworm/setup_scripts/misc.sh [new file with mode: 0644]
bookworm/setup_scripts/purge_nonrequireds.sh
bookworm/setup_scripts/set_hostname_and_fqdn.sh
bookworm/setup_scripts/setup.sh
bookworm/setup_scripts/setup_desktop.sh
bookworm/setup_scripts/setup_home.sh

index c0cb9bfea68afa67b9a99f1f6a6c468f83766afc..2c385f0675249c412fa4d06709696e9622cf5782 100755 (executable)
@@ -8,11 +8,10 @@
 #
 # CAUTION: This removes original files at the affected paths.
 set -e
+. ./misc.sh
+
+expect_n_args 3 "(source root, target root, modules)" "$@"
 
-if [ "$#" -lt 3 ]; then
-    echo 'Need arguments: source root, target root, modules.'
-    false
-fi
 source_root="$1"
 target_root="$2"
 shift 2
index 1fac9d975c1673ecdd26638d0a8d1f60b64a5583..6d04152f90f979be24b55e0323edb1c5132b60a4 100755 (executable)
@@ -4,10 +4,7 @@
 #
 # Ignores anything in an apt-mark/ file after the last newline.
 set -e
-debian_version="bookworm"
-
-config_tree_prefix="${HOME}/config/${debian_version}"
-aptmark_dir="${config_tree_prefix}/apt-mark"
+. ./misc.sh
 
 for target in "$@"; do
     path="${aptmark_dir}/${target}"
diff --git a/bookworm/setup_scripts/misc.sh b/bookworm/setup_scripts/misc.sh
new file mode 100644 (file)
index 0000000..18fc010
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+set -e
+debian_version="bookworm"
+legal_system_names="x220 w530"
+config_tree_prefix="${HOME}/config/${debian_version}"
+setup_scripts_dir="${config_tree_prefix}/setup_scripts"
+aptmark_dir="${config_tree_prefix}/apt-mark"
+
+expect_n_args() {
+    min_args="$1"
+    explainer="$2"
+    shift 2
+    if [ "$#" -lt "${min_args}" ]; then
+        echo "Need at least $1 arguments … ${explainer}"
+        false
+    fi
+}
+
+get_system_name_arg() {
+    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
+}
index 216779d6af220d60e4e20660cf56edcc4a93736a..40d1405e0539d73bdadb662196a9078e55243cab 100755 (executable)
@@ -3,10 +3,7 @@
 # "required" or not depended on by packages of priority "required"
 # or not listed in the argument-selected files of apt-mark/.
 set -e
-debian_version="bookworm"
-
-config_tree_prefix="${HOME}/config/${debian_version}"
-aptmark_dir="${config_tree_prefix}/apt-mark"
+. ./misc.sh
 
 dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed 's/ required//' > /tmp/list_white_unsorted
 for target in "$@"; do
index a3b9f9a9651747229b7442eb5fea1e3a87a5d985..b367906e07749d33e7ee5c3270cd90040a1cde50 100755 (executable)
 #
 # Ignores IPv6s.
 set -e
+. ./misc.sh
+
+expect_n_args 1 "(hostname, fqdn)" "$@"
 
 hostname="$1"
 fqdn="$2"
-if [ "${hostname}" = "" ]; then
-    echo "Need hostname as argument."
-    false
-fi
 echo "${hostname}" > /etc/hostname
 hostname "${hostname}"
 
index 815683edbd91051da2c0eb9e20128a06bfda986c..b64080c3b5315f73aa500d013e43447f8e49ff4a 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 set -e
 debian_version="bookworm"
+. ./misc.sh
 
 # Provide maximum input for set_hostname_and_fqdn.sh.
 if [ "$#" -lt 2 ]; then
@@ -11,8 +12,6 @@ hostname="$1"
 fqdn="$2"
 shift 2
 
-config_tree_prefix="${HOME}/config/${debian_version}"
-setup_scripts_dir="${config_tree_prefix}/setup_scripts"
 cd "${setup_scripts_dir}"
 
 # Adapt /etc/ to our needs by copying from ./etc_files. This will set
index c306dbeedc34a66405d1f9d1c89257b801f36bde..9675df81987ac29ebfc3198ea6aa122f603121f6 100755 (executable)
@@ -1,32 +1,16 @@
 #!/bin/sh
 set -e
 set -x
-debian_version="bookworm"
-legal_system_names="x220 w530"
+. ./misc.sh
 
-if [ "$#" -ne 1 ]; then
-    echo 'Need exactly one argument (system name).'
-    false
-fi
-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
+expect_n_args 1 "(system name)" "$@"
+get_system_name_arg "$1"
 
 # Set up system without user environment.
-config_tree_prefix="${HOME}/config/${debian_version}"
-setup_scripts_dir="${config_tree_prefix}/setup_scripts"
 cd "${setup_scripts_dir}"
 ./setup.sh "${system_name}" "" user desktop thinkpad "${system_name}"
 
+# Set up NVIDIA eGPU config.
 if [ "$system_name" = "w530" ]; then
     cd
     git clone https://github.com/NVIDIA/open-gpu-kernel-modules
index 31418ee421a576d1b9223e961e08792bfbc04376..9dfbf5856bb513fb66eda8f4f1e6432de466cdae 100755 (executable)
@@ -1,28 +1,13 @@
 #!/bin/sh
 set -e
 debian_version="bookworm"
-legal_system_names="x220 w530"
+. ./misc.sh
 
-if [ "$#" -ne 1 ]; then
-    echo 'Need exactly one argument (system name).'
-    false
-fi
-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
-system_name="$1"
+expect_n_args 1 "(system name)" "$@"
+get_system_name_arg "$1"
 
-# config_tree_prefix="${public_repos_dir}/config/${debian_version}"
 git clone https://plomlompom.com/repos/clone/config
+cd $setup_scripts_dir
 ./copy_dirtree.sh "${config_tree_prefix}/home_files" "${HOME}" minimal user "${system_name}"
 
 # public_repos_dir="${HOME}/public_repos"