Initial Commit
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
stop() {
|
||||
# Flush iptables (Code from archlinux)
|
||||
iptables=ip$1tables
|
||||
if ! type -p "$iptables" &>/dev/null; then
|
||||
echo "error: invalid argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while read -r table; do
|
||||
tables+=("/usr/share/iptables/empty-$table.rules")
|
||||
done <"/proc/net/ip$1_tables_names"
|
||||
|
||||
if (( ${#tables[*]} )); then
|
||||
cat "${tables[@]}" | "$iptables-restore"
|
||||
fi
|
||||
|
||||
# Clear the trap
|
||||
trap - SIGINT SIGTERM
|
||||
kill -- -$(pgrep iptables.sh)
|
||||
}
|
||||
|
||||
/usr/sbin/iptables-restore /etc/iptables/iptables.rules
|
||||
|
||||
# Run stop function when SIGINT or SIGTERM signals are caught
|
||||
trap "stop $1" SIGINT SIGTERM
|
||||
sleep infinity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user