2018-07-02 20:49:55 +00:00
|
|
|
initscript="$__type/files/nftables-init"
|
|
|
|
|
2019-09-29 13:26:21 +00:00
|
|
|
os=$(cat $__global/explorer/os)
|
|
|
|
|
|
|
|
conf=/etc/firewall.nft
|
|
|
|
|
2018-07-08 19:09:54 +00:00
|
|
|
if [ -f "$__object/parameter/config-from-stdin" ]; then
|
2018-07-08 19:02:03 +00:00
|
|
|
srcfile="$__object/stdin"
|
|
|
|
else
|
|
|
|
if [ ! -f "$__object/parameter/config" ]; then
|
|
|
|
echo "Need either config-from-stdin or config" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-08 19:08:28 +00:00
|
|
|
config=$(cat "$__object/parameter/config")
|
2018-07-08 19:02:03 +00:00
|
|
|
srcfile="$__files/nftables/${config}.conf"
|
|
|
|
|
|
|
|
if [ ! -f "$srcfile" ]; then
|
|
|
|
echo "No such config ${config}. Aborting." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-02 20:49:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
__package nftables
|
2019-09-29 17:30:33 +00:00
|
|
|
__file ${conf} --source "$srcfile" --mode 0644
|
2018-07-02 20:49:55 +00:00
|
|
|
|
2019-09-29 13:26:21 +00:00
|
|
|
case $os in
|
|
|
|
# Alpine actually has an init script, as opposed to everyone else
|
|
|
|
|
|
|
|
alpine)
|
|
|
|
:
|
|
|
|
;;
|
|
|
|
debian|devuan)
|
|
|
|
__file /etc/init.d/nftables --source "$initscript" --mode 0755
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported os: $os" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
require="__package/nftables" __start_on_boot nftables
|