add firewall rules with a rules handler, setup command fix and rust server

This commit is contained in:
Didier Slof 2022-12-05 09:11:37 +01:00
parent fb7b388c8e
commit 01e4c835b2
Signed by: didier
GPG key ID: 01E71F18AA4398E5
5 changed files with 153 additions and 23 deletions

42
utils/setup-ports.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
run() {
echo "$@"
"$@"
}
up() {
while read -r line; do
[ -z "$line" ] && continue
if [ "$(echo "$line" | cut -c1)" = "#" ]; then
echo "$line"
else
# shellcheck disable=SC2086
run iptables -A $line
fi
done < "$1"
}
down() {
while read -r line; do
[ -z "$line" ] && continue
if [ "$(echo "$line" | cut -c1)" = "#" ]; then
echo "$line"
else
# shellcheck disable=SC2086
run iptables -D $line
fi
done < "$1"
}
case "$1" in
up)
up "$2"
;;
down)
down "$2"
;;
*)
echo "Usage: $0 {up|down}"
exit 1
esac