102 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			2.9 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 strace sysstat htop screen man-db which # system 
 | |
| 
 | |
| 	nodejs dash jq # runtime
 | |
| 	qemu-system-x86 # virt
 | |
| 
 | |
| 	rlwrap fzf # shell helpers
 | |
| 	vifm vim less # nav & edit
 | |
| 	vim-ale vim-fugitive # vim plugins
 | |
| 
 | |
| 	just shellcheck # shell scripting
 | |
| 	git zip # data processing
 | |
| 	gnupg pass pass-otp pwgen # crypt
 | |
| 	imv mpv imagemagick gimp # media
 | |
| 	aichat libqalculate translate-shell  # utils	
 | |
| 	libreoffice-still  # docs
 | |
| 
 | |
| 	qutebrowser qt6-wayland # web browsing
 | |
| 	hugo miniserve # web utils
 | |
| 	neomutt telegram-desktop # communication
 | |
| 	
 | |
| 	greetd sway swaybg swayidle # desktop basic
 | |
| 	alacritty wmenu i3blocks mako libnotify # terminals, ui
 | |
| 	wev wl-clipboard wtype slurp grim # interaction
 | |
| 	ttf-roboto ttf-roboto-mono otf-font-awesome # fonts
 | |
| 	kvantum kvantum-qt5 kvantum-theme-materia materia-gtk-theme # themes
 | |
| 
 | |
| )
 | |
| 
 | |
| 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 $etype" >&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
 |