install-common.sh 1.54 KB
Newer Older
1
2
3
4
5
#!/bin/bash

set -e
set -x

6
7
8
9
10
11
# Setup pacman-init.service for clean pacman keyring initialization
cat <<EOF >/etc/systemd/system/pacman-init.service
[Unit]
Description=Initializes Pacman keyring
Wants=haveged.service
After=haveged.service
12
Before=sshd.service cloud-final.service
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ConditionFirstBoot=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/pacman-key --init
ExecStart=/usr/bin/pacman-key --populate archlinux

[Install]
WantedBy=multi-user.target
EOF

# Add service for running reflector on first boot
cat <<EOF >/etc/systemd/system/reflector-init.service
[Unit]
Description=Initializes mirrors for the VM
After=network-online.target
Wants=network-online.target
31
Before=sshd.service cloud-final.service
32
33
34
35
36
ConditionFirstBoot=yes

[Service]
Type=oneshot
RemainAfterExit=yes
David Runge's avatar
David Runge committed
37
ExecStart=reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
38
39
40
41
42

[Install]
WantedBy=multi-user.target
EOF

43
44
45
46
47
# enabling important services
systemctl enable sshd
systemctl enable haveged
systemctl enable systemd-networkd
systemctl enable systemd-resolved
48
systemctl enable systemd-timesyncd
49
50
systemctl enable pacman-init.service
systemctl enable reflector-init.service
51

52
sed -i 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' /etc/default/grub
53
# setup unpredictable kernel names
54
sed -i 's/^GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="net.ifnames=0"/' /etc/default/grub
55
sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"rootflags=compress-force=zstd\"/' /etc/default/grub
56
57
58
59
60
grub-mkconfig -o /boot/grub/grub.cfg

if declare -f post >/dev/null; then
  post
fi