2020-08-31 18:22:33 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
|
|
if [[ ${EUID} -ne 0 ]]; then
|
|
|
|
|
echo "This script should be run as root." > /dev/stderr
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $# == 1 && "$1" == "--check" ]]; then
|
|
|
|
|
echo "OK"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
ipset flush cloudron_blocklist
|
|
|
|
|
|
2020-09-14 10:29:48 -07:00
|
|
|
user_firewall_json="/home/yellowtent/boxdata/firewall/blocklist.txt"
|
2020-08-31 18:22:33 -07:00
|
|
|
|
2020-09-14 10:29:48 -07:00
|
|
|
if [[ -f "${user_firewall_json}" ]]; then
|
|
|
|
|
while read -r line; do
|
|
|
|
|
[[ -z "${line}" ]] && continue # ignore empty lines
|
|
|
|
|
[[ "$line" =~ ^#.*$ ]] && continue # ignore lines starting with #
|
|
|
|
|
ipset add cloudron_blocklist "${line}"
|
|
|
|
|
done < "${user_firewall_json}"
|
2020-08-31 18:22:33 -07:00
|
|
|
fi
|