-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost.sh
112 lines (83 loc) · 2.93 KB
/
post.sh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env sh
set -eu
# configure services, network, graphical environment, git credentials in the
# newly installed OS.
if [ "$(whoami)" = root ]; then
echo "This script is not to be run as root!"
exit
fi
systemctl status NetworkManager.service | grep running || {
sudo systemctl start NetworkManager.service
sudo systemctl enable NetworkManager.service
}
ping -c 1 archlinux.org || sudo nmtui
# replace the mirrors from reflector since they're not very good
country=$(curl -sL "https://ipinfo.io" | jq -r .country)
curl -s "https://archlinux.org/mirrorlist/?country=$country&protocol=https&ip_version=4&ip_version=6" |
sed -r 's|^#Server|Server|' |
sudo tee /etc/pacman.d/mirrorlist
sudo pacman -Syu
# https://www.davidtsadler.com/posts/installing-st-dmenu-and-dwm-in-arch-linux/
sudo pacman -S base-devel libx11 libxft xorg-server xorg-xinit terminus-font libxinerama kitty ranger firefox chromium
setup_git_ssh() { # {{{
# without ssh, you cannot clone -any- repo. but with ssh, you can clone
# public and private repos.
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account
# https://cli.github.com/manual/gh_auth_login
if [ ! -f ~/.ssh/gh_hejops ]; then
mkdir -p ~/.ssh
ssh-keygen -f ~/.ssh/gh_hejops -t ed25519 -C "[email protected]"
fi
{
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/gh_hejops
} > /dev/null 2> /dev/null
# https://cli.github.com/manual/gh_auth_login
if [ ! -d ~/.config/gh ]; then
chromium --incognito &
gh auth login
fi
MACHINE="$(cat /sys/devices/virtual/dmi/id/product_name)"
if ! gh ssh-key list | grep -q "$MACHINE"; then
gh auth refresh -h github.com -s admin:public_key
gh auth refresh -h github.com -s admin:ssh_signing_key
gh ssh-key add ~/.ssh/gh_hejops.pub --title "${MACHINE}_$(date -I)"
fi
} # }}}
setup_git_ssh
cd
git clone https://github.com/hejops/dwm
cd dwm
make clean
sudo make install
cat << EOF > "$HOME/.xinitrc"
# vim: ft=sh
# auto-generated by $(basename "$0")
setxkbmap -layout us -option -option compose:rctrl #,caps:menu
xrdb -merge ~/.Xresources
source ~/.bashrc
if [[ -z \$SSH_AUTH_SOCK ]]; then
{
pkill ssh-agent
eval "\$(ssh-agent -s)"
# TODO: find | grep -v .pub
ssh-add "\$HOME/.ssh/github_2024-06-17"
} > /dev/null 2> /dev/null
fi
exec dwm
EOF
# https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login
# https://unix.stackexchange.com/a/521049
# apparently, .bash_profile is tried by default, while .profile is totally ignored
# why does this EOF have single quotes? i honestly forgot
cat << 'EOF' > "$HOME/.bash_profile"
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
exec startx
fi
EOF
cat << EOF
Successfully configured dwm
dwm will be started automatically after logging back in
EOF
# pkill bash