#!/bin/bash

pickup_defaults
pickup_options

. $SCRIPTDIR/functions

[ -x "${AWG:=$DEFAULT_AWG}" ] || {
        print_error "$AWG does not exist or is not executable. Try installing amneziawg-tools RPM."
        exit 1
}

AWGCONFIG="$IFACEDIR/$NAME/$AWG_CONF"

[ -f "$AWGCONFIG" ] || {
        print_error 'no AWG_CONF filename in options or file does not exists !'
        exit 1
}

$IP link add $NAME type amneziawg

$AWG setconf "$NAME" "$AWGCONFIG"
