openssh-server
# firewalling
nftables
+# for playing nicely with ssh sessions via the foot terminal
+foot-terminfo
--- /dev/null
+. lib/abort
+
+expect_n_args() {
+ _N_MIN_ARGS="$1"
+ _N_MAX_ARGS="$2"
+ _USAGE="$3"
+ shift 3
+ _ABORT_MSG=
+ if [ "$#" -lt "${_N_MIN_ARGS}" ]; then
+ _ABORT_MSG="missing arguments (got $# instead of ${_N_MAX_ARGS})."
+ elif [ "$#" -gt "${_N_MAX_ARGS}" ]; then
+ shift "${_N_MAX_ARGS}"
+ _ABORT_MSG="unexpected arguments beyond expected number (${_N_MAX_ARGS}): $@"
+ fi
+ if [ ! -z "${_ABORT_MSG}" ]; then
+ if [ ! -z "${_USAGE}" ]; then
+ _ABORT_MSG="${_ABORT_MSG}\nExpected arguments: ${_USAGE}"
+ fi
+ abort "Aborting due to ${_ABORT_MSG}"
+ fi
+}
. lib/copy_dirtree
-. lib/constants_user
+. lib/constants_user # PATH_USER_HOME, USERNAME
setup_users() {
- MIN_TAGS="$1"
- TAGS_USER="$2"
- PATH_CONF_HOME=../home
- PATH_USER_BIN="${PATH_USER_HOME}/.local/bin"
+ _MIN_TAGS="$1"
+ _TAGS_USER="$2"
+ _PATH_CONF_HOME=../home
+ _PATH_USER_BIN="${PATH_USER_HOME}/.local/bin"
echo "\nSetting up root user's home directory."
- copy_dirtree "${PATH_CONF_HOME}" '/root' ${MIN_TAGS} root
+ copy_dirtree "${_PATH_CONF_HOME}" '/root' ${_MIN_TAGS} root
echo "\nSetting up user ${USERNAME}."
adduser --disabled-password --gecos "" "${USERNAME}"
usermod -a -G sudo "${USERNAME}"
- copy_dirtree "${PATH_CONF_HOME}" "${PATH_USER_HOME}" ${MIN_TAGS} ${TAGS_USER}
- mkdir -p "${PATH_USER_BIN}"
- cd "${PATH_USER_BIN}"
+ copy_dirtree "${_PATH_CONF_HOME}" "${PATH_USER_HOME}" ${_MIN_TAGS} ${_TAGS_USER}
+ mkdir -p "${_PATH_USER_BIN}"
+ cd "${_PATH_USER_BIN}"
ln -s ../../.plomlib.sh lib
cd - > /dev/null
chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_HOME}"
. lib/constants_user # USERNAME
. lib/copy_dirtree
. lib/determine_ip
-. lib/expect_min_n_args
+. lib/expect_n_args
. lib/init_packages
. lib/setup_users
MIN_TAGS='all server'
-expect_min_n_args 2 '(hostname, FQDN)' "$@"
+expect_n_args 2 2 'HOSTNAME, FQDN' $@
HOSTNAME="$1"
FQDN="$2"
PATH_CONF_ETC="${PATH_CONF}/${PATH_REL_ETC}"
PATH_ETC="/${PATH_REL_ETC}"
PATH_HOSTS="${PATH_ETC}/hosts"
+PATH_BORG_HOME=/home/borg
init_packages "${MIN_TAGS}"
mv "/root/${PATH_REL_SSH}/authorized_keys" "${PATH_USER_SSH}/"
chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_SSH}"
+echo '\nSetting up minimal borg user.'
+adduser --system --home "${PATH_BORG_HOME}" --shell /bin/sh borg
+cp -a "${PATH_USER_SSH}" "${PATH_BORG_HOME}/"
+chown -R borg:nogroup "${PATH_BORG_HOME}/${PATH_REL_SSH}"
+
echo '\nEnabling the firewall.'
systemctl enable nftables.service
PATH_BORG_CONF_SECURITY="${PATH_BORG_CONF}/security"
PATH_BORG_CONF_KEYS="${PATH_BORG_CONF}/keys"
-location_from_servername() { printf 'ssh://plom@%s/./borg' "$1"; }
+location_from_servername() { printf 'ssh://borg@%s/./borgrepo' "$1"; }
servername_from_location() { echo "$1" | cut -d'/' -f3 | cut -d'@' -f2; }
path_repo_location() { printf '%s' "${PATH_BORG_CONF_SECURITY}/${1}/location"; }
+++ /dev/null
-. lib/abort
-
-expect_n_args() {
- _N_MIN_ARGS="$1"
- _N_MAX_ARGS="$2"
- _USAGE="$3"
- shift 3
- _ABORT_MSG=
- if [ "$#" -lt "${_N_MIN_ARGS}" ]; then
- _ABORT_MSG="missing arguments (got $# instead of ${_N_MAX_ARGS})."
- elif [ "$#" -gt "${_N_MAX_ARGS}" ]; then
- shift "${_N_MAX_ARGS}"
- _ABORT_MSG="unexpected arguments beyond expected number (${_N_MAX_ARGS}): $@"
- fi
- if [ ! -z "${_ABORT_MSG}" ]; then
- if [ ! -z "${_USAGE}" ]; then
- _ABORT_MSG="${_ABORT_MSG}\nExpected arguments: ${_USAGE}"
- fi
- abort "Aborting due to ${_ABORT_MSG}"
- fi
-}
--- /dev/null
+../../../bookworm/scripts/lib/expect_n_args
\ No newline at end of file