commit 0dd2ff7012f3672ab5f213f12c8b1db448dc62db
parent ff21a896981f2dc9175c578600490992e2777b83
Author: Markus Hanetzok <markus@hanetzok.net>
Date: Fri, 24 Apr 2026 22:11:23 +0200
improved robustness of script, removed AUR package from prog.list
Diffstat:
2 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/post-install.sh b/post-install.sh
@@ -1,10 +1,8 @@
-#!/bin/sh
+#!/bin/bash
set -e
# variables used in the script
-user="markus"
-hostname="totoro"
tz="Europe/Berlin"
locale="de_DE.UTF-8"
suckless="git://git.hanetzok.net"
@@ -12,99 +10,125 @@ suckless="git://git.hanetzok.net"
### functions
slinstall() {
- echo "Installing $1"
- sudo -u "$user" git clone "$suckless"/"$1" /home/"$user"/src/"$1" > /dev/null
- cd /home/"$user"/src/"$1"
+ (
+ sudo -u "$user" git clone "$suckless/$1" "/home/$user/src/$1"
+ cd "/home/$user/src/$1"
sudo -u "$user" make > /dev/null
make install >/dev/null
+ )
}
-if [ "$EUID" -ne 0 ]
- then echo "Please run as root"
- exit
+if [ "$(id -u)" -ne 0 ]; then
+ echo "Please run as root"
+ exit 1
fi
# enable multilib repo and run system update
-echo "[multilib]" >> /etc/pacman.conf
-echo "Include = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf
+grep -q '\[multilib\]' /etc/pacman.conf || printf '\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n' >> /etc/pacman.conf
pacman -Syu --noconfirm --needed zsh
cp ./progs.list /tmp
-cd /tmp
+
+clear
+read -p "Enter username: " user
+if [[ ! "$user" =~ ^[a-z_][a-z0-9_-]*$ ]]; then
+ echo "Invalid username"; exit 1
+fi
+read -p "Enter hostname: " hostname
+if [[ ! "$hostname" =~ ^[a-zA-Z0-9-]+$ ]]; then
+ echo "Invalid hostname"; exit 1
+fi
+echo "User: $user - Hostname: $hostname"
+
+read -p "Is this correct? [Y/n] " start
+case "$start" in
+ Y | y | yes | Yes | YES) clear;;
+ *) exit 0;;
+esac
echo "!!! Set ROOT password !!!"
passwd
# user creation
-echo "Add user..."
-useradd -m -G wheel -s /usr/bin/zsh $user
-echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers
+echo "Add user $user..."
+useradd -m -G wheel -s /usr/bin/zsh "$user"
echo "Set user password..."
-passwd markus
+passwd "$user"
+
+# sudo
+echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/wheel
+chmod 440 /etc/sudoers.d/wheel
# timezone & locale
echo "Set timezone and locale..."
-echo "$locale UTF-8" >> /etc/locale.gen
+grep -q "$locale UTF-8" /etc/locale.gen || echo "$locale UTF-8" >> /etc/locale.gen
locale-gen > /dev/null
-echo "LANG=$locale" >> /etc/locale.conf
+echo "LANG=$locale" > /etc/locale.conf
ln -sf /usr/share/zoneinfo/"$tz" /etc/localtime
+hwclock --systohc
+
# set hostname
echo "$hostname" > /etc/hostname
# delete comments from progs.list
-sed '/^#/d' progs.list > ./progscleared.list
+[ -f /tmp/progs.list ] || { echo "progs.list not found"; exit 1; }
+sed '/^#/d' /tmp/progs.list > /tmp/progscleared.list
# install packages
echo "Installing packages from the official repos..."
-while IFS=$'\n' read -r prog; do
+while IFS= read -r prog || [ -n "$prog" ]; do
echo "Installing $prog..."
pacman --noconfirm --needed -S "$prog" > /dev/null
-done < ./progscleared.list
+done < /tmp/progscleared.list
-rm ./progscleared.list
+rm /tmp/progscleared.list
# check if yay is already installed
-if ! hash yay
-then
+if ! hash yay 2>/dev/null; then
echo "Download and install yay..."
git clone https://aur.archlinux.org/yay-bin /opt/yay-bin > /dev/null
chown "$user":"$user" -R /opt/yay-bin
cd /opt/yay-bin
- sudo -u "$user" makepkg -si > /dev/null
- cd /tmp
+ sudo -u "$user" makepkg -s --noconfirm > /dev/null
+ sudo pacman -U --noconfirm /opt/yay-bin/*.pkg.tar.* > /dev/null
fi
+cd /tmp
# install GRUB (UEFI)
echo "Install GRUB..."
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB > /dev/null
-grub-mkconfig -o /boot/grub/grub.cfg > /dev/null
# set GRUB theme
echo "Install GRUB theme..."
git clone https://github.com/krypciak/crossgrub /tmp/crossgrub > /dev/null
bash /tmp/crossgrub/install.sh
-echo "GRUB_THEME=/boot/grub/themes/crossgrub/theme.txt" >> /etc/default/grub
+
+grep -q 'GRUB_THEME' /etc/default/grub \
+ && sed -i 's|.*GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/crossgrub/theme.txt|' /etc/default/grub \
+ || echo "GRUB_THEME=/boot/grub/themes/crossgrub/theme.txt" >> /etc/default/grub
+
grub-mkconfig -o /boot/grub/grub.cfg > /dev/null
# set ZDOTDIR in zshenv to keep $HOME clean(er)
-echo 'export ZDOTDIR="$HOME/.config/zsh"' >> /etc/zsh/zshenv
+grep -q 'ZDOTDIR' /etc/zsh/zshenv || echo 'export ZDOTDIR="$HOME/.config/zsh"' >> /etc/zsh/zshenv
# disable hardware speaker bell
-rmmod pcspkr
+rmmod pcspkr 2>/dev/null || true
echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
# dotfiles
echo "Get dotfiles..."
-rm -f /home/$user/.bash*
+find "/home/$user" -maxdepth 1 -name '.bash*' -delete
git clone git://git.hanetzok.net/dotfiles /tmp/dotfiles > /dev/null
-cp -r /tmp/dotfiles/.* /home/$user/
-chown $user:$user -R /home/$user
+find /tmp/dotfiles -mindepth 1 -maxdepth 1 -name '.*' -exec cp -r {} "/home/$user/" \;
+chown "$user":"$user" -R "/home/$user"
# install stuff via git
echo "Install dominant_colours from GitHub (might take a while)..."
git clone "https://github.com/alexwlchan/dominant_colours.git" /tmp/dominant_colours > /dev/null
-chown "$user":"$user" /tmp/dominant_colours && cd /tmp/dominant_colours
+chown -R "$user":"$user" /tmp/dominant_colours
+cd /tmp/dominant_colours
sudo -u "$user" rustup default stable > /dev/null
sudo -u "$user" cargo install --path . > /dev/null
@@ -118,8 +142,10 @@ slinstall slock
# misc
echo "Set options for GNOME keyring..."
-echo "auth optional pam_gnome_keyring.so">> /etc/pam.d/login
-echo "session optional pam_gnome_keyring.so auto_start" >> /etc/pam.d/login
+grep -q 'pam_gnome_keyring' /etc/pam.d/login || {
+ echo "auth optional pam_gnome_keyring.so" >> /etc/pam.d/login
+ echo "session optional pam_gnome_keyring.so auto_start" >> /etc/pam.d/login
+}
echo "Enabling services"
systemctl enable NetworkManager > /dev/null
diff --git a/progs.list b/progs.list
@@ -10,7 +10,6 @@ gnome-keyring
grub
htop
keepassxc
-libgnome-keyring
libnotify
linux-zen-headers
lynx