home · contact · privacy
Update Raspi setup. master
authorChristian Heller <c.heller@plomlompom.de>
Thu, 24 Oct 2024 23:00:51 +0000 (01:00 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 24 Oct 2024 23:00:51 +0000 (01:00 +0200)
constants.sh
many_releases/home/all/.bashrc [new file with mode: 0644]
many_releases/home/minimal/.bashrc [deleted file]
testing/scripts/constants.sh [deleted file]
testing/scripts/setup_raspi.sh

index be2789a5c6161efaab639d2ce5f1595d3d449419..015b654a39156595d3996a11cc379616f442825b 100755 (executable)
@@ -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 (file)
index 0000000..1b592d8
--- /dev/null
@@ -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 (file)
index 1b592d8..0000000
+++ /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 (executable)
index 3aa951c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-set -e
-. ../../constants.sh
index e0966c6b1634c4dd18702fa5f8236f33b6128a38..75c625ff3a89cd2aa5af8db1c90094a90ce712c7 100755 (executable)
@@ -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}"