sbc-images/includes/post/user-setup.ksi

44 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-09-13 01:29:56 +00:00
%post
set -x
# The official kickstart docs has a 'user' command, but using it somehow
# causes 'systemd-logind.service' to fail during boot and you are essentially
# locked out even when you enter the correct credentials
# User setup
USER_COMMENT='Pratham Patel'
USER_NAME='pratham'
USER_PASSWORD='asdf'
USER_GROUPS='mock,wheel'
2023-09-13 01:29:56 +00:00
# The 'useradd' binary can't be found in $PATH (idk why), so
# execute it using its absolute path
/sbin/useradd \
--uid 1000 \
--create-home \
--comment "${USER_COMMENT}" \
--user-group "${USER_NAME}" \
--groups "${USER_GROUPS}"
echo -e "${USER_PASSWORD}\n${USER_PASSWORD}" | passwd "${USER_NAME}"
sed -i "s/# %wheel\tALL=(ALL)\tNOPASSWD: ALL/%wheel\tALL=(ALL)\tNOPASSWD: ALL/" /etc/sudoers
2023-09-13 01:29:56 +00:00
2023-11-20 11:54:06 +00:00
# dotfiles
2023-11-20 12:28:25 +00:00
cat << EOF > get-dotfiles.sh
#!/usr/bin/env bash
set -x
2024-04-28 12:58:51 +00:00
HOME='/home/pratham'
[[ -d "$HOME" ]] || exit 1
2023-11-20 12:28:25 +00:00
git clone --bare https://gitlab.com/thefossguy/dotfiles.git "${HOME}/.dotfiles"
git --git-dir="${HOME}/.dotfiles" --work-tree="${HOME}" checkout -f
rm -rf "${HOME}/.config/nvim"
EOF
chmod +x get-dotfiles.sh
2023-11-20 12:57:39 +00:00
sudo -i -u "${USER_NAME}" bash "$PWD/get-dotfiles.sh"
2023-11-20 12:28:25 +00:00
rm -vf get-dotfiles.sh
2023-11-20 11:54:06 +00:00
2023-09-13 01:29:56 +00:00
# Lock the root account
passwd -l root
%end