
Starting libvirtd.service provides iptable rules for NATed network virbr0. When starting firewalld.service after libvirtd, these rules will be overwritten. So NAT will no longer work. Restart of libvirtd fixes the rules again.
16 lines
505 B
Bash
16 lines
505 B
Bash
#!/usr/bin/bash
|
|
|
|
# exit if not running as root. Because other user don't have privileges to start/stop firewalld.
|
|
[[ "${UID}" -eq "0" ]] || exit 0
|
|
|
|
if [[ "${PAM_USER}" =~ -exam$ ]]; then
|
|
systemctl start firewalld.service
|
|
if systemctl is-enabled --quiet libvirtd.service; then
|
|
systemctl restart libvirtd.service
|
|
fi
|
|
elif ! (users | grep -q -- "-exam"); then
|
|
systemctl stop firewalld.service
|
|
if systemctl is-enabled --quiet libvirtd.service; then
|
|
systemctl restart libvirtd.service
|
|
fi
|
|
fi
|