This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/os/linux/arch/provision.d/00-add-user.bash

33 lines
692 B
Bash
Raw Normal View History

2020-11-07 22:23:52 -06:00
#!/usr/bin/env bash
u=daniel
ud="/home/$u"
# user exists - we will assume setup has already run
if getent passwd "$u"; then exit 0; fi
2021-03-25 09:04:51 -05:00
pacman -S --needed --noconfirm sudo fish git
2020-11-07 22:23:52 -06:00
groupadd admin 2>/dev/null
2021-03-25 09:04:51 -05:00
echo '%admin ALL=(ALL) ALL' >> /etc/sudoers.d/admin-group-sudoers
2020-11-07 22:23:52 -06:00
mkdir --parents "$ud/.home" "$ud/dl"
useradd --home-dir "$ud/.home" \
--groups "admin,users,uucp,lock" \
2020-11-07 22:23:52 -06:00
--shell "/bin/bash" \
"$u"
chown --recursive "$u:$u" "$ud"
2021-03-25 09:04:51 -05:00
chsh --shell /bin/fish
2020-11-07 22:23:52 -06:00
echo "Setting password for user '$u'"
# enforce that a password is set
# we need one for sudo commands in later scripts
while true; do
passwd "$u"
ee=$!
echo $ee
if [ "$ee" -eq 0 ]; then
break
fi
sleep 2
done
echo $!