ip-up.local 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. #
  3. # FFHO ip-up replacement script (Salt managed)
  4. #
  5. # Using a ip-up.local script intentionally PREVENTS ALL OTHER ip-up.d/ scripts
  6. # from being called. We don't want that stuff.
  7. #
  8. #
  9. # This script is run by the pppd after the link is established.
  10. #
  11. # This script is called with the following arguments:
  12. # Arg Name Example
  13. # $1 Interface name ppp0
  14. # $2 The tty ttyS1
  15. # $3 The link speed 38400
  16. # $4 Local IP number 12.34.56.78
  17. # $5 Peer IP number 12.34.56.99
  18. # $6 Optional ``ipparam'' value foo
  19. # The environment is cleared before executing this script
  20. # so the path must be reset
  21. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
  22. export PATH
  23. cat << EOF > /usr/local/sbin/fix_ppp_vrf.gen
  24. #!/bin/sh
  25. while ! ip a s dev ppp0 | grep -q "inet "; do
  26. sleep 1
  27. done
  28. ip link set ${1} master vrf_external
  29. ip link set ${1} up
  30. ip route add default via ${5} table 1023
  31. {%- if grains['id'] == 'bbr-kt.in.ffho.net' %}
  32. # Reload backbone GRE tunnels to rebind them to VRF master device
  33. for pop in ber dus fra; do
  34. for x in a b; do
  35. ifdown gre_ffrl_\${pop}_\${x}
  36. ifup gre_ffrl_\${pop}_\${x}
  37. done
  38. done
  39. {%- endif %}
  40. {%- if grains['id'] == 'bbr-wagsh.in.ffho.net' %}
  41. # Reload OpenVPN tunnels
  42. systemctl restart openvpn.service
  43. #systemctl restart fastd@hx-sued_intergw.service
  44. {%- endif %}
  45. EOF
  46. chmod 755 /usr/local/sbin/fix_ppp_vrf.gen
  47. at -f /usr/local/sbin/fix_ppp_vrf now