#!/bin/sh

set -o | grep -q pipefail && set -o pipefail
set -eu

test -f /etc/tinc/${NETNAME}/static_ips

case $2 in
  tinc)
    case $1 in
      up)
        # Agrega todas las IPs que pueda, si falla alguna, fallamos en
        # general luego de probar todas.
        for static_ip in `cat /etc/tinc/${NETNAME}/static_ips`; do
          ip address add ${static_ip} dev ${INTERFACE} || ret=$?
        done
      ;;
      down) ;;
    esac
    ;;
  *) exit 1 ;;
esac

exit $ret
