#!/bin/sh cd "$(dirname "$0")" . ../lib/bootstrap wrong_call() { cat << EOF run this script as root and with the username of your user account examples: $ sudo $0 loek $ sudo $0 "\$LOGNAME" # $0 gert EOF exit 1 } # this script needs to run with root privileges [ $(id -u) -ne 0 ] && wrong_call # SETUP_USER must exist SETUP_USER="$1" s getent passwd "$SETUP_USER" || wrong_call # SETUP_USER can not be root [ $(id -u "$SETUP_USER") -eq 0 ] && wrong_call begintask "copy system config files" s cp -r etc/. /etc endtask PINENTRY="pinentry-gnome3" [ "$(command -v pinentry | xargs realpath | xargs basename)" != "$PINENTRY" ] && ( begintask "set pinentry program to $PINENTRY" s ln -sf "$PINENTRY" "$(command -v pinentry)" endtask ) begintask "enabling services" s systemctl enable bluetooth ntpd cups endtask GROUPS_OK=1 CURRENT_GROUPS="$(id -Gn "$SETUP_USER")" TARGET_GROUPS="users uucp optical lp audio wheel input" for group in $TARGET_GROUPS ; do if ! echo "$CURRENT_GROUPS" | s grep "$group" ; then GROUPS_OK=0 break fi done [ "$GROUPS_OK" -ne 1 ] && ( begintask "adding $SETUP_USER to groups" s usermod -aG "$(echo "$TARGET_GROUPS" | tr ' ' ',')" "$SETUP_USER" endtask ) PAM_GNUPG_FILE="/etc/pam.d/system-login" ! s grep 'pam_gnupg' "$PAM_GNUPG_FILE" && ( begintask "adding pam-gnupg PAM module" cat << EOF >> "$PAM_GNUPG_FILE" # https://github.com/cruegge/pam-gnupg auth optional pam_gnupg.so store-only session optional pam_gnupg.so EOF endtask ) s grep '^#\s*\' /etc/pacman.conf && ( begintask "enabling color in /etc/pacman.conf" s sed 's/^#\s*\(\\)/\1/g' -i /etc/pacman.conf endtask ) [ "$(getent passwd "$SETUP_USER" | cut -d: -f7 | xargs basename)" != "zsh" ] && ( begintask "set user shell to zsh" s chsh -s "$(command -v zsh)" "$SETUP_USER" endtask ) cat << EOF root bootstrap finished in $(finishtime)! EOF