1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/bin/bash
- success() {
- echo "[ OK ] $1"
- }
- info() {
- echo "[INFO] $1"
- }
- warn() {
- echo "[WARN] $1" >&2
- }
- error() {
- echo "[FAIL] $1" >&2
- }
- critical() {
- echo "[CRIT] $1" >&2
- exit 1
- }
- echo "[INFO] Validating that VPN is up and the server is connected to internet..."
- ipv4=$(ping -w3 -c1 ip.yunohost.org >/dev/null 2>&1 && curl --max-time 5 https://ip.yunohost.org --silent)
- ipv6=$(ping -w3 -c1 ip6.yunohost.org >/dev/null 2>&1 && curl --max-time 5 https://ip6.yunohost.org --silent)
- if ip route get 1.2.3.4 | grep -q tun0; then
- if ping -c1 -w5 debian.org >/dev/null; then
- echo "[ OK ] YunoHost VPN client started!"
- echo "[INFO] IPv4 address is $ipv4"
- echo "[INFO] IPv6 address is $ipv6"
- else
- echo "[CRIT] The VPN is up but debian.org cannot be reached, indicating that something is probably misconfigured/blocked." >&2
- exit 1
- fi
- else
- echo "[CRIT] IPv4 routes are misconfigured !?" >&2
- exit 1
- fi
|