40-vpnclient-set-ipv6 723 B

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