flux-mrtg-update.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. ################################################################################
  3. # $Id: flux-mrtg-update.sh 2054 2006-12-30 16:57:55Z b4rt $
  4. # $Revision: 2054 $
  5. # $Date: 2006-12-30 10:57:55 -0600 (Sat, 30 Dec 2006) $
  6. ################################################################################
  7. # #
  8. # LICENSE #
  9. # #
  10. # This program is free software; you can redistribute it and/or #
  11. # modify it under the terms of the GNU General Public License (GPL) #
  12. # as published by the Free Software Foundation; either version 2 #
  13. # of the License, or (at your option) any later version. #
  14. # #
  15. # This program is distributed in the hope that it will be useful, #
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of #
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  18. # GNU General Public License for more details. #
  19. # #
  20. # To read the license please visit http://www.gnu.org/copyleft/gpl.html #
  21. # #
  22. # #
  23. ################################################################################
  24. # defaults
  25. FLUXPATH="/usr/local/torrentflux"
  26. CONFFILE="/etc/mrtg/mrtg.flux.cfg"
  27. BIN_MRTG="/usr/bin/mrtg"
  28. DEFAULT_CONFFILE="/etc/mrtg/flux-mrtg.conf"
  29. # load conf-file
  30. if [ "$1X" != "X" ] ; then
  31. if [ -e "$1" ] ; then
  32. . $1
  33. fi
  34. else
  35. if [ -e "$DEFAULT_CONFFILE" ] ; then
  36. . $DEFAULT_CONFFILE
  37. fi
  38. fi
  39. # check for mrtg-bin
  40. if [ ! -x "$BIN_MRTG" ] ; then
  41. BIN_MRTG=`whereis mrtg | awk '{print $2}'`
  42. if [ ! -x "$BIN_MRTG" ] ; then
  43. echo "error: cant find mrtg"
  44. exit
  45. fi
  46. fi
  47. # check for mrtg-directory, create if missing.
  48. if [ ! -d "$FLUXPATH/.mrtg" ] ; then
  49. mkdir -p $FLUXPATH/.mrtg
  50. fi
  51. # invoke mrtg for flux
  52. $BIN_MRTG $CONFFILE | tee -a $FLUXPATH/.mrtg/mrtg.log