Files
IPTables-Management/lib/persist.sh

26 lines
734 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
if [[ -n ${IPF_PERSIST_SH_LOADED:-} ]]; then
return 0
fi
IPF_PERSIST_SH_LOADED=1
: "${NETFILTER_PERSISTENT_BIN:=netfilter-persistent}"
: "${IPF_SKIP_PERSIST:=0}"
persist_available() {
[[ ${IPF_SKIP_PERSIST} == 1 ]] || command_is_available "${NETFILTER_PERSISTENT_BIN}"
}
persist_save() {
[[ ${IPF_SKIP_PERSIST} == 1 ]] && return 0
persist_available || { log_err '未找到 netfilter-persistent无法保存规则。'; return 1; }
"${NETFILTER_PERSISTENT_BIN}" save >/dev/null
}
persist_reload() {
[[ ${IPF_SKIP_PERSIST} == 1 ]] && return 0
persist_available || { log_err '未找到 netfilter-persistent无法重载规则。'; return 1; }
"${NETFILTER_PERSISTENT_BIN}" reload >/dev/null
}