diff --git a/etc/init.d/wireguard b/etc/init.d/wireguard new file mode 100644 index 0000000..87426fc --- /dev/null +++ b/etc/init.d/wireguard @@ -0,0 +1,42 @@ +#!/sbin/openrc-run + +description="WireGuard VPN tunnel" +required_dirs="/etc/wireguard" + +WIREGUARD= +name=$RC_SVCNAME +command="/usr/bin/wg-quick" +extra_started_commands="up down" +command_user="root" +pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid" +command_background="yes" + +depend() { + need localmount + need net +} + +start_pre() { + checkpath --directory --owner $command_user:$command_user --mode 0775 \ + /run/$RC_SVCNAME /var/log/$RC_SVCNAME +} + +up() { + ${command} up $WIREGUARD +} + +down() { + ${command} down $WIREGUARD +} + +start() { + ebegin "Starting wireguard" + up + eend $? +} + +stop() { + ebegin "Stopping wireguard" + down + eend $? +}