-
Notifications
You must be signed in to change notification settings - Fork 0
/
units.zsh
executable file
·71 lines (56 loc) · 1.6 KB
/
units.zsh
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
#!/usr/bin/env zsh
set -e
set -u
enabled=()
disabled=()
command -v systemctl >/dev/null 2>&1 || exit 0
enabled+=('lightdm')
enabled+=('numlock')
enabled+=('cups')
enabled+=('sshd')
enabled+=('systemd-resolved')
enabled+=('nftables')
enabled+=('bluetooth')
enabled+=('paccache.timer')
if [[ -e /etc/ddclient/ddclient.conf ]]; then
enabled+=('ddclient')
fi
if [[ -e /etc/samba/smb.conf ]]; then
enabled+=('smbd')
fi
if [[ -e /etc/nginx/nginx.conf ]]; then
enabled+=('nginx')
fi
if (pacman -Q bumblebee &>/dev/null); then
enabled+=('bumblebeed')
fi
if (pacman -Q linux-samus4 &>/dev/null); then
enabled+=('chromeos-kbd_backlight')
fi
if (pacman -Q open-vm-tools &>/dev/null); then
enabled+=('vmtoolsd')
fi
if [[ $(hostname) == 'Sleipnir' || $(hostname) == 'Mimir' || $(hostname) == 'Fenrir' ]]; then
enabled+=('systemd-networkd')
elif [[ $(hostname) == 'Freyja' ]]; then
enabled+=('dhcpcd')
elif [[ $(hostname) == 'Gungnir' ]]; then
enabled+=('iwd')
elif [[ $(hostname) == 'Mjolnir' && $(pacman -Q netctl &>/dev/null) ]]; then
enabled+=('systemd-resolved-resume')
enabled+=("netctl-auto@$(ls /sys/class/net | grep ^w | head -1)")
enabled+=("netctl-auto-resume@$(ls /sys/class/net | grep ^e | head -1)")
fi
for unit in $enabled; do
echo "[Enable] $unit"
sudo -S systemctl enable $unit
done
for unit in $disabled; do
echo "[Disable] $unit"
sudo -S systemctl disable $unit
done
# TODO This will fail under initial arch-chroot.
# Ignore for now and run it after first boot.
sudo -S ln -s -f /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo chattr +i "$(realpath /etc/resolv.conf)"
exit