fn_install_ts3db 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # LGSM fn_install_ts3_mariadb function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="251215"
  6. fn_install_ts3db_mariadb(){
  7. echo ""
  8. echo "checking if libmariadb2 is installed"
  9. echo "================================="
  10. ldd ${filesdir}/libts3db_mariadb.so | grep "libmariadb.so.2 => not found"
  11. if [ $? -eq 0 ]; then
  12. echo "libmariadb2 not installed. Please install it first."
  13. echo "exiting..."
  14. exit
  15. else
  16. echo "libmariadb2 installed."
  17. fi
  18. echo ""
  19. echo "Configuring ${gamename} Server for MariaDB/MySQL"
  20. echo "================================="
  21. sleep 1
  22. read -p "Enter MariaDB hostname: " mariahostname
  23. read -p "Enter MariaDB port: " mariaport
  24. read -p "Enter MariaDB username: " mariausername
  25. read -p "Enter MariaDB password: " mariapassword
  26. read -p "Enter MariaDB database name: " mariadbname
  27. echo "updating config."
  28. echo "[config]" >> ${servercfgdir}/ts3db_mariadb.ini
  29. echo "host='${mariahostname}'" >> ${servercfgdir}/ts3db_mariadb.ini
  30. echo "port='${mariaport}'" >> ${servercfgdir}/ts3db_mariadb.ini
  31. echo "username='${mariausername}'" >> ${servercfgdir}/ts3db_mariadb.ini
  32. echo "password='${mariapassword}'" >> ${servercfgdir}/ts3db_mariadb.ini
  33. echo "database='${mariadbname}'" >> ${servercfgdir}/ts3db_mariadb.ini
  34. echo "socket=" >> ${servercfgdir}/ts3db_mariadb.ini
  35. sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
  36. sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
  37. sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
  38. echo "================================="
  39. sleep 1
  40. }
  41. echo ""
  42. while true; do
  43. read -e -i "n" -p "Do you want to use MariaDB/MySQL instead of sqlite (Database Server including user and database already has to be set up!)? [y/N]" yn
  44. case $yn in
  45. [Yy]* ) fn_install_ts3db_mariadb && break;;
  46. [Nn]* ) break;;
  47. * ) echo "Please answer yes or no.";;
  48. esac
  49. done
  50. ## Get privilege key
  51. echo ""
  52. echo "Getting privilege key"
  53. echo "================================="
  54. sleep 1
  55. echo "IMPORANT! Save these details for later."
  56. sleep 1
  57. cd "${executabledir}"
  58. ./ts3server_startscript.sh start inifile=ts3-server.ini
  59. sleep 5
  60. ./ts3server_startscript.sh stop