workspace/arch-root/install.sh

101 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
set -e
cd "$(dirname "$(readlink -f -- "$0")")/_install"
PACKAGES=(
linux base linux-firmware lvm2 sudo polkit # base
pulseaudio pulseaudio-bluetooth bluez bluez-utils networkmanager udisks2 # device management
openssh man-db htop # admin utils
nodejs dash jq # runtime
qemu-system-x86 # virt
vifm vim less # nav & edit
vim-ale vim-fugitive # vim plugins
just shellcheck # shell scripting
git zip # data processing
gnupg pass pass-otp # crypt
imv mpv imagemagick gimp # media
libqalculate translate-shell # utils
sqlitebrowser qt5-wayland # db
libreoffice-still # docs
qutebrowser qt6-wayland # web browsing
hugo miniserve # web utils
neomutt telegram-desktop # communication
greetd sway swaybg swayidle # desktop basic
foot bemenu-wayland i3blocks mako libnotify # terminals, ui
wev wl-clipboard wtype slurp grim # interaction
ttf-roboto ttf-roboto-mono ttf-font-awesome # fonts
)
install() {
pacman -S --needed --noconfirm "$@"
}
file_has_line() {
grep -qxF "$2" "$1" || echo "$2" >> "$1"
}
cp_chown() {
cp -rf "$1" "$2"
chown "$3" "$2" -R
chmod "$4" "$2" -R
}
[ "$(id -u)" != "0" ] && echo "ERROR: root required" >&2 && exit 1
pacman -Syu --noconfirm
install "${PACKAGES[@]}"
file_has_line "/etc/profile" "umask 002"
find /etc/pam.d -type f -exec sed -i -e 's/^session optional pam_umask.so$/session optional pam_umask.so usergroups/g' {} \;
# device management
sed -i 's/#AutoEnable=true/AutoEnable=false/' /etc/bluetooth/main.conf
systemctl enable bluetooth --now
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
cp_chown greetd.toml /etc/greetd/config.toml root:root 644
custom_script="./custom/$(cat /etc/hostname).sh"
if [ -f "$custom_script" ]; then
echo "Executing host-specific $custom_script"
# shellcheck disable=SC1090
source "$custom_script"
fi