#!/sbin/openrc-run

name="WireGuard"
description="WireGuard via wg-quick(8)"

command="${WG_BINARY:-/usr/bin/wg-quick}"
CONF="${WG_CONF:-/etc/wireguard/wg0.conf}"

depend() {
    need net
    use dns
}

start() {
    ebegin "Starting $description for $CONF"
    start-stop-daemon --background "${command}" up "$CONF"
    eend $? "Failed to start $description for $CONF"
}

stop() {
    ebegin "Stopping $description for $CONF"
    start-stop-daemon --background "${command}" down "$CONF"
    eend $? "Failed to stop $description for $CONF"
}
