summaryrefslogtreecommitdiffstats
path: root/core/modules/safe-mode/data/opt/openslx/scripts/systemd-safe_mode
blob: d88d2a3a3be59a7a4d62f228377f7a274694127f (plain) (blame)
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
#!/bin/ash

disable_tty_switch() {
	cat > /etc/X11/xorg.conf.d/50-no-tty.conf <<EOF
Section "ServerFlags"
	Option "DontVTSwitch" "true"
EndSection
EOF
}

disable_openbox_menu() {
	[ ! -e "/etc/xdg/openbox/rc.xml.safe" ] && \
		echo "No rc.xml.safe template found." && return 1
	cp "/etc/xdg/openbox/rc.xml" "/root/rc.xml.unsafe"
	cp "/etc/xdg/openbox/rc.xml.safe" "/etc/xdg/openbox/rc.xml"
}

disable_magic_keys() {
	echo 0 > /proc/sys/kernel/sysrq
}

change_loginscreen() {
	mkdir -p "/etc/lightdm/qt-lightdm-greeter.conf.d"
	cat > "/etc/lightdm/qt-lightdm-greeter.conf.d/99-exam-mode.conf" <<EOF
[General]
greeter-background-gradient = FFB22C FFB22C
greeter-background-image =
EOF
	/opt/openslx/scripts/lightdm-patch_logo "Prüfungsmodus" '#888687'
}

systemd_config() {
	# Disable ctrl-alt-delete
	systemctl mask --no-block ctrl-alt-del.target
	# No idleaction
	rm -- "/etc/cron.d/openslx-idleaction"
	# Ignore everything but power button, no VTs
	mkdir -p "/etc/systemd/logind.conf.d"
	cat > "/etc/systemd/logind.conf.d/99-exam.conf" <<EOF
[Login]
NAutoVTs=0
ReserveVT=0
KillUserProcesses=no
HandlePowerKey=poweroff
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
IdleAction=ignore
EOF
	# reload
	timeout 2 systemctl daemon-reload
	timeout 3 systemctl try-restart systemd-logind
	systemctl --no-block stop getty@tty1 # Since this is hard-linked
}

ssh_banner() {
	# Visual: ssh banner
	echo "+ - - -  PRÜFUNGSMODUS  AKTIV  - - - +" >> "/etc/issue.net"
	echo "++++++++++++++++++++++++++++++++++++++" >> "/etc/issue.net"
}

disable_tty_switch
disable_openbox_menu
disable_magic_keys
change_loginscreen
systemd_config
ssh_banner

exit 0