From 67db4b362d658068e59ecd320f1a8d6ea9b465fa Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 31 Oct 2024 01:51:02 +0100 Subject: [PATCH] Update raspi setup. --- many_releases/aptmark/raspi | 8 ++- .../etc/all/locale.conf | 0 .../{user => desktop}/.config/sway/config | 0 many_releases/scripts/_misc.sh | 60 +++++++++++++++++++ testing/scripts/setup_raspi.sh | 58 ++---------------- 5 files changed, 71 insertions(+), 55 deletions(-) rename {testing => many_releases}/etc/all/locale.conf (100%) rename many_releases/home/{user => desktop}/.config/sway/config (100%) diff --git a/many_releases/aptmark/raspi b/many_releases/aptmark/raspi index c8b8c57..6db4efe 100644 --- a/many_releases/aptmark/raspi +++ b/many_releases/aptmark/raspi @@ -9,9 +9,13 @@ sway pulseaudio # for setting console keyboard via /etc/default/keyboard console-setup +# for setting system time +ntpsec-ntpdate +# basic usage +mpv +firefox-esr # for convenience +foot sudo vim ack -foot -mpv diff --git a/testing/etc/all/locale.conf b/many_releases/etc/all/locale.conf similarity index 100% rename from testing/etc/all/locale.conf rename to many_releases/etc/all/locale.conf diff --git a/many_releases/home/user/.config/sway/config b/many_releases/home/desktop/.config/sway/config similarity index 100% rename from many_releases/home/user/.config/sway/config rename to many_releases/home/desktop/.config/sway/config diff --git a/many_releases/scripts/_misc.sh b/many_releases/scripts/_misc.sh index c48602d..98b486f 100755 --- a/many_releases/scripts/_misc.sh +++ b/many_releases/scripts/_misc.sh @@ -95,3 +95,63 @@ upgrade_from_older_release() { apt -y -o Dpkg::Options::='--force-confnew' full-upgrade apt -y autoremove } + +add_my_public_key() { + # NB: vars expected to be pulled in from caller previously calling constants.sh! + apt update + apt -y install wget + wget "${URL_PUBLIC_KEY}" + cat "${FILENAME_PUBLIC_KEY}" >> "${PATH_AUTHORIZED_KEYS}" + rm "${FILENAME_PUBLIC_KEY}" +} + +setup_for_desktop() { + # NB: vars expected to be pulled in from caller previously calling constants.sh! + + # on installing console-setup, will guide it to do the right thing (including + # re-writing /etc/default/keyboard) + echo 'XKBLAYOUT=de' > /etc/default/keyboard + + # 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 + done + apt update + 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 + + # so Sway won't complain about failing to access non-existant background image file + sed -i '/^output \* bg/ s/^/#/' /etc/sway/config + + # Set up root environment. + for root in "${PATH_MANY}" '..'; do + copy_dirtree "${root}${PATH_REL_HOME}" '/root' all 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 $@ + done + cp -a "${PATH_REPO}" "${PATH_USER_HOME}" + mkdir "${PATH_USER_SSH}" + cp "${PATH_AUTHORIZED_KEYS}" "${PATH_USER_SSH}" + chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_HOME}" + passwd "${USERNAME}" + rm "${PATH_AUTHORIZED_KEYS}" +} diff --git a/testing/scripts/setup_raspi.sh b/testing/scripts/setup_raspi.sh index 791bf51..995a822 100755 --- a/testing/scripts/setup_raspi.sh +++ b/testing/scripts/setup_raspi.sh @@ -1,66 +1,18 @@ -#!/bin/sh +#!/bin/sh set -e 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 -apt update -apt -y install wget -wget "${URL_PUBLIC_KEY}" -cat "${FILENAME_PUBLIC_KEY}" >> "${PATH_AUTHORIZED_KEYS}" -rm "${FILENAME_PUBLIC_KEY}" +# 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 - -# 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}" '/etc' all raspi - copy_dirtree "${root}${PATH_REL_ETC}/all" '/etc/apt' apt - copy_dirtree "${root}${PATH_REL_ETC}/raspi" '/etc/apt' apt -done -apt update -mark_nonrequireds_auto -for root in "${PATH_MANY}" '..'; do - 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 -done - -# Ensure our desired locale is available. -locale-gen - -# Set Berlin localtime. -ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime - -# so Sway won't complain about failing to access non-existant background image file -sed -i '/^output \* bg/ s/^/#/' /etc/sway/config - -# Set up root environment. -for root in "${PATH_MANY}" '..'; do - copy_dirtree "${root}${PATH_REL_HOME}" '/root' all 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 user raspi -done -cp -a "${PATH_REPO}" "${PATH_USER_HOME}" -mkdir "${PATH_USER_SSH}" -cp "${PATH_AUTHORIZED_KEYS}" "${PATH_USER_SSH}" -chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_HOME}" -passwd "${USERNAME}" -rm "${PATH_AUTHORIZED_KEYS}" +# actual setup +setup_for_desktop raspi -- 2.30.2