setup.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. echo "Checking dependencies..."
  3. python -c "
  4. try:
  5. import praw
  6. except ImportError:
  7. print 'redditmodule requires praw. pybot will run fine without it.'
  8. try:
  9. import MySQLdb
  10. except ImportError:
  11. print 'pybot requires mysqldb. It will run without it; it\'ll just throw lots of errors.'
  12. try:
  13. import requests
  14. except ImportError:
  15. print 'several modules require requests. pybot will run, but several modules will not function.'
  16. "
  17. if [[ $? -ne 0 ]]; then
  18. echo "Dependency checks failed.
  19. pybot's module dependencies are available in pip, which is probably available in your package manager.
  20. Install dependencies with 'pip install <package name>'."
  21. else
  22. echo "Dependency checks succeeded."
  23. fi
  24. read -p "Do you want to use mysql? [y/n] " mysql_answer
  25. if [[ $mysql_answer == "y" ]]; then
  26. echo "The following information should be what is in your pybotrc file, for dbname, dbusername, and dbpass, respectively."
  27. echo
  28. read -p "Enter database name for bot to use: " dbname
  29. read -p "Enter MYSQL username bot will log in with: " username
  30. read -s -p "Enter user password: " password
  31. echo
  32. read -s -p "Re-enter password: " password2
  33. echo
  34. if [ -f mysql_init ]; then
  35. rm mysql_init
  36. fi
  37. echo "CREATE DATABASE IF NOT EXISTS $dbname;" > mysql_init
  38. echo "GRANT ALL ON $dbname.* TO '$username'@'localhost' IDENTIFIED BY '$password';" >> mysql_init
  39. echo "mysql_init file has been created. As root or otherwise mysql-privileged user, run 'mysql -p < mysql_init'"
  40. else
  41. echo "you're using sqlite. you're done!"
  42. fi