#!/bin/sh
_restarted=$(redis-cli get "${PPP_IFACE}_restarted")
if ([ -z "${_restarted}" ] || [ "${_restarted}" = "false" ]) && [ $(systemctl is-active strongswan-starter) = "active" ]; then
        _pif=$(grep nic /etc/ppp/peers/${PPP_IFACE} | cut -d'-' -f2)
        ifdown ${PPP_IFACE}
        ifdown ${_pif}
        sleep 1
        ifup ${_pif}
        ifup ${PPP_IFACE}
        redis-cli set ${PPP_IFACE}_triger_restart true
else
        redis-cli set ${PPP_IFACE}_triger_restart false
        redis-cli set ${PPP_IFACE}_restarted false
fi