tinc-up.j2 637 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. # {{ ansible_managed }}
  3. OS=`uname`
  4. {% if tinc_vpn_ipv4_net is defined %}
  5. IPv4_HOSTPREFIX={{ tinc_vpn_ipv4_net | ipv4(_hostnumber) }}
  6. {% endif %}
  7. {% if tinc_vpn_ipv6_net is defined %}
  8. IPv6_HOSTPREFIX={{ tinc_vpn_ipv6_net | ipv6(_hostnumber) }}
  9. {% endif %}
  10. case $OS in
  11. FreeBSD)
  12. [ -z "$IPv4_HOSTPREFIX" ] || ifconfig $INTERFACE $IPv4_HOSTPREFIX
  13. [ -z "$IPv6_HOSTPREFIX" ] || ifconfig $INTERFACE inet6 $IPv6_HOSTPREFIX
  14. ;;
  15. Linux)
  16. ip link set $INTERFACE up
  17. [ -z "$IPv4_HOSTPREFIX" ] || ip addr add $IPv4_HOSTPREFIX dev $INTERFACE
  18. [ -z "$IPv6_HOSTPREFIX" ] || ip -6 addr add $IPv6_HOSTPREFIX dev $INTERFACE
  19. ;;
  20. esac