From: Christian Heller Date: Tue, 1 Aug 2023 21:47:04 +0000 (+0200) Subject: Enhance bookworm setup. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance?a=commitdiff_plain;h=c23514e257843acb215e435b2da06a24c11f39dd;p=config Enhance bookworm setup. --- diff --git a/bookworm/setup_scripts/copy_dirtree.sh b/bookworm/setup_scripts/copy_dirtree.sh index c0cb9bf..2c385f0 100755 --- a/bookworm/setup_scripts/copy_dirtree.sh +++ b/bookworm/setup_scripts/copy_dirtree.sh @@ -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 diff --git a/bookworm/setup_scripts/install_for_target.sh b/bookworm/setup_scripts/install_for_target.sh index 1fac9d9..6d04152 100755 --- a/bookworm/setup_scripts/install_for_target.sh +++ b/bookworm/setup_scripts/install_for_target.sh @@ -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 index 0000000..18fc010 --- /dev/null +++ b/bookworm/setup_scripts/misc.sh @@ -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 +} diff --git a/bookworm/setup_scripts/purge_nonrequireds.sh b/bookworm/setup_scripts/purge_nonrequireds.sh index 216779d..40d1405 100755 --- a/bookworm/setup_scripts/purge_nonrequireds.sh +++ b/bookworm/setup_scripts/purge_nonrequireds.sh @@ -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 diff --git a/bookworm/setup_scripts/set_hostname_and_fqdn.sh b/bookworm/setup_scripts/set_hostname_and_fqdn.sh index a3b9f9a..b367906 100755 --- a/bookworm/setup_scripts/set_hostname_and_fqdn.sh +++ b/bookworm/setup_scripts/set_hostname_and_fqdn.sh @@ -13,13 +13,12 @@ # # 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}" diff --git a/bookworm/setup_scripts/setup.sh b/bookworm/setup_scripts/setup.sh index 815683e..b64080c 100755 --- a/bookworm/setup_scripts/setup.sh +++ b/bookworm/setup_scripts/setup.sh @@ -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 diff --git a/bookworm/setup_scripts/setup_desktop.sh b/bookworm/setup_scripts/setup_desktop.sh index c306dbe..9675df8 100755 --- a/bookworm/setup_scripts/setup_desktop.sh +++ b/bookworm/setup_scripts/setup_desktop.sh @@ -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 diff --git a/bookworm/setup_scripts/setup_home.sh b/bookworm/setup_scripts/setup_home.sh index 31418ee..9dfbf58 100755 --- a/bookworm/setup_scripts/setup_home.sh +++ b/bookworm/setup_scripts/setup_home.sh @@ -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"