blob: b24447122e879fec40b6980d031ec741738a87ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/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*\<Color\>' /etc/pacman.conf && (
begintask "enabling color in /etc/pacman.conf"
s sed 's/^#\s*\(\<Color\>\)/\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
|