10-vpnclient-set-firewall 602 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. is_firewall_set() {
  3. local wired_device=$(ip route | awk '/default via/ { print $5; }')
  4. ip6tables -w -nvL OUTPUT | grep vpnclient_out | grep -q "${wired_device}" \
  5. && iptables -w -nvL OUTPUT | grep vpnclient_out | grep -q "${wired_device}"
  6. }
  7. if ! is_firewall_set; then
  8. bash /etc/yunohost/apps/vpnclient/conf/hook_post-iptable-rules
  9. cp /etc/yunohost/apps/vpnclient/conf/hook_post-iptable-rules /etc/yunohost/hooks.d/post_iptable_rules/90-vpnclient
  10. fi
  11. if is_firewall_set; then
  12. echo "[ OK ] IPv6/IPv4 firewall set"
  13. else
  14. echo "[FAIL] No IPv6/IPv4 firewall set" >&2
  15. exit 1
  16. fi