setup.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. "
  13. if [[ $? -ne 0 ]]; then
  14. echo "Dependency checks failed.
  15. pybot's module dependencies are available in pip, which is probably available in your package manager.
  16. Install dependencies with 'pip install <package name>'."
  17. else
  18. echo "Dependency checks succeeded."
  19. fi
  20. echo "The following information should be what is in your pybotrc file, for dbname, dbusername, and dbpass, respectively."
  21. echo
  22. read -p "Enter database name for bot to use: " dbname
  23. read -p "Enter MYSQL username bot will log in with: " username
  24. read -s -p "Enter user password: " password
  25. echo
  26. read -s -p "Re-enter password: " password2
  27. echo
  28. if [ -f mysql_init ]; then
  29. rm mysql_init
  30. fi
  31. echo "CREATE DATABASE IF NOT EXISTS $dbname;" > mysql_init
  32. echo "GRANT ALL ON $dbname.* TO '$username'@'localhost' IDENTIFIED BY '$password';" >> mysql_init
  33. echo "mysql_init file has been created. As root or otherwise mysql-privileged user, run 'mysql -p < mysql_init'"