From: Christian Heller Date: Tue, 6 May 2025 00:13:06 +0000 (+0200) Subject: Fix. X-Git-Url: https://plomlompom.com/repos/add_task?a=commitdiff_plain;h=db862fb44d12861cb86bd2e38aa1acec4c185475;p=config Fix. --- diff --git a/bookworm/scripts/lib/core_setup b/bookworm/scripts/lib/core_setup index a8ed301..8dc1e46 100644 --- a/bookworm/scripts/lib/core_setup +++ b/bookworm/scripts/lib/core_setup @@ -1,8 +1,8 @@ . lib/apt_get_digested . lib/constants_user # USERNAME . lib/copy_dirtrees_of_tags -. lib/minimize_installation . lib/prefixed_msg + core_setup() { prefixed_msg_init 'core_setup' prefixed_msg 'starting (performing standard installation setup steps)' @@ -12,7 +12,7 @@ _FQDN="$2" _EXTERNAL_IP="$3" _INSTALL_TAGS="$4" -minimize_installation ${_INSTALL_TAGS} +./minimize_installation.sh ${_INSTALL_TAGS} prefixed_msg 'And now: dist-upgrade …' apt_get_digested '-q -q dist-upgrade' diff --git a/bookworm/scripts/lib/minimize_installation b/bookworm/scripts/lib/minimize_installation deleted file mode 100644 index 87e88d1..0000000 --- a/bookworm/scripts/lib/minimize_installation +++ /dev/null @@ -1,44 +0,0 @@ -. lib/apt_get_digested -. lib/ensure_packages_of_tags -. lib/prefixed_msg - -minimize_installation() { -prefixed_msg_init 'minimize_installation' -_INSTALL_TAGS="$@" -prefixed_msg "narrow system to what is required explicitly by Debian and by us, as per these INSTALL_TAGS: ${_INSTALL_TAGS}" - -_TOK_REQ='required' -_PATH_LIST_PREFIX=/tmp/list_ -_PATH_LIST_UNSORTED="${_PATH_LIST_PREFIX}unsorted" -_PATH_LIST_WHITE="${_PATH_LIST_PREFIX}white" -_PATH_LIST_ALL_PACKAGES="${_PATH_LIST_PREFIX}all_packages" -_PATH_LIST_BLACK="${_PATH_LIST_PREFIX}black" - -if ! which calc > /dev/null; then - prefixed_msg 'not found calc, which is needed, so installing …' - apt-get -y -q -q install calc > /dev/null -fi - -prefixed_msg_no_nl "collect packages deemed '${_TOK_REQ}' by Debian: " -dpkg-query -Wf '${Package} ${Priority}\n' | grep " ${_TOK_REQ}" | cut -d' ' -f1 > "${_PATH_LIST_UNSORTED}" -sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_WHITE}" -echo $(cat "${_PATH_LIST_WHITE}") - -prefixed_msg_no_nl 'collect installed packages outside this selection: ' -dpkg-query -Wf '${Package}\n' > "${_PATH_LIST_UNSORTED}" -sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_ALL_PACKAGES}" -comm -3 "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" > "${_PATH_LIST_BLACK}" -echo $(cat "${_PATH_LIST_BLACK}") - -prefixed_msg 'apt-mark auto from diff …' -apt-mark auto `cat "${_PATH_LIST_BLACK}"` > /dev/null -rm "${_PATH_LIST_UNSORTED}" "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" "${_PATH_LIST_BLACK}" - -prefixed_msg 'install or mark as manually installed packages from our own selections …' -ensure_packages_of_tags ${_INSTALL_TAGS} - -prefixed_msg 'run autopurge to get rid of all unwanted packages …' -apt_get_digested '-q -q autopurge' - -prefixed_msg_exit -} diff --git a/bookworm/scripts/lib/prefixed_msg b/bookworm/scripts/lib/prefixed_msg index d29d6bf..8ebd158 100644 --- a/bookworm/scripts/lib/prefixed_msg +++ b/bookworm/scripts/lib/prefixed_msg @@ -1,10 +1,10 @@ prefixed_msg_init() { - prefixed_msg_OLD_PREFIX="${prefixed_msg_PREFIX}|${prefixed_msg_OLD_PREFIX}" - prefixed_msg_PREFIX="$1" + export prefixed_msg_OLD_PREFIX="${prefixed_msg_PREFIX}|${prefixed_msg_OLD_PREFIX}" + export prefixed_msg_PREFIX="$1" } prefixed_msg_exit() { - prefixed_msg_PREFIX=$(echo "${prefixed_msg_OLD_PREFIX}" | cut -d'|' -f1) - prefixed_msg_OLD_PREFIX=$(echo "${prefixed_msg_OLD_PREFIX}" | cut -d'|' -f2-) + export prefixed_msg_PREFIX=$(echo "${prefixed_msg_OLD_PREFIX}" | cut -d'|' -f1) + export prefixed_msg_OLD_PREFIX=$(echo "${prefixed_msg_OLD_PREFIX}" | cut -d'|' -f2-) } prefixed_msg_no_nl() { diff --git a/bookworm/scripts/minimize_installation.sh b/bookworm/scripts/minimize_installation.sh new file mode 100755 index 0000000..ae682a2 --- /dev/null +++ b/bookworm/scripts/minimize_installation.sh @@ -0,0 +1,45 @@ +#!/bin/sh +set -e +cd $(dirname "$0") +. lib/apt_get_digested +. lib/ensure_packages_of_tags +. lib/prefixed_msg + +prefixed_msg_init 'minimize_installation' +_INSTALL_TAGS="$@" +prefixed_msg "narrow system to what is required explicitly by Debian and by us, as per these INSTALL_TAGS: ${_INSTALL_TAGS}" + +_TOK_REQ='required' +_PATH_LIST_PREFIX=/tmp/list_ +_PATH_LIST_UNSORTED="${_PATH_LIST_PREFIX}unsorted" +_PATH_LIST_WHITE="${_PATH_LIST_PREFIX}white" +_PATH_LIST_ALL_PACKAGES="${_PATH_LIST_PREFIX}all_packages" +_PATH_LIST_BLACK="${_PATH_LIST_PREFIX}black" + +if ! which calc > /dev/null; then + prefixed_msg 'not found calc, which is needed, so installing …' + apt-get -y -q -q install calc > /dev/null +fi + +prefixed_msg_no_nl "collect packages deemed '${_TOK_REQ}' by Debian: " +dpkg-query -Wf '${Package} ${Priority}\n' | grep " ${_TOK_REQ}" | cut -d' ' -f1 > "${_PATH_LIST_UNSORTED}" +sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_WHITE}" +echo $(cat "${_PATH_LIST_WHITE}") + +prefixed_msg_no_nl 'collect installed packages outside this selection: ' +dpkg-query -Wf '${Package}\n' > "${_PATH_LIST_UNSORTED}" +sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_ALL_PACKAGES}" +comm -3 "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" > "${_PATH_LIST_BLACK}" +echo $(cat "${_PATH_LIST_BLACK}") + +prefixed_msg 'apt-mark auto from diff …' +apt-mark auto `cat "${_PATH_LIST_BLACK}"` > /dev/null +rm "${_PATH_LIST_UNSORTED}" "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" "${_PATH_LIST_BLACK}" + +prefixed_msg 'install or mark as manually installed packages from our own selections …' +ensure_packages_of_tags ${_INSTALL_TAGS} + +prefixed_msg 'run autopurge to get rid of all unwanted packages …' +apt_get_digested '-q -q autopurge' + +prefixed_msg_exit diff --git a/testing/scripts/init_server_access.sh b/testing/scripts/init_server_access.sh index 5fed9ee..612cb3f 100755 --- a/testing/scripts/init_server_access.sh +++ b/testing/scripts/init_server_access.sh @@ -5,8 +5,12 @@ cd $(dirname "$0") . lib/constants_ssh # PATH_REL_SSH, PATH_USER_SSH . lib/expect_n_args . lib/path_tmp_timestamped +. lib/prefixed_msg . lib/trapp +prefixed_msg_init 'init_server_access.sh' +prefixed_msg 'starting' + PATH_KNOWN_HOSTS="${PATH_USER_SSH}/known_hosts" URL_REPO_CLONE='https://plomlompom.com/repos/clone/config' @@ -15,14 +19,14 @@ SERVER="$1" NEW_ROOT_PW="$2" OLD_ROOT_PW="$3" if [ ! -z "${OLD_ROOT_PW}" ]; then - echo '# Provided OLD_ROOT_PW, so will later try to log-in with that and place local key file …' + prefixed_msg 'Provided OLD_ROOT_PW, so will later try to log-in with that and place local key file …' abort_if_command_unknown sshpass fi -echo "# In ${PATH_KNOWN_HOSTS}, removing previous entry for ${SERVER} if found …" +prefixed_msg "In ${PATH_KNOWN_HOSTS}, removing previous entry for ${SERVER} if found …" ssh-keygen -f "${PATH_KNOWN_HOSTS}" -R "${SERVER}" > /dev/null -echo '# Scanning server for new key to add to file …' +prefixed_msg 'Scanning server for new key to add to file …' PATH_LOG_KEYSCAN_STDERR=$(path_tmp_timestamped) CMD_RM_LOG="rm ${PATH_LOG_KEYSCAN_STDERR}" set +e @@ -31,7 +35,7 @@ RESULT=$? set -e trapp "${CMD_RM_LOG}" if [ "${RESULT}" != "0" ]; then - echo "# ERROR: For some reason ssh-keyscan returned non-zero exit code, here's the stderr log:" + prefixed_msg "ERROR: For some reason ssh-keyscan returned non-zero exit code, here's the stderr log:" cat "${PATH_LOG_KEYSCAN_STDERR}" exit "${RESULT}" fi @@ -40,13 +44,13 @@ trapp SSH_TARGET="root@${SERVER}" if [ ! -z "${OLD_ROOT_PW}" ]; then - echo '# Logging in with provided password to place local key file …' + prefixed_msg 'Logging in with provided password to place local key file …' SSHPASS="${OLD_ROOT_PW}" sshpass -e scp -q "${PATH_USER_SSH}/id_rsa.pub" "root@${SERVER}:~/${PATH_REL_SSH}/authorized_keys" fi CMD_SSH="ssh ${SSH_TARGET}" -echo '# On server, setting new root password …' +prefixed_msg 'On server, setting new root password …' PATH_NEW_ROOT_PW=$(path_tmp_timestamped new_server_root_pw) CMD_RM_ROOT_PW="rm ${PATH_NEW_ROOT_PW}" trapp "${CMD_RM_ROOT_PW}" @@ -56,16 +60,19 @@ ${CMD_RM_ROOT_PW} trapp ${CMD_SSH} "cat ${PATH_NEW_ROOT_PW} | chpasswd; ${CMD_RM_ROOT_PW}" -echo '# On server, ensuring some minimum locale presence …' +prefixed_msg 'On server, ensuring some minimum locale presence …' ${CMD_SSH} 'if [ ! -z "$(locale 2>&1 1>/dev/null)" ]; then localectl set-locale en_US.UTF-8; fi' -echo '# On server, updating package database …' +prefixed_msg 'On server, updating package database …' ${CMD_SSH} 'apt-get -q -q update' -echo '# On server, installing git …' +prefixed_msg 'On server, installing git …' ${CMD_SSH} 'DEBIAN_FRONTEND=noninteractive apt-get -y install git > /dev/null' -echo '# On server, pulling config repo …' +prefixed_msg 'On server, pulling config repo …' ${CMD_SSH} "git clone -q ${URL_REPO_CLONE}" -echo "# Server ready, log in with: ssh root@${SERVER}" +prefixed_msg "Server ready, log in with: ssh root@${SERVER}" + +prefixed_msg 'finished' +prefixed_msg_exit diff --git a/testing/scripts/lib/apt_get_digested b/testing/scripts/lib/apt_get_digested new file mode 120000 index 0000000..fdf81df --- /dev/null +++ b/testing/scripts/lib/apt_get_digested @@ -0,0 +1 @@ +../../../trixie/scripts/lib/apt_get_digested \ No newline at end of file diff --git a/testing/scripts/lib/minimize_installation b/testing/scripts/lib/minimize_installation deleted file mode 120000 index e2b2ccb..0000000 --- a/testing/scripts/lib/minimize_installation +++ /dev/null @@ -1 +0,0 @@ -../../../trixie/scripts/lib/minimize_installation \ No newline at end of file diff --git a/testing/scripts/lib/prefixed_msg b/testing/scripts/lib/prefixed_msg new file mode 120000 index 0000000..713bd58 --- /dev/null +++ b/testing/scripts/lib/prefixed_msg @@ -0,0 +1 @@ +../../../trixie/scripts/lib/prefixed_msg \ No newline at end of file diff --git a/testing/scripts/setup_desktop.sh b/testing/scripts/setup_desktop.sh index 1415738..c5f21be 100755 --- a/testing/scripts/setup_desktop.sh +++ b/testing/scripts/setup_desktop.sh @@ -57,8 +57,8 @@ adopt_wifi_connection() { fi } -echo "\n# Upgrading to testing …" -./from_older_upgrade.sh +../../trixie/scripts/from_older_upgrade.sh desktop +./from_older_upgrade.sh desktop # NB: This needs to come before steps potentially overwriting /etc/network/interfaces. apt-get -y install network-manager > /dev/null diff --git a/trixie/scripts/from_older_upgrade.sh b/trixie/scripts/from_older_upgrade.sh index fb55105..ed9be54 100755 --- a/trixie/scripts/from_older_upgrade.sh +++ b/trixie/scripts/from_older_upgrade.sh @@ -6,7 +6,6 @@ cd $(dirname "$0") . lib/constants_etc # PATH_ETC . lib/constants_releases # PREV_RELEASE, THIS_RELEASE . lib/expect_n_args -. lib/minimize_installation . lib/prefixed_msg prefixed_msg_init 'from_older_upgrade.sh' @@ -22,7 +21,7 @@ prefixed_msg "starting (upgrading from ${PREV_RELEASE} to ${THIS_RELEASE})" prefixed_msg 'minimizing installation first so there is less to upgrade' INSTALL_TAGS='all minimal keep_if_installed:systemd_resolved' -"../../${PREV_RELEASE}/minimize_installation" "${INSTALL_TAGS}" +"../../${PREV_RELEASE}/scripts/minimize_installation.sh" "${INSTALL_TAGS}" apt_update_to_full_upgrade() { prefixed_msg 'Updating package database …' diff --git a/trixie/scripts/lib/minimize_installation b/trixie/scripts/lib/minimize_installation deleted file mode 120000 index b12c91d..0000000 --- a/trixie/scripts/lib/minimize_installation +++ /dev/null @@ -1 +0,0 @@ -../../../bookworm/scripts/lib/minimize_installation \ No newline at end of file