umorpha-boxes/modules/umorpha-sshusers.sh

53 lines
1.8 KiB
Bash
Raw Normal View History

2023-10-28 20:37:09 +00:00
#!/hint/bash -euE
# Copyright (C) 2018 Luke Shumaker
# Copyright (C) 2023 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
2023-10-31 07:43:40 +00:00
load_module "$(dirname -- "${BASH_SOURCE[0]}")/base-sshd.sh"
2023-10-28 22:12:25 +00:00
2023-10-31 07:43:40 +00:00
packages+=(
# Functionality
sudo
# Experience
less
bash-completion
rxvt-unicode-terminfo
2023-11-01 19:31:01 +00:00
man-db
2023-10-31 07:43:40 +00:00
)
post_install+=(
01:umorpha-sshusers:early
99:umorpha-sshusers:late
)
umorpha-sshusers:early() {
2023-10-28 20:37:09 +00:00
local arg_mountpoint=$1
2023-10-31 07:43:40 +00:00
echo en_US.UTF-8 UTF-8 >"${arg_mountpoint}/etc/locale.gen"
arch-chroot -- "$arg_mountpoint" locale-gen
cat >"${arg_mountpoint}/etc/locale.conf" <<-EOF
LANG=en_US.UTF-8
LC_COLLATE=C
EOF
2023-10-28 20:37:09 +00:00
echo '%wheel ALL=(ALL) ALL' >"$arg_mountpoint/etc/sudoers.d/00-wheel"
useradd --root="$arg_mountpoint" --gid=users --comment='Luke T. Shumaker' --create-home lukeshu
passwd --root="$arg_mountpoint" --delete --expire lukeshu
gpasswd --root="$arg_mountpoint" --add=lukeshu wheel
mkdir "$arg_mountpoint/home/lukeshu/.ssh"
echo >"$arg_mountpoint/home/lukeshu/.ssh/authorized_keys" 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDIOENnrA4fx+1DZE0oTpX84Rncc0yYKtUXM+1WIa+jHB4L0d5dCnvKshD5yi3G4TT5PhUSM+S/8zrnt9Ytug75Y3BRqG6ZIAeWc662X2z97ExDJZlV5KW7C1dVzMjM/EVyRV2ey0AqiaW/71lOkVw/AR2crggV2YfA24ecDN5tHVJGoxdi6isQyD2w0w1PnMWiXQR9aQ2kp9qv4MdW8sEYMmVSi3i5CNOQdYc+YIXsYfUSDiQ1YYVdvtHE7HprX86SCtqZCETKiYXxY0rtvJ+uI9aPmSpdEEo34EgwFtuYr+9sIfEhjL9+Hy/5+6HuksSpEY61UamiLUJhD7c1lZUpo93+oxHhRSzTvdTVoTRbZCu2iAmOJRhcqpLmhuHz2JesD73I+RmatTXGPaCkMex12QqGPvmhArxg8Btkd9ZiXFJZJgn11GiHBVTiAlf27pKXy0k2Il3iS+gcU7yndgoMI45WLh/vSHveHJ3IMEc1cZmBE70e8D3yp16cusn9bZ8= lukeshu@lukeshu-thinkpad-e15'
}
2023-10-31 07:43:40 +00:00
umorpha-sshusers:late() {
2023-10-28 20:37:09 +00:00
local arg_mountpoint=$1
local user uidgid
for user in lukeshu; do
uidgid=$(awk -v FS=: -v OFS=: "\$1 == "$user" { print \$3, \$4 }" <"$arg_mountpoint/etc/passwd")
chown -R -- "$uidgid" "$arg_mountpoint/home/$user"
done
}