install_ts3db.sh 2.5 KB

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