You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
623 B

  1. #!/bin/sh
  2. . /lib/functions.sh
  3. . /lib/mwan3/mwan3.sh
  4. LOG="logger -t $(basename "$0")[$$] -p"
  5. clean_up() {
  6. $LOG notice "Stopping mwan3rtmon..."
  7. exit 0
  8. }
  9. rtchange() {
  10. $LOG info "Detect rtchange event."
  11. }
  12. main() {
  13. local rtmon_interval
  14. trap clean_up TERM
  15. trap rtchange USR1
  16. config_load mwan3
  17. config_get rtmon_interval globals rtmon_interval '5'
  18. sleep 3
  19. while true; do
  20. mwan3_lock "service" "mwan3rtmon"
  21. mwan3_rtmon_ipv4 || mwan3_rtmon_ipv6
  22. ret=$?
  23. mwan3_unlock "service" "mwan3rtmon"
  24. [ "$ret" = "0" ] || break
  25. [ "$rtmon_interval" = "0" ] && break
  26. sleep "$rtmon_interval" &
  27. wait
  28. done
  29. }
  30. main "$@"