From: Christian Heller Date: Thu, 24 Oct 2024 23:00:51 +0000 (+0200) Subject: Update Raspi setup. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/task?a=commitdiff_plain;h=7ff51403c3f15a5d233bdfb27b3f7c380bcd0392;p=config Update Raspi setup. --- diff --git a/constants.sh b/constants.sh index be2789a..015b654 100755 --- a/constants.sh +++ b/constants.sh @@ -1,6 +1,19 @@ #!/bin/sh -PATH_REPO="${HOME}/config" +set -e +PATH_REL_ETC="/etc" +PATH_REL_APTMARK="/aptmark" +PATH_REL_REPO="/config" +PATH_REPO="${HOME}${PATH_REL_REPO}" PATH_MANY="${PATH_REPO}/many_releases" PATH_MANY_MISC="${PATH_MANY}/scripts/_misc.sh" -NAME_ETC_DIR="etc" -NAME_APTMARK_DIR="aptmark" + +USERNAME="plom" +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_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}" + diff --git a/many_releases/home/all/.bashrc b/many_releases/home/all/.bashrc new file mode 100644 index 0000000..1b592d8 --- /dev/null +++ b/many_releases/home/all/.bashrc @@ -0,0 +1,29 @@ +# Settings for interactive shells. + +# Fancy colors for ls. +alias ls="ls --color=auto" + +# Other helpful aliases +alias sshauth='eval $(ssh-agent) && ssh-add' + +# Use vim as default editor for anything. +export VISUAL=vim +export EDITOR=$VISUAL + +# Colored prompt with username, hostname, date/time, directory. +colornumber=7 # Default to white if no color set via colornumber dotfile. +colornumber_file=~/.shell_prompt_color +if [ -f $colornumber_file ]; then + colornumber=`cat $colornumber_file` +fi +tput_color="$(tput setaf $colornumber)$(tput bold)" +tput_reset="$(tput sgr0)" +# Bash confuses the line length when not told to not count escape sequences. +if [ ! "$BASH" = "" ]; then + tput_color="\[$tput_color\]" + tput_reset="\[$tput_reset\]" +fi +PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $(whoami)@$(hostname):"\$\(pwd\)"]$ $tput_reset" +PS2="${tput_color}> $tput_reset" +PS3="${tput_color}select: $tput_reset" +PS4="${tput_color}+ $tput_reset" diff --git a/many_releases/home/minimal/.bashrc b/many_releases/home/minimal/.bashrc deleted file mode 100644 index 1b592d8..0000000 --- a/many_releases/home/minimal/.bashrc +++ /dev/null @@ -1,29 +0,0 @@ -# Settings for interactive shells. - -# Fancy colors for ls. -alias ls="ls --color=auto" - -# Other helpful aliases -alias sshauth='eval $(ssh-agent) && ssh-add' - -# Use vim as default editor for anything. -export VISUAL=vim -export EDITOR=$VISUAL - -# Colored prompt with username, hostname, date/time, directory. -colornumber=7 # Default to white if no color set via colornumber dotfile. -colornumber_file=~/.shell_prompt_color -if [ -f $colornumber_file ]; then - colornumber=`cat $colornumber_file` -fi -tput_color="$(tput setaf $colornumber)$(tput bold)" -tput_reset="$(tput sgr0)" -# Bash confuses the line length when not told to not count escape sequences. -if [ ! "$BASH" = "" ]; then - tput_color="\[$tput_color\]" - tput_reset="\[$tput_reset\]" -fi -PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $(whoami)@$(hostname):"\$\(pwd\)"]$ $tput_reset" -PS2="${tput_color}> $tput_reset" -PS3="${tput_color}select: $tput_reset" -PS4="${tput_color}+ $tput_reset" diff --git a/testing/scripts/constants.sh b/testing/scripts/constants.sh deleted file mode 100755 index 3aa951c..0000000 --- a/testing/scripts/constants.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -set -e -. ../../constants.sh diff --git a/testing/scripts/setup_raspi.sh b/testing/scripts/setup_raspi.sh index e0966c6..75c625f 100755 --- a/testing/scripts/setup_raspi.sh +++ b/testing/scripts/setup_raspi.sh @@ -1,45 +1,51 @@ #!/bin/sh set -e -. ./constants.sh +. ./../constants.sh . "${PATH_MANY_MISC}" # ensure we can log in -FILENAME_PUBLIC_KEY='id_rsa.pub' -URL_PUBLIC_KEY="https://dump.plomlompom.com/dump/${FILENAME_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}" >> ~/.ssh/authorized_keys +cat "${FILENAME_PUBLIC_KEY}" >> "${PATH_AUTHORIZED_KEYS}" rm "${FILENAME_PUBLIC_KEY}" -# service sshd restart upgrade_from_older_release # properly apt system for root in "${PATH_MANY}" '..'; do - copy_dirtree "${root}/${NAME_ETC_DIR}" "" all raspi + copy_dirtree "${root}${PATH_REL_ETC}" "" all raspi done apt update mark_nonrequireds_auto for root in "${PATH_MANY}" '..'; do - install_for_modules "${root}/${NAME_APTMARK_DIR}" all raspi + install_for_modules "${root}${PATH_REL_APTMARK}" all raspi done apt -y --purge autoremove # TODO test if isc-dhcp-client necessary (ifupdown certainly is) # Ensure our desired locale is available. -# locale-gen +locale-gen # Set Berlin localtime. -# ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime +ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime # Set up users and their environments. for root in "${PATH_MANY}" '..'; do - copy_dirtree "${root}/${NAME_HOME_DIR}" '/root' minimal root + copy_dirtree "${root}/${NAME_HOME_DIR}" '/root' all root done -adduser --disabled-password --gecos "" plom -usermod -a -G sudo plom -passwd plom -cp -a ~/config /home/plom -chown -R plom:plom /home/plom/config +adduser --disabled-password --gecos "" "${USERNAME}" +usermod -a -G sudo "${USERNAME}" +cp -a "${PATH_REPO}" "${PATH_USER_HOME}" +mkdir "${PATH_USER_SSH}" +cp "${PATH_AUTHORIZED_KEYS}" "${PATH_USER_SSH}" +for path in "${PATH_USER_HOME}${PATH_REL_REPO}" "${PATH_USER_SSH}"; do + chown -R "${USERNAME}:${USERNAME}" "${path}" +done +passwd "${USERNAME}" +rm "${PATH_AUTHORIZED_KEYS}"