From 34367f78d330425e5ecd908496fef545d6f528b9 Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 21:48:41 +0300 Subject: [PATCH 01/12] fix: improve `arch` package check logic - update the package check condition to use a more efficient command for verifying installed packages. Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index bf40cd75b..ce486b7fd 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -788,7 +788,7 @@ installPackages() { arch) local missing=() for pkg in "${packages[@]}"; do - if [[ -z $(pacman -Qqe "$pkg" 2>/dev/null) ]]; then + if ! pacman -Q "$pkg" >/dev/null 2>&1; then missing+=("$pkg") fi done From d6c51a538b4c1e383c4aad95a888f79ae08b9dcb Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 21:50:01 +0300 Subject: [PATCH 02/12] refactor: adjust indentation and remove unnecessary echo statements - corrected indentation for better readability - removed redundant help hint Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index ce486b7fd..fd86b8159 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -2060,8 +2060,8 @@ main() { echo " $(msg lang_choice)" echo " [$(colorize green 1)] $(msg lang_english)" echo " [$(colorize yellow 2)] $(msg lang_russian)" - local answer_lang - answer_lang=$(promptInput "$(msg your_lang)" "1") + local answer_lang + answer_lang=$(promptInput "$(msg your_lang)" "1") if [[ "$answer_lang" == "2" ]]; then lang="ru" fi @@ -2071,8 +2071,6 @@ main() { echo " $(msg script_title)" echo "=============================================================" echo "" - echo " $(msg help_hint)" - echo "" local user_choice user_choice=$(promptYesNoDelete "$(msg want_install)" "n") From fa024e502d414bbc71f006b44292fe6ae5d48a10 Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 21:51:03 +0300 Subject: [PATCH 03/12] refactor: remove help hint from localization messages Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index fd86b8159..10d258859 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -74,7 +74,6 @@ declare -A MSG_EN=( # Script info [script_title]="TorrServer install and configuration script for Linux" - [help_hint]="Enter $scriptname -h or --help or help for all available commands" # Checks [check_internet]="Check Internet access…" @@ -197,7 +196,6 @@ declare -A MSG_RU=( # Script info [script_title]="Скрипт установки, удаления и настройки TorrServer для Linux" - [help_hint]="Наберите $scriptname -h или --help или help для вызова справки всех доступных команд" # Checks [check_internet]="Проверяем соединение с Интернетом…" From c34618ee1454a7340b72836948a2431f295190af Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 21:53:40 +0300 Subject: [PATCH 04/12] refactor: streamline localization messages and update version handling - removed unnecessary internet check messages from both English and Russian localization - consolidated version update logic into a common function for better maintainability Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 93 +++++++-------------------------------- 1 file changed, 16 insertions(+), 77 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index 10d258859..29d64c619 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -76,11 +76,7 @@ declare -A MSG_EN=( [script_title]="TorrServer install and configuration script for Linux" # Checks - [check_internet]="Check Internet access…" - [have_internet]="Have Internet Access" - [no_internet]="No Internet. Check your network and DNS settings." [need_root]="Script must run as root or user with sudo privileges. Example: sudo $scriptname" - [need_ping]="Please install iputils-ping first" [unsupported_arch]="Unsupported Arch. Can't continue." [unsupported_os]="It looks like you are running this installer on a system other than Debian, Ubuntu, Fedora, CentOS, Amazon Linux, Oracle Linux or Arch Linux." @@ -125,7 +121,6 @@ declare -A MSG_EN=( [enable_log]="Enable TorrServer log output to file? (Yes/No) " [enable_bbr]="Enable BBR (TCP congestion control)? (Yes/No) " [confirm_delete]="Are you sure you want to delete TorrServer? (Yes/No) " - [yes_no_delete]="Enter Yes, No or Delete" # Uninstall [install_dir_label]="TorrServer install dir -" @@ -148,7 +143,6 @@ declare -A MSG_EN=( [bbr_config_failed]="Warning: Failed to configure BBR" [bbr_not_available]="BBR is not available in this kernel" [bbr_requires_kernel]="BBR requires Linux kernel 4.9+ with tcp_bbr module" - [bbr_settings_in_file]="BBR settings added to %s and will apply after reboot" [bbr_write_failed]="Failed to write to %s" [bbr_current_values]="Current: qdisc=%s, congestion_control=%s" [bbr_settings_will_apply]="BBR settings are in %s and will apply after reboot" @@ -198,11 +192,7 @@ declare -A MSG_RU=( [script_title]="Скрипт установки, удаления и настройки TorrServer для Linux" # Checks - [check_internet]="Проверяем соединение с Интернетом…" - [have_internet]="соединение с Интернетом успешно" - [no_internet]="Нет Интернета. Проверьте ваше соединение, а также разрешение имен DNS." [need_root]="Вам нужно запустить скрипт от root или пользователя с правами sudo. Пример: sudo $scriptname" - [need_ping]="Сначала установите iputils-ping" [unsupported_arch]="Не поддерживаемая архитектура. Продолжение невозможно." [unsupported_os]="Похоже, что вы запускаете этот установщик в системе отличной от Debian, Ubuntu, Fedora, CentOS, Amazon Linux, Oracle Linux или Arch Linux." @@ -247,7 +237,6 @@ declare -A MSG_RU=( [enable_log]="Включить запись журнала работы TorrServer в файл? (Yes/No) " [enable_bbr]="Включить BBR (управление перегрузкой TCP)? (Yes/No) " [confirm_delete]="Вы уверены что хотите удалить программу? (Yes/No) " - [yes_no_delete]="Ввведите Yes, No или Delete" # Uninstall [install_dir_label]="Директория c TorrServer -" @@ -270,7 +259,6 @@ declare -A MSG_RU=( [bbr_config_failed]="Предупреждение: Не удалось настроить BBR" [bbr_not_available]="BBR недоступен в этом ядре" [bbr_requires_kernel]="BBR требует Linux kernel 4.9+ с модулем tcp_bbr" - [bbr_settings_in_file]="Настройки BBR добавлены в %s и вступят в силу после перезагрузки" [bbr_write_failed]="Не удалось записать в %s" [bbr_current_values]="Текущие значения: qdisc=%s, congestion_control=%s" [bbr_settings_will_apply]="Настройки BBR находятся в %s и вступят в силу после перезагрузки" @@ -392,10 +380,6 @@ getIP() { serverIP="$ip" } -checkRunning() { - pgrep -f '[Tt]orr[Ss]erver' -} - promptYesNo() { local prompt="$1" local default="${2:-n}" @@ -459,26 +443,6 @@ promptInput() { echo "${answer:-$default}" } -readEnvFromProc() { - local pid="$1" - local key="$2" - - if [[ -z "$pid" || -z "$key" || ! -r "/proc/$pid/environ" ]]; then - return 1 - fi - - while IFS= read -r -d '' entry; do - case "$entry" in - "$key"=*) - printf '%s' "${entry#"${key}"=}" - return 0 - ;; - esac - done < "/proc/$pid/environ" - - return 1 -} - systemctlCmd() { local quiet=0 if [[ ${1:-} == "--quiet" ]]; then @@ -1593,13 +1557,15 @@ installTorrServer() { return 0 } -UpdateVersion() { - local target_version - target_version=$(getTargetVersion) +# Common function to update/downgrade TorrServer version +updateTorrServerVersion() { + local target_version="$1" + local cancel_message="$2" + local use_latest_url="${3:-0}" if ! checkGlibcCompatibility "$target_version"; then if [[ $SILENT_MODE -eq 0 ]]; then - echo " - $(msg update_cancelled)" + echo " - $(msg "$cancel_message")" fi return 1 fi @@ -1611,10 +1577,10 @@ UpdateVersion() { local binName binName=$(getBinaryName) local urlBin - if [[ -n "$specificVersion" ]]; then - urlBin=$(buildDownloadUrl "$target_version" "$binName") - else + if [[ $use_latest_url -eq 1 && -z "$specificVersion" ]]; then urlBin=$(buildDownloadUrl "latest" "$binName") + else + urlBin=$(buildDownloadUrl "$target_version" "$binName") fi downloadBinary "$urlBin" "$dirInstall/$binName" "$target_version" @@ -1637,43 +1603,16 @@ UpdateVersion() { return 0 } +UpdateVersion() { + local target_version + target_version=$(getTargetVersion) + updateTorrServerVersion "$target_version" "update_cancelled" 1 +} + DowngradeVersion() { local target_version target_version=$(getVersionTag "$downgradeRelease") - - if ! checkGlibcCompatibility "$target_version"; then - if [[ $SILENT_MODE -eq 0 ]]; then - echo " - $(msg downgrade_cancelled)" - fi - return 1 - fi - - if ! systemctlCmd stop "$serviceName.service"; then - : - fi - - local binName - binName=$(getBinaryName) - local urlBin - urlBin=$(buildDownloadUrl "$target_version" "$binName") - downloadBinary "$urlBin" "$dirInstall/$binName" "$target_version" - - # Update service file to reflect user change - if [[ -f "$dirInstall/$serviceName.service" ]]; then - createServiceFile - if ! systemctlCmd daemon-reload; then - : - fi - fi - - # Ensure BBR is active before starting service (if previously configured) - ensureBBRActive - - if ! systemctlCmd start "$serviceName.service"; then - : - fi - - return 0 + updateTorrServerVersion "$target_version" "downgrade_cancelled" 0 } ############################################# From 8fddeca497c4dc1d9263349878295a4a89cd07ee Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 22:00:14 +0300 Subject: [PATCH 05/12] feat: enhance error messaging and user prompts - add localized error messages for username and version requirements - improve user prompts for running the service as root and installing TorrServer - update echo statements to utilize the new message functions Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 46 ++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index 29d64c619..aef5c5f7c 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -178,6 +178,16 @@ declare -A MSG_EN=( # User mode [running_as_root]="Service will run as root user" [running_as_user]="Service will run as %s user" + + # Error messages + [error_username_required]="Error: Username required for --change-user" + [error_version_required]="Error: Version number required for downgrade" + [error_version_example]="Example: %s -d 101" + [error_unknown_option]="Unknown option: %s" + [installing_specific_version]="Installing specific version: %s" + [service_reconfigured_user]="Service reconfigured for user: %s" + [install_first_required]="Please install TorrServer first using: %s --install" + [prompt_run_as_root]="Run service as root user? (Yes/No) " ) declare -A MSG_RU=( @@ -294,6 +304,16 @@ declare -A MSG_RU=( # User mode [running_as_root]="Служба будет запущена от пользователя root" [running_as_user]="Служба будет запущена от пользователя %s" + + # Error messages + [error_username_required]="Ошибка: Требуется имя пользователя для --change-user" + [error_version_required]="Ошибка: Требуется номер версии для понижения версии" + [error_version_example]="Пример: %s -d 101" + [error_unknown_option]="Неизвестная опция: %s" + [installing_specific_version]="Установка конкретной версии: %s" + [service_reconfigured_user]="Служба перенастроена для пользователя: %s" + [install_first_required]="Пожалуйста, сначала установите TorrServer используя: %s --install" + [prompt_run_as_root]="Запустить службу от пользователя root? (Yes/No) " ) # Translation function @@ -1321,7 +1341,7 @@ EOF changeServiceUser() { local target_user="$1" if [[ -z "$target_user" ]]; then - echo "Error: Username required for --change-user" + echo " $(msg error_username_required)" exit 1 fi @@ -1404,7 +1424,7 @@ changeServiceUser() { installTorrServer() { if [[ $SILENT_MODE -eq 0 && $ROOT_PROMPTED -eq 0 ]]; then if [[ $USE_ROOT_USER -ne 1 ]]; then - if promptYesNo "Run service as root user? (Yes/No)" "n"; then + if promptYesNo "$(msg prompt_run_as_root)" "n"; then USE_ROOT_USER=1 username="root" fi @@ -1684,7 +1704,7 @@ reconfigureTorrServer() { # Check if TorrServer is installed if ! checkInstalled; then echo " - $(msg not_found)" - echo " - Please install TorrServer first using: $scriptname --install" + echo " - $(msg install_first_required "$scriptname")" exit 1 fi @@ -1833,13 +1853,13 @@ parseArguments() { downgradeRelease="$next_arg" shift else - echo "Error: Version number required for downgrade" - echo "Example: $scriptname -d 101" + echo " $(msg error_version_required)" + echo " $(msg error_version_example "$scriptname")" exit 1 fi else - echo "Error: Version number required for downgrade" - echo "Example: $scriptname -d 101" + echo " $(msg error_version_required)" + echo " $(msg error_version_example "$scriptname")" exit 1 fi ;; @@ -1858,7 +1878,7 @@ parseArguments() { changeUserName="$1" shift else - echo "Error: Username required for --change-user" + echo " $(msg error_username_required)" exit 1 fi ;; @@ -1876,7 +1896,7 @@ parseArguments() { shift ;; *) - echo "Unknown option: $1" + echo " $(msg error_unknown_option "$1")" helpUsage exit 1 ;; @@ -1898,7 +1918,7 @@ main() { case "$command" in install) if [[ $SILENT_MODE -eq 0 && -n "$specificVersion" ]]; then - echo " - Installing specific version: $specificVersion" + echo " - $(msg installing_specific_version "$specificVersion")" fi initialCheck @@ -1931,7 +1951,7 @@ main() { : fi if [[ $SILENT_MODE -eq 0 ]]; then - echo " - Service reconfigured for user: $username" + echo " - $(msg service_reconfigured_user "$username")" fi fi exit 0 @@ -1979,7 +1999,7 @@ main() { ;; change_user) if [[ -z "$changeUserName" ]]; then - echo "Error: Username required for --change-user" + echo " $(msg error_username_required)" exit 1 fi if ! isRoot; then @@ -2018,7 +2038,7 @@ main() { elif [[ "$user_choice" == "yes" ]]; then initialCheck - if promptYesNo "Run service as root user? (Yes/No)" "n"; then + if promptYesNo "$(msg prompt_run_as_root)" "n"; then USE_ROOT_USER=1 username="root" fi From b47341495e476ec42e14ec8b37384b293c48463a Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 22:12:46 +0300 Subject: [PATCH 06/12] feat: add option to change authentication credentials during setup - introduce a prompt for users to change their authentication username and password Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index aef5c5f7c..c247e35d1 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -117,6 +117,7 @@ declare -A MSG_EN=( [enable_auth]="Enable server authorization? (Yes/No) " [prompt_user]="User: " [prompt_password]="Password: " + [change_auth_credentials]="Change authentication username and password? (Yes/No) " [enable_rdb]="Start TorrServer in public read-only mode? (Yes/No) " [enable_log]="Enable TorrServer log output to file? (Yes/No) " [enable_bbr]="Enable BBR (TCP congestion control)? (Yes/No) " @@ -243,6 +244,7 @@ declare -A MSG_RU=( [enable_auth]="Включить авторизацию на сервере? (Yes/No) " [prompt_user]="Пользователь: " [prompt_password]="Пароль: " + [change_auth_credentials]="Изменить имя пользователя и пароль для авторизации? (Yes/No) " [enable_rdb]="Запускать TorrServer в публичном режиме без возможности изменения настроек через веб сервера? (Yes/No) " [enable_log]="Включить запись журнала работы TorrServer в файл? (Yes/No) " [enable_bbr]="Включить BBR (управление перегрузкой TCP)? (Yes/No) " @@ -1258,6 +1260,15 @@ configureService() { auth=$(cat "$dirInstall/accs.db" | head -2 | tail -1 | tr -d '[:space:]' | tr -d '"') if [[ $SILENT_MODE -eq 0 ]]; then printf ' - %s\n' "$(msg use_existing_auth "${dirInstall}/accs.db" "$auth")" + # Ask if user wants to change credentials + if promptYesNo "$(msg change_auth_credentials)" "n"; then + isAuthUser=$(promptInput "$(msg prompt_user)" "admin") + isAuthPass=$(promptInput "$(msg prompt_password)" "admin") + if [[ $SILENT_MODE -eq 0 ]]; then + printf ' %s\n' "$(msg store_auth "$isAuthUser" "$isAuthPass" "${dirInstall}/accs.db")" + fi + echo -e "{\n \"$isAuthUser\": \"$isAuthPass\"\n}" > "$dirInstall/accs.db" + fi fi fi fi From aee54fef08195927e7d6d3a3d1fed7800caed0b0 Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 22:14:26 +0300 Subject: [PATCH 07/12] fix: update BBR prompt messages for clarity - revise English and Russian prompts for enabling BBR to indicate it is recommended for better download speed Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index c247e35d1..a3ab7cdcd 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -120,7 +120,7 @@ declare -A MSG_EN=( [change_auth_credentials]="Change authentication username and password? (Yes/No) " [enable_rdb]="Start TorrServer in public read-only mode? (Yes/No) " [enable_log]="Enable TorrServer log output to file? (Yes/No) " - [enable_bbr]="Enable BBR (TCP congestion control)? (Yes/No) " + [enable_bbr]="Enable BBR (Recommended for better download speed)? (Yes/No) " [confirm_delete]="Are you sure you want to delete TorrServer? (Yes/No) " # Uninstall @@ -247,7 +247,7 @@ declare -A MSG_RU=( [change_auth_credentials]="Изменить имя пользователя и пароль для авторизации? (Yes/No) " [enable_rdb]="Запускать TorrServer в публичном режиме без возможности изменения настроек через веб сервера? (Yes/No) " [enable_log]="Включить запись журнала работы TorrServer в файл? (Yes/No) " - [enable_bbr]="Включить BBR (управление перегрузкой TCP)? (Yes/No) " + [enable_bbr]="Включить BBR (Рекомендуется для лучшей скорости загрузки)? (Yes/No) " [confirm_delete]="Вы уверены что хотите удалить программу? (Yes/No) " # Uninstall From 55c694d9e3520cb35995c58c42d7fb8f0b27226e Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 22:39:10 +0300 Subject: [PATCH 08/12] feat: add test script for installTorrServerLinux.sh and GitHub Actions workflow Signed-off-by: Pavel Pikta --- .github/scripts/test-install-script.sh | 315 ++++++++++++++++++++++ .github/workflows/test-install-script.yml | 119 ++++++++ 2 files changed, 434 insertions(+) create mode 100755 .github/scripts/test-install-script.sh create mode 100644 .github/workflows/test-install-script.yml diff --git a/.github/scripts/test-install-script.sh b/.github/scripts/test-install-script.sh new file mode 100755 index 000000000..671bd823a --- /dev/null +++ b/.github/scripts/test-install-script.sh @@ -0,0 +1,315 @@ +#!/usr/bin/env bash +# Test script for installTorrServerLinux.sh +# This script runs inside Docker containers to test the installation script + +set -e + +# Colors for output +readonly RED='\033[0;31m' +readonly GREEN='\033[0;32m' +readonly YELLOW='\033[1;33m' +readonly NC='\033[0m' # No Color + +# Test configuration +readonly SCRIPT_NAME="installTorrServerLinux.sh" +readonly INSTALL_DIR="/opt/torrserver" +readonly GLIBC_LIMITED_VERSION="135" +readonly MIN_GLIBC_VERSION="2.32" + +# Helper functions +log_info() { + echo -e "${GREEN}✓${NC} $1" +} + +log_error() { + echo -e "${RED}✗${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}⚠${NC} $1" +} + +log_test() { + echo "Test $1: $2" +} + +# Check if OS requires glibc-limited version +is_glibc_limited_os() { + local os="$1" + local glibc_limited_oses="$2" + echo "$glibc_limited_oses" | grep -qE "(^|\|)$os(\||$)" +} + +# Get glibc version message for OS +get_glibc_message() { + local os="$1" + case "$os" in + debian-11) + echo "Note: Debian 11 has glibc 2.31, installing version $GLIBC_LIMITED_VERSION (version 136+ requires glibc >= $MIN_GLIBC_VERSION)" + ;; + almalinux-8) + echo "Note: AlmaLinux 8 has glibc 2.28, installing version $GLIBC_LIMITED_VERSION (version 136+ requires glibc >= $MIN_GLIBC_VERSION)" + ;; + rocky-8) + echo "Note: Rocky 8 has glibc 2.28, installing version $GLIBC_LIMITED_VERSION (version 136+ requires glibc >= $MIN_GLIBC_VERSION)" + ;; + amazonlinux-2) + echo "Note: Amazon Linux 2 has glibc 2.26, installing version $GLIBC_LIMITED_VERSION (version 136+ requires glibc >= $MIN_GLIBC_VERSION)" + ;; + esac +} + +# Install RPM packages (dnf/yum) +install_rpm_packages() { + local pkg_manager="$1" + shift + local packages=("$@") + + "$pkg_manager" makecache -q || true + # Always remove curl-minimal first to avoid conflicts + "$pkg_manager" remove -y -q curl-minimal 2>/dev/null || true + + # Check if curl package is installed (not just curl-minimal) + if rpm -qa curl >/dev/null 2>&1; then + # curl package is already installed, just install other packages + "$pkg_manager" install -y -q "${packages[@]}" || true + else + # curl package not installed, install curl with --allowerasing + "$pkg_manager" install -y -q --allowerasing curl "${packages[@]}" || true + fi +} + +# Install dependencies based on OS +install_dependencies() { + if command -v apt-get >/dev/null 2>&1; then + apt-get update -qq + apt-get install -y -qq curl iputils-ping dnsutils || true + elif command -v dnf >/dev/null 2>&1; then + install_rpm_packages dnf iputils bind-utils + elif command -v yum >/dev/null 2>&1; then + install_rpm_packages yum iputils bind-utils + fi +} + +# Verify curl installation +verify_curl_installation() { + if command -v rpm >/dev/null 2>&1; then + if ! rpm -qa curl >/dev/null 2>&1; then + log_error "curl package is not installed after dependency installation" + exit 1 + fi + # Verify curl-minimal is not present (it should have been removed) + if rpm -qa curl-minimal >/dev/null 2>&1; then + log_warning "curl-minimal is still installed, removing it..." + rpm -e --nodeps curl-minimal 2>/dev/null || true + fi + elif command -v dpkg >/dev/null 2>&1; then + if ! dpkg -s curl >/dev/null 2>&1; then + log_error "curl package is not installed after dependency installation" + exit 1 + fi + fi +} + +# Run a test command and handle errors +run_test() { + local test_name="$1" + local test_command="$2" + local skip_on_error="${3:-false}" + + if eval "$test_command"; then + log_info "$test_name" + return 0 + else + if [[ "$skip_on_error" == "true" ]]; then + log_warning "$test_name (skipped)" + return 0 + else + log_error "$test_name" + return 1 + fi + fi +} + +# Main test execution +main() { + local matrix_os="${MATRIX_OS:-}" + local test_user="${TEST_USER:-default}" + local glibc_limited_oses="${GLIBC_LIMITED_OSES:-}" + + # Determine root flag + local root_flag='' + if [[ "$test_user" == 'root' ]]; then + root_flag='--root' + fi + + # Check if OS requires glibc-limited version + local is_glibc_limited=false + if is_glibc_limited_os "$matrix_os" "$glibc_limited_oses"; then + is_glibc_limited=true + fi + + echo "========================================" + echo "Testing $SCRIPT_NAME" + echo "OS: $matrix_os" + echo "User: $test_user" + echo "========================================" + echo "" + + # Test 1: Check script syntax + log_test "1" "Checking script syntax..." + if bash -n "$SCRIPT_NAME"; then + log_info "Script syntax is valid" + else + log_error "Script syntax check failed" + exit 1 + fi + echo "" + + # Test 2: Show help + log_test "2" "Testing help command..." + if ./"$SCRIPT_NAME" --help > /dev/null; then + log_info "Help command works" + else + log_error "Help command failed" + exit 1 + fi + echo "" + + # Test 3: Install in silent mode + log_test "3" "Installing TorrServer (silent mode)..." + if [[ "$is_glibc_limited" == "true" ]]; then + local glibc_msg + glibc_msg=$(get_glibc_message "$matrix_os") + if [[ -n "$glibc_msg" ]]; then + echo "$glibc_msg" + fi + if ./"$SCRIPT_NAME" --install "$GLIBC_LIMITED_VERSION" --silent $root_flag; then + log_info "Installation completed" + else + log_error "Installation failed" + exit 1 + fi + else + if ./"$SCRIPT_NAME" --install --silent $root_flag; then + log_info "Installation completed" + else + log_error "Installation failed" + exit 1 + fi + fi + echo "" + + # Test 4: Check installation + log_test "4" "Checking installation..." + if ls "$INSTALL_DIR"/TorrServer-linux-* >/dev/null 2>&1; then + log_info "Binary file exists" + else + log_error "Binary file not found" + exit 1 + fi + echo "" + + # Test 5: Check version + log_test "5" "Checking for updates..." + if [[ "$is_glibc_limited" == "true" ]]; then + echo "Note: Skipping version check (latest version requires glibc >= $MIN_GLIBC_VERSION)" + log_info "Version check skipped (expected)" + else + if ./"$SCRIPT_NAME" --check --silent $root_flag; then + log_info "Version check completed" + else + log_error "Version check failed" + exit 1 + fi + fi + echo "" + + # Test 6: Update (if available) + log_test "6" "Testing update command..." + if [[ "$is_glibc_limited" == "true" ]]; then + echo "Note: Skipping update test (latest version requires glibc >= $MIN_GLIBC_VERSION)" + log_info "Update check skipped (expected)" + else + if ./"$SCRIPT_NAME" --update --silent $root_flag; then + log_info "Update check completed" + else + log_error "Update check failed" + exit 1 + fi + fi + echo "" + + # Test 7: Reconfigure + log_test "7" "Testing reconfigure command..." + if ./"$SCRIPT_NAME" --reconfigure --silent $root_flag; then + log_info "Reconfigure completed" + else + log_error "Reconfigure failed" + exit 1 + fi + echo "" + + # Test 8: Change user (if not already root) + if [[ "$test_user" == 'default' ]]; then + log_test "8" "Testing change-user to root..." + if ./"$SCRIPT_NAME" --change-user root --silent; then + log_info "User change to root completed" + else + log_error "User change to root failed" + exit 1 + fi + echo "" + + # Test 8b: Change user back to default (only for Ubuntu to test full flow) + if [[ "$matrix_os" == 'ubuntu-22.04' ]] || [[ "$matrix_os" == 'ubuntu-24.04' ]]; then + log_test "8b" "Testing change-user back to default..." + if ./"$SCRIPT_NAME" --change-user torrserver --silent; then + log_info "User change back to default completed" + else + log_error "User change back to default failed" + exit 1 + fi + echo "" + fi + fi + + # Test 9: Cleanup - Uninstall + log_test "9" "Uninstalling TorrServer..." + if ./"$SCRIPT_NAME" --remove --silent; then + log_info "Uninstallation completed" + else + log_error "Uninstallation failed" + exit 1 + fi + echo "" + + # Test 10: Verify cleanup + log_test "10" "Verifying cleanup..." + if [[ ! -d "$INSTALL_DIR" ]] || [[ -z "$(ls -A "$INSTALL_DIR" 2>/dev/null)" ]]; then + log_info "Cleanup verified" + else + log_warning "Installation directory still exists (may be expected)" + fi + echo "" + + echo "========================================" + echo "All tests passed! ✓" + echo "========================================" +} + +# Setup and run tests +setup() { + # Install dependencies + install_dependencies + + # Verify curl installation + verify_curl_installation + + # Make script executable + chmod +x "$SCRIPT_NAME" +} + +# Run setup and main +setup +main diff --git a/.github/workflows/test-install-script.yml b/.github/workflows/test-install-script.yml new file mode 100644 index 000000000..61a91e37e --- /dev/null +++ b/.github/workflows/test-install-script.yml @@ -0,0 +1,119 @@ +name: Test Install Script + +on: + push: + branches: + - master + - feature/** + paths: + - "installTorrServerLinux.sh" + - ".github/workflows/test-install-script.yml" + - ".github/scripts/test-install-script.sh" + pull_request: + branches: + - master + paths: + - "installTorrServerLinux.sh" + - ".github/workflows/test-install-script.yml" + - ".github/scripts/test-install-script.sh" + workflow_dispatch: + +# OSes that require version 135 due to glibc < 2.32 +# Version 136+ requires glibc >= 2.32 +env: + GLIBC_LIMITED_OSES: "debian-11|almalinux-8|rocky-8|amazonlinux-2" + +jobs: + test-script-syntax: + name: Test Script Syntax + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Test script syntax + run: | + chmod +x installTorrServerLinux.sh + bash -n installTorrServerLinux.sh + echo "✓ Script syntax is valid" + + - name: Test help command + run: | + ./installTorrServerLinux.sh --help > /dev/null + ./installTorrServerLinux.sh help > /dev/null + echo "✓ Help command works" + + test-install-script: + name: Test on ${{ matrix.os }} (${{ matrix.test-user }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + - ubuntu-24.04 + - debian-11 + - debian-12 + - debian-13 + - fedora-latest + - almalinux-8 + - almalinux-9 + - almalinux-10 + - rocky-8 + - rocky-9 + - rocky-10 + - amazonlinux-2 + test-user: [root, default] + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Get Docker image for OS + id: get-image + run: | + # Map OS to Docker image + case "${{ matrix.os }}" in + ubuntu-22.04) IMAGE="ubuntu:22.04" ;; + ubuntu-24.04) IMAGE="ubuntu:24.04" ;; + debian-11) IMAGE="debian:11" ;; + debian-12) IMAGE="debian:12" ;; + debian-13) IMAGE="debian:13" ;; + fedora-latest) IMAGE="fedora:latest" ;; + almalinux-8) IMAGE="almalinux:8" ;; + almalinux-9) IMAGE="almalinux:9" ;; + almalinux-10) IMAGE="almalinux:10" ;; + rocky-8) IMAGE="rockylinux/rockylinux:8" ;; + rocky-9) IMAGE="rockylinux/rockylinux:9" ;; + rocky-10) IMAGE="rockylinux/rockylinux:10" ;; + amazonlinux-2) IMAGE="amazonlinux:2" ;; + *) + echo "Warning: Unknown OS ${{ matrix.os }}, using ubuntu:22.04 as default" + IMAGE="ubuntu:22.04" + ;; + esac + echo "image=$IMAGE" >> $GITHUB_OUTPUT + echo "Using Docker image: $IMAGE for OS: ${{ matrix.os }}" + + - name: Run tests in container + run: | + docker run --rm \ + -v "$PWD:/workspace" \ + -w /workspace \ + --privileged \ + -e MATRIX_OS="${{ matrix.os }}" \ + -e TEST_USER="${{ matrix.test-user }}" \ + -e GLIBC_LIMITED_OSES="${{ env.GLIBC_LIMITED_OSES }}" \ + "${{ steps.get-image.outputs.image }}" \ + bash -c " + set -e + + # Make test script executable + chmod +x .github/scripts/test-install-script.sh + + # Run the test script + .github/scripts/test-install-script.sh + " From 95ea5502df1d703109a3945292acb74ebacb217f Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 23:39:53 +0300 Subject: [PATCH 09/12] refactor: remove redundant authentication status logic from configureService function Signed-off-by: Pavel Pikta --- installTorrServerLinux.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/installTorrServerLinux.sh b/installTorrServerLinux.sh index a3ab7cdcd..d20ddb928 100755 --- a/installTorrServerLinux.sh +++ b/installTorrServerLinux.sh @@ -1232,12 +1232,6 @@ configureService() { else # Auth setting exists, ask if user wants to change it if [[ $SILENT_MODE -eq 0 ]]; then - local current_auth_status - if [[ $isAuth -eq 1 ]]; then - current_auth_status="enabled" - else - current_auth_status="disabled" - fi if promptYesNo "$(msg enable_auth)" "$([[ $isAuth -eq 1 ]] && echo 'y' || echo 'n')"; then isAuth=1 else From 4fc6c7e1d023a179079fd943fd646e0ef57b5911 Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 23:52:46 +0300 Subject: [PATCH 10/12] feat: implement retry logic for installation and command execution in test-install-script Signed-off-by: Pavel Pikta --- .github/scripts/test-install-script.sh | 103 ++++++++++++++++------ .github/workflows/test-install-script.yml | 5 +- 2 files changed, 80 insertions(+), 28 deletions(-) diff --git a/.github/scripts/test-install-script.sh b/.github/scripts/test-install-script.sh index 671bd823a..98f443a65 100755 --- a/.github/scripts/test-install-script.sh +++ b/.github/scripts/test-install-script.sh @@ -15,6 +15,8 @@ readonly SCRIPT_NAME="installTorrServerLinux.sh" readonly INSTALL_DIR="/opt/torrserver" readonly GLIBC_LIMITED_VERSION="135" readonly MIN_GLIBC_VERSION="2.32" +readonly MAX_RETRIES="${MAX_RETRIES:-3}" +readonly RETRY_DELAY="${RETRY_DELAY:-2}" # Helper functions log_info() { @@ -82,12 +84,12 @@ install_rpm_packages() { # Install dependencies based on OS install_dependencies() { if command -v apt-get >/dev/null 2>&1; then - apt-get update -qq - apt-get install -y -qq curl iputils-ping dnsutils || true + retry_command "apt-get update" "apt-get update -qq" 3 1 || true + retry_command "apt-get install" "apt-get install -y -qq curl iputils-ping dnsutils" 3 1 || true elif command -v dnf >/dev/null 2>&1; then - install_rpm_packages dnf iputils bind-utils + retry_command "dnf install" "install_rpm_packages dnf iputils bind-utils" 3 1 || true elif command -v yum >/dev/null 2>&1; then - install_rpm_packages yum iputils bind-utils + retry_command "yum install" "install_rpm_packages yum iputils bind-utils" 3 1 || true fi } @@ -111,22 +113,68 @@ verify_curl_installation() { fi } +# Retry a command with exponential backoff +retry_command() { + local test_name="$1" + local test_command="$2" + local max_attempts="${3:-$MAX_RETRIES}" + local delay="${4:-$RETRY_DELAY}" + local attempt=1 + local last_error=0 + + while [[ $attempt -le $max_attempts ]]; do + if eval "$test_command"; then + if [[ $attempt -gt 1 ]]; then + log_info "$test_name (succeeded on attempt $attempt)" + fi + return 0 + else + last_error=$? + if [[ $attempt -lt $max_attempts ]]; then + log_warning "$test_name failed (attempt $attempt/$max_attempts), retrying in ${delay}s..." + sleep "$delay" + delay=$((delay * 2)) + fi + attempt=$((attempt + 1)) + fi + done + + log_error "$test_name (failed after $max_attempts attempts)" + return $last_error +} + # Run a test command and handle errors run_test() { local test_name="$1" local test_command="$2" local skip_on_error="${3:-false}" + local use_retry="${4:-true}" - if eval "$test_command"; then - log_info "$test_name" - return 0 + if [[ "$use_retry" == "true" ]]; then + if retry_command "$test_name" "$test_command"; then + log_info "$test_name" + return 0 + else + if [[ "$skip_on_error" == "true" ]]; then + log_warning "$test_name (skipped after retries)" + return 0 + else + log_error "$test_name" + return 1 + fi + fi else - if [[ "$skip_on_error" == "true" ]]; then - log_warning "$test_name (skipped)" + if eval "$test_command"; then + log_info "$test_name" return 0 else - log_error "$test_name" - return 1 + if [[ "$skip_on_error" == "true" ]]; then + log_warning "$test_name (skipped)" + return 0 + else + log_error "$test_name" + return 1 + fi fi fi } @@ -153,6 +201,7 @@ main() { echo "Testing $SCRIPT_NAME" echo "OS: $matrix_os" echo "User: $test_user" + echo "Retry settings: max=$MAX_RETRIES, initial_delay=${RETRY_DELAY}s" echo "========================================" echo "" @@ -184,17 +233,17 @@ main() { if [[ -n "$glibc_msg" ]]; then echo "$glibc_msg" fi - if ./"$SCRIPT_NAME" --install "$GLIBC_LIMITED_VERSION" --silent $root_flag; then + if retry_command "Installation" "./$SCRIPT_NAME --install $GLIBC_LIMITED_VERSION --silent $root_flag"; then log_info "Installation completed" else - log_error "Installation failed" + log_error "Installation failed after retries" exit 1 fi else - if ./"$SCRIPT_NAME" --install --silent $root_flag; then + if retry_command "Installation" "./$SCRIPT_NAME --install --silent $root_flag"; then log_info "Installation completed" else - log_error "Installation failed" + log_error "Installation failed after retries" exit 1 fi fi @@ -216,10 +265,10 @@ main() { echo "Note: Skipping version check (latest version requires glibc >= $MIN_GLIBC_VERSION)" log_info "Version check skipped (expected)" else - if ./"$SCRIPT_NAME" --check --silent $root_flag; then + if retry_command "Version check" "./$SCRIPT_NAME --check --silent $root_flag"; then log_info "Version check completed" else - log_error "Version check failed" + log_error "Version check failed after retries" exit 1 fi fi @@ -231,10 +280,10 @@ main() { echo "Note: Skipping update test (latest version requires glibc >= $MIN_GLIBC_VERSION)" log_info "Update check skipped (expected)" else - if ./"$SCRIPT_NAME" --update --silent $root_flag; then + if retry_command "Update check" "./$SCRIPT_NAME --update --silent $root_flag"; then log_info "Update check completed" else - log_error "Update check failed" + log_error "Update check failed after retries" exit 1 fi fi @@ -242,10 +291,10 @@ main() { # Test 7: Reconfigure log_test "7" "Testing reconfigure command..." - if ./"$SCRIPT_NAME" --reconfigure --silent $root_flag; then + if retry_command "Reconfigure" "./$SCRIPT_NAME --reconfigure --silent $root_flag"; then log_info "Reconfigure completed" else - log_error "Reconfigure failed" + log_error "Reconfigure failed after retries" exit 1 fi echo "" @@ -253,10 +302,10 @@ main() { # Test 8: Change user (if not already root) if [[ "$test_user" == 'default' ]]; then log_test "8" "Testing change-user to root..." - if ./"$SCRIPT_NAME" --change-user root --silent; then + if retry_command "User change to root" "./$SCRIPT_NAME --change-user root --silent"; then log_info "User change to root completed" else - log_error "User change to root failed" + log_error "User change to root failed after retries" exit 1 fi echo "" @@ -264,10 +313,10 @@ main() { # Test 8b: Change user back to default (only for Ubuntu to test full flow) if [[ "$matrix_os" == 'ubuntu-22.04' ]] || [[ "$matrix_os" == 'ubuntu-24.04' ]]; then log_test "8b" "Testing change-user back to default..." - if ./"$SCRIPT_NAME" --change-user torrserver --silent; then + if retry_command "User change back to default" "./$SCRIPT_NAME --change-user torrserver --silent"; then log_info "User change back to default completed" else - log_error "User change back to default failed" + log_error "User change back to default failed after retries" exit 1 fi echo "" @@ -276,10 +325,10 @@ main() { # Test 9: Cleanup - Uninstall log_test "9" "Uninstalling TorrServer..." - if ./"$SCRIPT_NAME" --remove --silent; then + if retry_command "Uninstallation" "./$SCRIPT_NAME --remove --silent"; then log_info "Uninstallation completed" else - log_error "Uninstallation failed" + log_error "Uninstallation failed after retries" exit 1 fi echo "" diff --git a/.github/workflows/test-install-script.yml b/.github/workflows/test-install-script.yml index 61a91e37e..e4dea383b 100644 --- a/.github/workflows/test-install-script.yml +++ b/.github/workflows/test-install-script.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - feature/** paths: - "installTorrServerLinux.sh" - ".github/workflows/test-install-script.yml" @@ -22,6 +21,8 @@ on: # Version 136+ requires glibc >= 2.32 env: GLIBC_LIMITED_OSES: "debian-11|almalinux-8|rocky-8|amazonlinux-2" + MAX_RETRIES: "3" + RETRY_DELAY: "2" jobs: test-script-syntax: @@ -107,6 +108,8 @@ jobs: -e MATRIX_OS="${{ matrix.os }}" \ -e TEST_USER="${{ matrix.test-user }}" \ -e GLIBC_LIMITED_OSES="${{ env.GLIBC_LIMITED_OSES }}" \ + -e MAX_RETRIES="${{ env.MAX_RETRIES }}" \ + -e RETRY_DELAY="${{ env.RETRY_DELAY }}" \ "${{ steps.get-image.outputs.image }}" \ bash -c " set -e From c4253c8d74cf8e697c8b143e5129722c6b7eb38a Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Sun, 9 Nov 2025 23:54:35 +0300 Subject: [PATCH 11/12] chore: increase retry delay Signed-off-by: Pavel Pikta --- .github/workflows/test-install-script.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-install-script.yml b/.github/workflows/test-install-script.yml index e4dea383b..4ae94b252 100644 --- a/.github/workflows/test-install-script.yml +++ b/.github/workflows/test-install-script.yml @@ -22,7 +22,7 @@ on: env: GLIBC_LIMITED_OSES: "debian-11|almalinux-8|rocky-8|amazonlinux-2" MAX_RETRIES: "3" - RETRY_DELAY: "2" + RETRY_DELAY: "60" jobs: test-script-syntax: From 69e4098bb8c8af566bcd0deb3fb59e907dc74baa Mon Sep 17 00:00:00 2001 From: Pavel Pikta Date: Mon, 10 Nov 2025 22:55:18 +0300 Subject: [PATCH 12/12] feat: enhance test-install-script with detailed logging and structured output Signed-off-by: Pavel Pikta --- .github/scripts/test-install-script.sh | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/scripts/test-install-script.sh b/.github/scripts/test-install-script.sh index 98f443a65..9294f8f35 100755 --- a/.github/scripts/test-install-script.sh +++ b/.github/scripts/test-install-script.sh @@ -122,7 +122,15 @@ retry_command() { local attempt=1 local last_error=0 + # Print command before first attempt + if [[ $attempt -eq 1 ]]; then + echo "Executing: $test_command" + fi + while [[ $attempt -le $max_attempts ]]; do + if [[ $attempt -gt 1 ]]; then + echo "Retry attempt $attempt/$max_attempts: $test_command" + fi if eval "$test_command"; then if [[ $attempt -gt 1 ]]; then log_info "$test_name (succeeded on attempt $attempt)" @@ -206,26 +214,35 @@ main() { echo "" # Test 1: Check script syntax + echo "::group::Test 1: Check script syntax" log_test "1" "Checking script syntax..." + echo "Executing: bash -n $SCRIPT_NAME" if bash -n "$SCRIPT_NAME"; then log_info "Script syntax is valid" else log_error "Script syntax check failed" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 2: Show help + echo "::group::Test 2: Test help command" log_test "2" "Testing help command..." + echo "Executing: ./$SCRIPT_NAME --help" if ./"$SCRIPT_NAME" --help > /dev/null; then log_info "Help command works" else log_error "Help command failed" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 3: Install in silent mode + echo "::group::Test 3: Install TorrServer" log_test "3" "Installing TorrServer (silent mode)..." if [[ "$is_glibc_limited" == "true" ]]; then local glibc_msg @@ -237,6 +254,7 @@ main() { log_info "Installation completed" else log_error "Installation failed after retries" + echo "::endgroup::" exit 1 fi else @@ -244,22 +262,29 @@ main() { log_info "Installation completed" else log_error "Installation failed after retries" + echo "::endgroup::" exit 1 fi fi + echo "::endgroup::" echo "" # Test 4: Check installation + echo "::group::Test 4: Verify installation" log_test "4" "Checking installation..." + echo "Executing: ls $INSTALL_DIR/TorrServer-linux-*" if ls "$INSTALL_DIR"/TorrServer-linux-* >/dev/null 2>&1; then log_info "Binary file exists" else log_error "Binary file not found" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 5: Check version + echo "::group::Test 5: Check version" log_test "5" "Checking for updates..." if [[ "$is_glibc_limited" == "true" ]]; then echo "Note: Skipping version check (latest version requires glibc >= $MIN_GLIBC_VERSION)" @@ -269,12 +294,15 @@ main() { log_info "Version check completed" else log_error "Version check failed after retries" + echo "::endgroup::" exit 1 fi fi + echo "::endgroup::" echo "" # Test 6: Update (if available) + echo "::group::Test 6: Test update command" log_test "6" "Testing update command..." if [[ "$is_glibc_limited" == "true" ]]; then echo "Note: Skipping update test (latest version requires glibc >= $MIN_GLIBC_VERSION)" @@ -284,62 +312,79 @@ main() { log_info "Update check completed" else log_error "Update check failed after retries" + echo "::endgroup::" exit 1 fi fi + echo "::endgroup::" echo "" # Test 7: Reconfigure + echo "::group::Test 7: Test reconfigure command" log_test "7" "Testing reconfigure command..." if retry_command "Reconfigure" "./$SCRIPT_NAME --reconfigure --silent $root_flag"; then log_info "Reconfigure completed" else log_error "Reconfigure failed after retries" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 8: Change user (if not already root) if [[ "$test_user" == 'default' ]]; then + echo "::group::Test 8: Test change-user to root" log_test "8" "Testing change-user to root..." if retry_command "User change to root" "./$SCRIPT_NAME --change-user root --silent"; then log_info "User change to root completed" else log_error "User change to root failed after retries" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 8b: Change user back to default (only for Ubuntu to test full flow) if [[ "$matrix_os" == 'ubuntu-22.04' ]] || [[ "$matrix_os" == 'ubuntu-24.04' ]]; then + echo "::group::Test 8b: Test change-user back to default" log_test "8b" "Testing change-user back to default..." if retry_command "User change back to default" "./$SCRIPT_NAME --change-user torrserver --silent"; then log_info "User change back to default completed" else log_error "User change back to default failed after retries" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" fi fi # Test 9: Cleanup - Uninstall + echo "::group::Test 9: Uninstall TorrServer" log_test "9" "Uninstalling TorrServer..." if retry_command "Uninstallation" "./$SCRIPT_NAME --remove --silent"; then log_info "Uninstallation completed" else log_error "Uninstallation failed after retries" + echo "::endgroup::" exit 1 fi + echo "::endgroup::" echo "" # Test 10: Verify cleanup + echo "::group::Test 10: Verify cleanup" log_test "10" "Verifying cleanup..." + echo "Executing: Checking if $INSTALL_DIR is empty or doesn't exist" if [[ ! -d "$INSTALL_DIR" ]] || [[ -z "$(ls -A "$INSTALL_DIR" 2>/dev/null)" ]]; then log_info "Cleanup verified" else log_warning "Installation directory still exists (may be expected)" fi + echo "::endgroup::" echo "" echo "========================================" @@ -349,6 +394,7 @@ main() { # Setup and run tests setup() { + echo "::group::Setup: Install dependencies" # Install dependencies install_dependencies @@ -357,6 +403,8 @@ setup() { # Make script executable chmod +x "$SCRIPT_NAME" + echo "::endgroup::" + echo "" } # Run setup and main