#!/bin/bash
# -*- mode: sh; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
# vim:set ft=sh et sw=2 ts=2:
#
# Fake radvd to test scripts
#
# Set the following in your radvd-gen.conf file to test:
#
# shellcheck disable=SC1090

[ "$1" = "-h" ] && {
  echo "Usage: ${0##*/} [ <radvd-gen-args> ]"
  exit 1
}

fail() {
  echo >&2 "$*"
  exit 1
}

# load common.conf
TEST_COMMON=${TEST_COMMON:-conf/common.conf}
{ [[ -r ${TEST_COMMON} ]] && . "${TEST_COMMON}"; } ||
  fail "Unable to load ${TEST_COMMON}"

# radvd-gen.conf loads general.conf for program overrides
export RADVDGEN_CONF=${RADVDGEN_CONF-$TEST_CONF/radvd-gen.conf}

bash "$SRC_ROOT/usr/lib/NetworkManager/dispatcher.d/95-radvd-gen" "$@" eth0 up
