stop-sqm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License version 2 as
  4. # published by the Free Software Foundation.
  5. #
  6. # Copyright (C) 2012-4 Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
  7. # allow passing in the IFACE as first command line argument
  8. [ -n "$IFACE" ] || exit 1
  9. . /etc/sqm/sqm.conf
  10. . ${SQM_LIB_DIR}/functions.sh
  11. . ${SQM_LIB_DIR}/defaults.sh
  12. check_state_dir
  13. # log file for the most recent sqm instance stop
  14. if [ "$SQM_DEBUG" -eq "1" ] ; then
  15. SQM_DEBUG_LOG="${SQM_STOP_LOG}"
  16. OUTPUT_TARGET="${SQM_DEBUG_LOG}"
  17. echo "stop-sqm: Log for interface ${IFACE}: $(date)" > "${OUTPUT_TARGET}"
  18. fi
  19. if [ ! -f "${SQM_STATE_DIR}/${IFACE}.state" ] ; then
  20. sqm_error "State file does not exist; SQM was not running on interface ${IFACE}"
  21. exit 1
  22. fi
  23. STATE_FILE="${SQM_STATE_DIR}/${IFACE}.state"
  24. if [ -z "${SCRIPT}" ] ; then
  25. sqm_error "SCRIPT value is not defined in /etc/sqm/${IFACE}.iface.conf"
  26. sqm_error "Please check your configuration and try again."
  27. exit 1
  28. fi
  29. sqm_trace; sqm_trace "$(date): Stopping." # Add some space and a date stamp to verbose log output and log files to separate runs
  30. # make sure to only delete the ifb associated with the current interface
  31. CUR_IFB=$( get_ifb_associated_with_if ${IFACE} )
  32. [ -z "$CUR_IFB" ] && CUR_IFB=$( ifb_name ${IFACE} )
  33. if [ ! -f "${SQM_LIB_DIR}/$SCRIPT" ]; then
  34. sqm_error "SQM script ${SCRIPT} not found!"
  35. exit 1
  36. fi
  37. . "${SQM_LIB_DIR}/$SCRIPT"
  38. if [ "$CLEANUP" -eq "1" ]; then
  39. sqm_log "Cleaning up SQM state on ${IFACE}"
  40. sqm_cleanup 1
  41. else
  42. sqm_log "Stopping SQM on ${IFACE}"
  43. sqm_stop
  44. fi
  45. rm -f "${STATE_FILE}"
  46. exit 0