summaryrefslogtreecommitdiff
path: root/kvmd.install
blob: 73f9440a3a09abe3e42b9cd6e2452a93d246f9da (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
post_install() {
	post_upgrade
}

post_upgrade() {
	echo "==> Ensuring KVMD users and groups ..."
	systemd-sysusers /usr/lib/sysusers.d/kvmd.conf

	# https://github.com/systemd/systemd/issues/13522
	usermod --expiredate= kvmd >/dev/null

	chown kvmd:kvmd /etc/kvmd/htpasswd
	chown kvmd-ipmi:kvmd-ipmi /etc/kvmd/ipmipasswd
	chown kvmd-vnc:kvmd-vnc /etc/kvmd/vncpasswd
	chmod 600 /etc/kvmd/*passwd

	chown kvmd /var/lib/kvmd/msd || true

	if [ ! -d /etc/kvmd/nginx/ssl/server.crt ]; then
		echo "==> Generating KVMD-Nginx certificate ..."
		kvmd-gencert --do-the-thing
	fi

	if [ ! -d /etc/kvmd/vnc/ssl/server.crt ]; then
		echo "==> Generating KVMD-VNC certificate ..."
		kvmd-gencert --do-the-thing --vnc
	fi

	for target in nginx vnc; do
		chown root:root /etc/kvmd/$target/ssl
		chown root:kvmd-$target /etc/kvmd/$target/ssl/*
		chmod 440 /etc/kvmd/$target/ssl/server.key
		chmod 444 /etc/kvmd/$target/ssl/server.crt
	done

	echo "==> Patching configs ..."
	[ ! -f /boot/config.txt ] || sed -i -e 's/^dtoverlay=pi3-disable-bt$/dtoverlay=disable-bt/g' /boot/config.txt
	[ ! -f /boot/config.txt ] || sed -i -e 's/^dtoverlay=dwc2$/dtoverlay=dwc2,dr_mode=peripheral/g' /boot/config.txt
}