diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2025-07-01 15:35:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-01 15:35:54 +0200 |
commit | e1b2689c3a2b1395323d2fc58588b1e1b3c07c53 (patch) | |
tree | f36a888ec1fef286ac59607c8a513668286e4065 /apps/installer/includes | |
parent | d3130f0d39064d03bed969c7bc135ebb6066442f (diff) |
feat(bash): startup-scripts reworked + bash scripts workflow integration (#22401)
Diffstat (limited to 'apps/installer/includes')
-rw-r--r-- | apps/installer/includes/functions.sh | 46 | ||||
-rw-r--r-- | apps/installer/includes/os_configs/debian.sh | 17 | ||||
-rw-r--r-- | apps/installer/includes/os_configs/ubuntu.sh | 40 |
3 files changed, 76 insertions, 27 deletions
diff --git a/apps/installer/includes/functions.sh b/apps/installer/includes/functions.sh index 7e95f78fca..b4bd14caf5 100644 --- a/apps/installer/includes/functions.sh +++ b/apps/installer/includes/functions.sh @@ -1,3 +1,8 @@ +#!/usr/bin/env bash + +# Set SUDO variable - one liner +SUDO=$([ "$EUID" -ne 0 ] && echo "sudo" || echo "") + function inst_configureOS() { echo "Platform: $OSTYPE" case "$OSTYPE" in @@ -45,6 +50,42 @@ function inst_configureOS() { esac } +# Use the data/sql/create/create_mysql.sql to initialize the database +function inst_dbCreate() { + echo "Creating database..." + + # Attempt to connect with MYSQL_ROOT_PASSWORD + if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then + if $SUDO mysql -u root -p"$MYSQL_ROOT_PASSWORD" < "$AC_PATH_ROOT/data/sql/create/create_mysql.sql" 2>/dev/null; then + echo "Database created successfully." + return 0 + else + echo "Failed to connect with provided password, falling back to interactive mode..." + fi + fi + + # In CI environments or when no password is set, try without password first + if [[ "$CONTINUOUS_INTEGRATION" == "true" ]]; then + echo "CI environment detected, attempting connection without password..." + + if $SUDO mysql -u root < "$AC_PATH_ROOT/data/sql/create/create_mysql.sql" 2>/dev/null; then + echo "Database created successfully." + return 0 + else + echo "Failed to connect without password, falling back to interactive mode..." + fi + fi + + # Try with password (interactive mode) + echo "Please enter your sudo and your MySQL root password if prompted." + $SUDO mysql -u root -p < "$AC_PATH_ROOT/data/sql/create/create_mysql.sql" + if [ $? -ne 0 ]; then + echo "Database creation failed. Please check your MySQL server and credentials." + exit 1 + fi + echo "Database created successfully." +} + function inst_updateRepo() { cd "$AC_PATH_ROOT" if [ ! -z $INSTALLER_PULL_FROM ]; then @@ -73,7 +114,8 @@ function inst_cleanCompile() { function inst_allInOne() { inst_configureOS inst_compile - dbasm_import true true true + inst_dbCreate + inst_download_client_data } function inst_getVersionBranch() { @@ -215,7 +257,7 @@ function inst_module_remove { function inst_simple_restarter { echo "Running $1 ..." - bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1" + bash "$AC_PATH_APPS/startup-scripts/src/simple-restarter" "$AC_BINPATH_FULL" "$1" echo #disown -a #jobs -l diff --git a/apps/installer/includes/os_configs/debian.sh b/apps/installer/includes/os_configs/debian.sh index 4183925651..0eb2b3b1e4 100644 --- a/apps/installer/includes/os_configs/debian.sh +++ b/apps/installer/includes/os_configs/debian.sh @@ -2,8 +2,11 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Set SUDO variable - one liner +SUDO=$([ "$EUID" -ne 0 ] && echo "sudo" || echo "") + if ! command -v lsb_release &>/dev/null ; then - sudo apt-get install -y lsb-release + $SUDO apt-get install -y lsb-release fi DEBIAN_VERSION=$(lsb_release -sr) @@ -18,18 +21,18 @@ if [[ $DEBIAN_VERSION -lt $DEBIAN_VERSION_MIN ]]; then echo "########## ########## ##########" fi -sudo apt-get update -y +$SUDO apt-get update -y -sudo apt-get install -y gdbserver gdb unzip curl \ +$SUDO apt-get install -y gdbserver gdb unzip curl \ libncurses-dev libreadline-dev clang g++ \ gcc git cmake make ccache \ libssl-dev libbz2-dev \ - libboost-all-dev gnupg wget + libboost-all-dev gnupg wget jq screen tmux VAR_PATH="$CURRENT_PATH/../../../../var" # run noninteractive install for MYSQL 8.4 LTS wget https://dev.mysql.com/get/mysql-apt-config_0.8.32-1_all.deb -P "$VAR_PATH" -sudo DEBIAN_FRONTEND="noninteractive" dpkg -i "$VAR_PATH/mysql-apt-config_0.8.32-1_all.deb" -sudo apt-get update -sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server libmysqlclient-dev +DEBIAN_FRONTEND="noninteractive" $SUDO dpkg -i "$VAR_PATH/mysql-apt-config_0.8.32-1_all.deb" +$SUDO apt-get update +DEBIAN_FRONTEND="noninteractive" $SUDO apt-get install -y mysql-server libmysqlclient-dev diff --git a/apps/installer/includes/os_configs/ubuntu.sh b/apps/installer/includes/os_configs/ubuntu.sh index 02e6997ccd..9b45b35c04 100644 --- a/apps/installer/includes/os_configs/ubuntu.sh +++ b/apps/installer/includes/os_configs/ubuntu.sh @@ -2,8 +2,11 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Set SUDO variable - one liner +SUDO=$([ "$EUID" -ne 0 ] && echo "sudo" || echo "") + if ! command -v lsb_release &>/dev/null ; then - sudo apt-get install -y lsb-release + $SUDO apt-get install -y lsb-release fi UBUNTU_VERSION=$(lsb_release -sr); @@ -23,28 +26,29 @@ case $UBUNTU_VERSION in ;; esac -sudo apt update +$SUDO apt update # shared deps -sudo DEBIAN_FRONTEND="noninteractive" \ -apt-get -y install ccache clang cmake curl google-perftools libmysqlclient-dev make unzip - -if [[ $CONTINUOUS_INTEGRATION || $DOCKER ]]; then - # TODO: update CI / Docker section for Ubuntu 22.04+ - sudo add-apt-repository -y ppa:mhier/libboost-latest && sudo apt update && sudo apt-get -y install build-essential cmake-data \ - libboost1.74-dev libbz2-dev libncurses5-dev libmysql++-dev libgoogle-perftools-dev libreadline6-dev libssl-dev libtool \ - openssl zlib1g-dev -else - sudo DEBIAN_FRONTEND="noninteractive" \ - apt-get install -y g++ gdb gdbserver gcc git \ - libboost-all-dev libbz2-dev libncurses-dev libreadline-dev \ - libssl-dev +DEBIAN_FRONTEND="noninteractive" $SUDO \ +apt-get -y install ccache clang cmake curl google-perftools libmysqlclient-dev make unzip jq screen tmux \ + libreadline-dev libncurses5-dev libncursesw5-dev libbz2-dev git gcc g++ libssl-dev \ + libncurses-dev libboost-all-dev gdb gdbserver VAR_PATH="$CURRENT_PATH/../../../../var" + +# Do not install MySQL if we are in docker (It will be used a docker container instead) or we are explicitly skipping it. +if [[ $DOCKER != 1 && $SKIP_MYSQL_INSTALL != 1 ]]; then # run noninteractive install for MYSQL 8.4 LTS wget https://dev.mysql.com/get/mysql-apt-config_0.8.32-1_all.deb -P "$VAR_PATH" - sudo DEBIAN_FRONTEND="noninteractive" dpkg -i "$VAR_PATH/mysql-apt-config_0.8.32-1_all.deb" - sudo apt-get update - sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server + DEBIAN_FRONTEND="noninteractive" $SUDO dpkg -i "$VAR_PATH/mysql-apt-config_0.8.32-1_all.deb" + $SUDO apt-get update + DEBIAN_FRONTEND="noninteractive" $SUDO apt-get install -y mysql-server +fi + + +if [[ $CONTINUOUS_INTEGRATION ]]; then + $SUDO systemctl enable mysql.service + $SUDO systemctl start mysql.service fi + |