This repository has been archived on 2023-05-02. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neo/utils/setup-ports.sh

42 lines
No EOL
617 B
Bash
Executable file

#!/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