#!/sbin/openrc-run
# managed by ovpmon deploy/native  (firewall.sh replaces this file only while this marker line is present)
#
# Loads the nftables rules of the VPN clients (masquerade, TCP MSS clamp, TTL) at boot, OpenRC (Alpine).
# Install: `deploy/native/firewall.sh` renders this script into /etc/init.d/ovpmon-nft, adds it to the default
# runlevel and starts it. Independent of the distribution's nftables service: only the table `ip ovpmon`
# is loaded and removed. Guide: DOCS/Deployment/Scenario2_System_Services.md

name="ovpmon-nft"
description="NAT, MSS and TTL rules for the VPN clients (nftables)"

rules="/etc/ovpmon/nftables.nft"

depend() {
	need localmount
	before net
}

start() {
	ebegin "Loading $rules"
	nft -f "$rules"
	eend $?
}

stop() {
	ebegin "Removing the table ip ovpmon"
	nft delete table ip ovpmon 2>/dev/null
	eend 0
}
