#!/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}"
+
--- /dev/null
+# 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"
+++ /dev/null
-# 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"
+++ /dev/null
-#!/bin/sh
-set -e
-. ../../constants.sh
#!/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}"