77 lines
2.0 KiB
Bash
77 lines
2.0 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
PACKAGES=(
|
|
|
|
# system
|
|
base apparmor lvm2 greetd sudo # system
|
|
openssh networkmanager man-db restic htop # admin utils
|
|
|
|
# cli programs
|
|
vifm vim # navigation & editors
|
|
dash shellcheck # shell scripting
|
|
hugo miniserve neomutt # www
|
|
gnupg pass pass-otp # crypt
|
|
git zip # others
|
|
|
|
# desktop env
|
|
sway swaybg xorg-xwayland # basic
|
|
foot bemenu-wayland i3blocks mako libnotify # terminals, ui
|
|
wev wl-clipboard wtype slurp grim # interaction
|
|
ttf-roboto ttf-roboto-mono # fonts
|
|
|
|
# gui apps
|
|
imv mpv gimp # media
|
|
firefox sqlitebrowser qt5-wayland
|
|
|
|
# extensions
|
|
firefox-tridactyl vim-ale vim-fugitive
|
|
|
|
)
|
|
|
|
file_has_line() {
|
|
grep -qxF "$2" "$1" || echo "$2" >> "$1"
|
|
}
|
|
|
|
[ "$(id -u)" != "0" ] && echo "ERROR: root required" >&2 && exit 1
|
|
|
|
pacman -Syu
|
|
pacman -S --needed "${PACKAGES[@]}"
|
|
pacman -S --needed brightnessctl sof-firmware intel-media-driver intel-ucode mesa
|
|
pacman -S --needed libreoffice-still
|
|
|
|
file_has_line "/etc/profile" "umask 002"
|
|
|
|
while read -r entity; do
|
|
# group <name> <id>
|
|
# user <name> <id> [<secondary groups>...]
|
|
read -ra entity_parts <<< "$entity"
|
|
etype="${entity_parts[0]}"
|
|
ename="${entity_parts[1]}"
|
|
eid="${entity_parts[2]}"
|
|
[ "$etype" != "user" ] && [ "$etype" != "group" ] && echo "ERROR: bad entity type" >&2 && exit 1
|
|
|
|
# every user has their own primary group with id matching uid,
|
|
# so for each entry we need a usergroup
|
|
if [ -z "$(getent group "$eid")" ]; then
|
|
echo "Creating group \"$ename\", id=$eid"
|
|
groupadd --gid "$eid" "$ename"
|
|
fi
|
|
if [ "$etype" = "user" ]; then
|
|
if ! id "$eid" >/dev/null 2>&1; then
|
|
echo "Creating user \"$ename\", id=$eid"
|
|
useradd --gid "$eid" --uid "$eid" -m "$ename"
|
|
fi
|
|
usermod -aG "$(IFS=,; echo "${entity_parts[*]:3}")" "$ename"
|
|
else # group
|
|
if [[ "$ename" == share-* ]]; then
|
|
echo "Creating shared dir $ename"
|
|
mkdir -p "/home/$ename"
|
|
chgrp "$ename" -R "/home/$ename"
|
|
chmod u=rwX,g=rwX,o= -R "/home/$ename"
|
|
find "/home/$ename" -type d -print0 | xargs -0 chmod g+s
|
|
|
|
fi
|
|
fi
|
|
done </root/users.conf
|