summaryrefslogtreecommitdiff
path: root/scripts/setup-config-alpine
blob: 23cb6a8625b65b15a6e77370e87d3d418a13ec87 (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh

# Set up my configuration on a new Alpine Linux installation.

print_log() {
	printf '\n>>> %s \n\n' "$@"
}

set -e  # Abort on first error


print_log "Installing git and cloning the config repo"

doas apk add git
cd ~
git init .
git remote add origin https://git.tronto.net/config
git fetch && git checkout -f master
git remote set-url origin git@tronto.net:config
git remote set-url origin --add --push git@github.com:sebastianotronto/config


print_log "Installing software from alpine repositories"

tmp_repo_file=$(mktemp)
main_repo="$(grep main /etc/apk/repositories)"
community_repo="$(echo "$main_repo" | sed 's/main/community/')"
printf '%s\n%s\n' "$main_repo" "$community_repo" > "$tmp_repo_file"
doas mv "$tmp_repo_file" /etc/apk/repositories

./scripts/apkworld


print_log "Installing and configuring desktop environment"

doas setup-xorg-base

mkdir -p src
cd src
for i in dmenu dwm st; do
	git clone https://git.suckless.org/$i
	cd $i
	cp ~/.config/$i/config.h ./config.h
	make && doas make install
	cd ..
done
cd

tmp_xorg_file=$(mktemp)
cat <<EOF > "$tmp_xorg_file"
Section "InputClass"
	Identifier "libinput touchpad catchall"
	MatchIsTouchpad "on"
	MatchDevicePath "/dev/input/event*"
	Driver "libinput"
	Option "Tapping" "on"
EndSection
EOF

doas mkdir -p /etc/X11/xorg.conf.d
doas mv "$tmp_xorg_file" /etc/X11/xorg.conf.d/40-libinput.conf

tmp_doas_file=$(mktemp)
cp /etc/doas.d/20-wheel.conf "$tmp_doas_file"
for c in poweroff reboot; do
	printf 'permit nopass :wheel as root cmd %s\n' "$c" >> "$tmp_doas_file"
done
doas cp "$tmp_doas_file" /etc/doas.d/20-wheel.conf


print_log "Configuring the console"

tmp_kmap_file=$(mktemp)
tmp_loadkmap_file=$(mktemp)
printf 'keycode 1 = Caps_Lock\nkeycode 58 = Escape\n' > "$tmp_kmap_file"
doas loadkeys "$tmp_kmap_file"
dumpkmap > us-swapesc.bmap
gzip us-swapesc.bmap
doas mv us-swapesc.bmap.gz /etc/keymap/
printf 'KEYMAP=/etc/keymap/us-swapesc.bmap.gz\n' > "$tmp_loadkmap_file"
doas mv "$tmp_loadkmap_file" /etc/conf.d/loadkmap

tmp_blacklist_file=$(mktemp)
cp /etc/modprobe.d/blacklist.conf "$tmp_blacklist_file"
printf '\n# Disable PC speaker for real\nblacklist pcspkr\n' >> "$tmp_blacklist_file"
doas cp "$tmp_blacklist_file" /etc/modprobe.d/blacklist.conf


print_log "Setting up ACPI (see https://wiki.alpinelinux.org/wiki/Power_management)"

tmp_acpi_file=$(mktemp)
printf '#!/bin/sh\necho mem > /sys/power/state\n' > "$tmp_acpi_file"

for dir in LID PWRF; do
	doas mkdir -p /etc/acpi/$dir
	doas cp "$tmp_acpi_file" /etc/acpi/$dir/00000080
	doas chmod +x /etc/acpi/$dir/00000080
done

doas rc-update add acpid


print_log "Setting up WiFi (iwd) (see https://wiki.alpinelinux.org/wiki/Iwd)"

tmp_iwd_file=$(mktemp)
cat <<EOF > "$tmp_iwd_file"
[General]
EnableNetworkConfiguration=True

[Network]
NameResolvingService=resolvconf
EOF

doas mv "$tmp_iwd_file" /etc/iwd/main.conf

doas rc-update add iwd boot
doas rc-update del networking boot
doas rc-service --ifstarted wpa_supplicant stop
doas rc-service iwd start


print_log "Setting up bluetooth (see https://wiki.alpinelinux.org/wiki/Bluetooth)"

doas modprobe btusb
doas adduser sebastiano lp
doas rc-update add bluetooth
doas rc-service bluetooth start


print_log "Setting up SyncThing"

tmp_syncthing_file=$(mktemp)
doas print 'SYNCTHING_USER="sebastiano"\n' > "$tmp_syncthing_file"
mv "$tmp_syncthing_file" /etc/conf.d/syncthing
doas rc-update add syncthing
doas rc-service start syncthing


print_log "Generating SSH keys"

ssh-keygen


echo ""
echo "All done!"
echo ""
echo "You should log out and back in to apply some of the changes."
echo "Additionally, you may want to perform the following manual steps:"
echo "   1. Connect to WiFi again. The default network manager has been"
echo "      replaced by iwd."
echo "   2. Add your SSH key to various servers, namely:"
echo "      1a. Artemisia"
echo "      1b. pizoc (both regular user and git)"
echo "      1c. github"
echo "      1d. lampone"
echo "   3. Share folders in SyncThing, including but not limited to:"
echo "      2a. box with Artemisia, pizoc and phone"
echo "      2b. file-drop with phone"
echo "   4. Copy your mailbox.org password to .ssh/mailbox.org."
echo "   5. Log into Firefox account and set up extensions, if needed."
echo ""
echo "Enjoy!"

Generated with cgit - Back to sebastiano.tronto.net