install_ts3db.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # LinuxGSM install_ts3db.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Installs the database server MariaDB for TeamSpeak 3.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. fn_install_ts3db_mariadb() {
  9. if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then
  10. echo -e "copying libmariadb.so.2...\c"
  11. cp "${serverfiles}/redist/libmariadb.so.2" "${serverfiles}"
  12. local exitcode=$?
  13. if [ "${exitcode}" == "0" ]; then
  14. fn_print_ok_eol_nl
  15. fn_script_log_pass "copying libmariadb.so.2"
  16. else
  17. fn_print_fail_eol_nl
  18. fn_script_log_fatal "copying libmariadb.so.2"
  19. core_exit.sh
  20. fi
  21. fi
  22. echo -e ""
  23. echo -e "${lightyellow}Configure ${gamename} Server for MariaDB${default}"
  24. echo -e "================================="
  25. fn_sleep_time
  26. read -rp "Enter MariaDB hostname: " mariahostname
  27. read -rp "Enter MariaDB port: " mariaport
  28. read -rp "Enter MariaDB username: " mariausername
  29. read -rp "Enter MariaDB password: " mariapassword
  30. read -rp "Enter MariaDB database name: " mariadbname
  31. read -rp "Enter MariaDB socket path: " mariadbsocket
  32. {
  33. echo -e "[config]"
  34. echo -e "host='${mariahostname}'"
  35. echo -e "port='${mariaport}'"
  36. echo -e "username='${mariausername}'"
  37. echo -e "password='${mariapassword}'"
  38. echo -e "database='${mariadbname}'"
  39. echo -e "socket='${mariadbsocket}'"
  40. } >> "${servercfgdir}/ts3db_mariadb.ini"
  41. sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
  42. sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
  43. sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
  44. echo -e "updating ts3db_mariadb.ini."
  45. fn_sleep_time
  46. }
  47. echo -e ""
  48. echo -e "${lightyellow}Select Database${default}"
  49. echo -e "================================="
  50. fn_sleep_time
  51. if [ -z "${autoinstall}" ]; then
  52. if fn_prompt_yn "Do you want to use MariaDB instead of sqlite? (MariaDB must be pre-configured)" N; then
  53. fn_install_ts3db_mariadb
  54. fi
  55. else
  56. fn_print_information_nl "./${selfname} auto-install is uses sqlite. For MariaDB use ./${selfname} install"
  57. fi
  58. install_eula.sh
  59. echo -e ""
  60. echo -e "${lightyellow}Getting privilege key${default}"
  61. echo -e "================================="
  62. fn_sleep_time
  63. fn_print_information_nl "Save these details for later."
  64. fn_print_information_nl "Key also saved in:"
  65. echo -e "${serverfiles}/privilege_key.txt"
  66. cd "${executabledir}" || exit
  67. ./ts3server_startscript.sh start inifile=ts3-server.ini 2>&1 | tee "${serverfiles}/privilege_key.txt"
  68. sleep 5
  69. ./ts3server_startscript.sh stop