base-image/scripts/add_deploy_user.sh

13 lines
424 B
Bash
Raw Normal View History

2022-12-16 02:45:20 +00:00
#!/usr/bin/env bash
set -eux
readonly USERNAME="deploy"
arch-chroot /mnt useradd --create-home --user-group $USERNAME
arch-chroot /mnt bash -c "echo $USERNAME:$USERNAME | chpasswd"
arch-chroot /mnt mkdir -p /etc/sudoers.d
arch-chroot /mnt touch /etc/sudoers.d/99_$USERNAME
arch-chroot /mnt chmod 0440 /etc/sudoers.d/99_$USERNAME
arch-chroot /mnt echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /mnt/etc/sudoers.d/99_$USERNAME