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

35 lines
1.1 KiB
Plaintext

%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'
# 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
# dotfiles
sudo -i -u "${USER_NAME}" git clone --bare https://gitlab.com/thefossguy/dotfiles.git "/home/${USER_NAME}/.dotfiles"
sudo -i -u "${USER_NAME}" git --git-dir="/home/${USER_NAME}/.dotfiles" --work-tree="/home/${USER_NAME}" checkout -f
rm -rf "/home/${USER_NAME}/.config/nvim"
# Lock the root account
passwd -l root
%end