bot.sh 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. mydir=$(readlink -f $0)
  3. mydir=$(dirname "$mydir")
  4. python3 -V > /dev/null 2>&1 && python3="python3"
  5. if [ -z "$python3" ]; then
  6. python3.4 -V > /dev/null 2>&1 && python3="python3.4"
  7. if [ -z "$python3" ]; then
  8. echo "Did not find neither python3 nor python3.4 in your path :-("
  9. exit 1
  10. fi
  11. fi
  12. if [ ! -r "${mydir}/bot.cfg" ]; then
  13. echo "'bot.cfg' is missing. Have you copied 'bot.cfg.example'?"
  14. exit 2
  15. fi
  16. case $1 in
  17. start)
  18. [ ! -d "${mydir}/logs" ] && mkdir "${mydir}/logs"
  19. $python3 "${mydir}/willie/willie.py" -c "${mydir}/bot.cfg" --fork
  20. ;;
  21. stop)
  22. $python3 "${mydir}/willie/willie.py" -c "${mydir}/bot.cfg" --quit
  23. ;;
  24. restart)
  25. "$0" stop
  26. sleep 2
  27. "$0" start
  28. ;;
  29. reload)
  30. echo "Not supported by script. Issue '!reload ffpb' in a query to reload the ffpb module."
  31. exit 2
  32. ;;
  33. *)
  34. echo "Unknown command. Please give 'start', 'stop' or 'restart'."
  35. exit 1
  36. ;;
  37. esac