2
0
Fork 0
main
Ducky 2023-08-13 02:17:17 +01:00
parent 11e45a59d1
commit ef4d41d315
3 changed files with 30 additions and 0 deletions

6
.gitignore vendored
View File

@ -42,5 +42,11 @@
!/usr/local/bin/
/usr/local/bin/*
!/usr/local/bin/zio-backup
!/usr/local/bin/zio-libvirt-port-forward
!/usr/local/bin/zio-update-caddy
!/usr/local/bin/zio-update-rootfs
# /usr/local/libexec/
!/usr/local/libexec/
/usr/local/libexec/*
!/usr/local/libexec/zio-helpers

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
if [[ "$(realpath "$(dirname "$(realpath -s "$0")")/../../../")" == "/" ]]; then
. /usr/local/libexec/zio-helpers
else
. "$(dirname "$(realpath -s "$0")")/../libexec/zio-helpers"
fi
vm_state="$1"
vm_ip="$2"
vm_port="$3"
vm_proto="$4"
host_port="$5"
if [ $vm_state == "stopped" ] || [ $vm_state == "reconnect" ]; then
iptables -D FORWARD -o virbr0 -p $vm_proto -d $vm_ip --dport $vm_port -j ACCEPT
iptables -t nat -D PREROUTING -p $vm_proto --dport $host_port -j DNAT --to $vm_ip:$vm_port
fi
if [ $vm_state == "start" ] || [ $vm_state == "reconnect" ]; then
iptables -I FORWARD -o virbr0 -p $vm_proto -d $vm_ip --dport $vm_port -j ACCEPT
iptables -t nat -I PREROUTING -p $vm_proto --dport $host_port -j DNAT --to $vm_ip:$vm_port
fi

View File

@ -0,0 +1 @@
#!/usr/bin/env bash