123456789101112131415161718192021222324252627282930313233343536 |
- #!/bin/bash
- is_serverip6route_set() {
- local server_ip6s=${1}
- if [[ -z "${server_ip6s}" ]]; then
- return 0
- fi
- for server_ip6 in ${server_ip6s}; do
- if ! ip -6 route | grep -q "^${server_ip6}"; then
- return 1
- fi
- done
- }
- unset_serverip6route() {
- local server_ip6s=${1}
- local ip6_gw=${2}
- local wired_device=${3}
- for server_ip6 in ${server_ip6s}; do
- ip route delete "${server_ip6}/128" via "${ip6_gw}" dev "${wired_device}"
- done
- }
- old_ip6_gw=$(yunohost app setting vpnclient ip6_gw)
- old_wired_device=$(yunohost app setting vpnclient wired_device)
- old_server_ip6=$(yunohost app setting vpnclient server_ip6)
- # Check old state of the server ipv6 route
- if [[ -n "${old_server_ip6}" && -n "${old_ip6_gw}" && -n "${old_wired_device}" ]]; then
- if is_serverip6route_set "${old_server_ip6}"; then
- unset_serverip6route "${old_server_ip6}" "${old_ip6_gw}" "${old_wired_device}"
- fi
- fi
|