LinuxGSM/lgsm/modules/install_ts3db.sh
Daniel Gibbs 68ae13c069
feat: change sleep timers (#4339)
* refactor: simplify sleep time functions

The `fn_sleep_time` function has been refactored to remove unnecessary conditions and set a default sleep time of 0.5 seconds. Additionally, four new functions (`fn_sleep_time_1`, `fn_sleep_time_5`, `fn_sleep_time_10`) have been added to provide different sleep times of 1, 5, and 10 seconds respectively. This improves code readability and allows for more flexibility in setting sleep times.

* change sleep to fn_sleep_time

* refactor: optimize sleep time functions

- Refactored the code to optimize the sleep time functions.
- Updated the `fn_sleep_time` function calls to `fn_sleep_time_1` in multiple files.
- Removed unnecessary sleep time calls in some files.

* refactor: simplify sleep time function call

The code changes refactor the sleep time function call in the check_deps.sh file. Instead of calling fn_sleep_time_1, it now calls fn_sleep_time. This change simplifies the code and improves readability.

* feat: add sleep time before checking session

Add a sleep time of 1 second before checking the session in the command_monitor.sh file. This allows for better synchronization and improves the accuracy of the session check.

* changes

* refactor: optimize sleep time function

The code changes refactor the sleep time function in multiple files to improve efficiency. The fn_sleep_time function is replaced with fn_sleep_time_1. This change reduces unnecessary delays during execution.

* refactor: update sleep time function names

The sleep time functions in the core_messages.sh file have been updated to use more descriptive names. The fn_sleep_time function has been renamed to fn_sleep_time_1 for clarity and consistency. This change improves code readability and maintainability.

* refactor: optimize sleep time in core_messages.sh

The commit optimizes the sleep time in the core_messages.sh file. The fn_sleep_time and fn_print_dots functions now use a shorter sleep time of 0.5 seconds instead of 1 second, resulting in faster execution.

* refactor: improve readability and consistency in code

- Refactored the log messages to use consistent capitalization and wording.
- Updated log messages in check_glibc.sh, check_permissions.sh, command_backup.sh, command_update_linuxgsm.sh, command_wipe.sh, fix_samp.sh, install_config.sh, and set_dst_config_vars() functions.

feat: add more descriptive log messages

- Added more descriptive log messages to provide clearer information about the actions being performed.
- Updated log messages in check_glibc.sh, check_permissions.sh, command_backup.sh, command_update_linuxgsm.sh, command_wipe.sh, fix_samp.sh, install_config.sh.

fix: correct spelling errors in log messages

- Corrected spelling errors in some of the log messages for better clarity.
- Updated log messages in check_glibc.sh and fix_samp.sh.

* refactor: remove unnecessary print statements

This commit refactors the code by removing unnecessary print statements in multiple files. The removed print statements were used for displaying dots and warnings, but they are not needed anymore. This improves the readability and cleanliness of the code.

* refactor: improve commit messages for code changes

- Refactored check_glibc.sh to improve readability and clarity of error messages.
- Refactored check_permissions.sh to provide more informative error messages when checking /sys permissions.
- Refactored check_system_requirements.sh to provide clearer warning message when checking RAM requirements.
- Refactored command_backup.sh to provide more descriptive messages when starting a backup.

* remove legacy code

* fix: remove \t

* fix: run check_root

check root was never running because of logic in linuxgsm.sh

* fix: update warning message for missing sudo access

The warning message for users without sudo access has been updated to provide clearer instructions. Instead of just suggesting manual installation, it now also suggests running the script as root using `./${selfname} install`. This change improves user experience and helps them resolve dependency installation issues more effectively.

* tidy
2023-10-15 17:52:03 +01:00

74 lines
2.5 KiB
Bash

#!/bin/bash
# LinuxGSM install_ts3db.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Installs the database server MariaDB for TeamSpeak 3.
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_install_ts3db_mariadb() {
if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then
echo -e "copying libmariadb.so.2...\c"
cp "${serverfiles}/redist/libmariadb.so.2" "${serverfiles}"
local exitcode=$?
if [ "${exitcode}" != "0" ]; then
fn_print_fail_eol_nl
fn_script_log_fail "copying libmariadb.so.2"
core_exit.sh
else
fn_print_ok_eol_nl
fn_script_log_pass "copying libmariadb.so.2"
fi
fi
echo -e ""
echo -e "${bold}${lightyellow}Configure ${gamename} Server for MariaDB${default}"
fn_messages_separator
read -rp "Enter MariaDB hostname: " mariahostname
read -rp "Enter MariaDB port: " mariaport
read -rp "Enter MariaDB username: " mariausername
read -rp "Enter MariaDB password: " mariapassword
read -rp "Enter MariaDB database name: " mariadbname
read -rp "Enter MariaDB socket path: " mariadbsocket
{
echo -e "[config]"
echo -e "host='${mariahostname}'"
echo -e "port='${mariaport}'"
echo -e "username='${mariausername}'"
echo -e "password='${mariapassword}'"
echo -e "database='${mariadbname}'"
echo -e "socket='${mariadbsocket}'"
} >> "${servercfgdir}/ts3db_mariadb.ini"
sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
echo -e "updating ts3db_mariadb.ini."
fn_sleep_time_1
}
echo -e ""
echo -e "${bold}${lightyellow}Select Database${default}"
fn_messages_separator
if [ -z "${autoinstall}" ]; then
if fn_prompt_yn "Do you want to use MariaDB instead of sqlite? (MariaDB must be pre-configured)" N; then
fn_install_ts3db_mariadb
fi
else
fn_print_information_nl "./${selfname} auto-install is uses sqlite. For MariaDB use ./${selfname} install"
fi
install_eula.sh
echo -e ""
echo -e "${bold}${lightyellow}Getting Privilege Key${default}"
fn_messages_separator
fn_print_information_nl "Save these details for later."
fn_print_information_nl "Key also saved in:"
echo -e "${serverfiles}/privilege_key.txt"
cd "${executabledir}" || exit
./ts3server_startscript.sh start inifile=ts3-server.ini 2>&1 | tee "${serverfiles}/privilege_key.txt"
fn_sleep_time_5
./ts3server_startscript.sh stop