summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
blob: 92ff218623aa3023f45c28a0964b34f628b1362b (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
#!/bin/bash
############################################
# Feature: Setup firewall rules for the VM #
############################################
## Functions
setup_firewall () {
	local LOGF="${TMPDIR}/firewall.log"
	local RET
	[ "$DISPLAY" = ":0" ] || return 0 # For now, to avoid conflicts, we only do this on display :0
	slxfwtool "$IMGUUID" > "$LOGF" 2>&1
	RET=$?
	if [ "$RET" != "0" ]; then
		slxlog "virt-firewall" "Error setting up firewall rules for lecture $IMGUUID (Exit code $RET)" "$LOGF"
		return 1
	fi
	return 0
}

## MAIN ##
# Sanity checks
if check_dep slxfwtool; then
	reg_feature_handler "firewall" "setup_firewall"
else
	writelog "Could not find 'slxfwtool' in PATH: $PATH. Netrules firewall will not work!"
	error_user "Fehler" "Keine Unterstützung von veranstaltungspezifische Firewall-Regeln!"
	# TODO handle
fi