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
656 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_remon_ipv4 = "1" ] || \
  22. [ mwan3_rtmon_ipv6 = "1" ] && break
  23. mwan3_unlock "service" "mwan3rtmon"
  24. [ "$rtmon_interval" = "0" ] && break
  25. sleep "$rtmon_interval" &
  26. wait
  27. done
  28. mwan3_unlock "service" "mwan3rtmon"
  29. }
  30. main "$@"