40-vpnclient-set-ipv6 661 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. is_ip6addr_set() {
  3. local ip6_addr=${1}
  4. ip address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"
  5. }
  6. ip6_addr=$(yunohost app setting "vpnclient" "ip6_addr")
  7. if [[ -n "${ip6_addr}" ]] && [[ "${ip6_addr}" != none ]]; then
  8. if ! is_ip6addr_set "${ip6_addr}"; then
  9. ip address add "${ip6_addr}/64" dev tun0
  10. fi
  11. echo "[INFO] IPv6 delegated prefix found"
  12. echo "[INFO] IPv6 address computed from the delegated prefix: ${ip6_addr}"
  13. if is_ip6addr_set "${ip6_addr}"; then
  14. echo "[ OK ] IPv6 address correctly set"
  15. else
  16. echo "[FAIL] No IPv6 address set" >&2
  17. exit 1
  18. fi
  19. else
  20. echo "[INFO] No IPv6 delegated prefix found"
  21. fi