From b2f70696720f4a0979a32466254c6fa6f48ab67e Mon Sep 17 00:00:00 2001 From: tremor021 Date: Thu, 2 Oct 2025 13:52:34 +0200 Subject: [PATCH] Revert sonarqube to old install method --- ct/sonarqube.sh | 73 +++++++++++++++++++----------------- install/sonarqube-install.sh | 9 ++++- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/ct/sonarqube.sh b/ct/sonarqube.sh index 4c79daab..c8338e4a 100644 --- a/ct/sonarqube.sh +++ b/ct/sonarqube.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) +source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: prop4n # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -20,40 +20,45 @@ color catch_errors function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/sonarqube ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - - if check_for_gh_release "sonarqube" "SonarSource/sonarqube"; then - msg_info "Stopping service" - systemctl stop sonarqube - msg_ok "Service stopped" - - msg_info "Creating backup" - BACKUP_DIR="/opt/sonarqube-backup" - mv /opt/sonarqube ${BACKUP_DIR} - msg_ok "Backup created" - - fetch_and_deploy_gh_release "sonarqube" "SonarSource/sonarqube" "tarball" - - msg_info "Restoring backup" - cp -rp ${BACKUP_DIR}/data/ /opt/sonarqube/data/ - cp -rp ${BACKUP_DIR}/extensions/ /opt/sonarqube/extensions/ - cp -p ${BACKUP_DIR}/conf/sonar.properties /opt/sonarqube/conf/sonar.properties - rm -rf ${BACKUP_DIR} - chown -R sonarqube:sonarqube /opt/sonarqube - msg_ok "Backup restored" - - msg_info "Starting service" - systemctl start sonarqube - msg_ok "Service started" - msg_ok "Updated Successfully" - fi + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/sonarqube ]]; then + msg_error "No ${APP} Installation Found!" exit + fi + + if check_for_gh_release "sonarqube" "SonarSource/sonarqube"; then + msg_info "Stopping service" + systemctl stop sonarqube + msg_ok "Service stopped" + + msg_info "Creating backup" + BACKUP_DIR="/opt/sonarqube-backup" + mv /opt/sonarqube ${BACKUP_DIR} + msg_ok "Backup created" + + msg_info "Installing sonarqube" + RELEASE=$(curl -fsSL https://api.github.com/repos/SonarSource/sonarqube/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + curl -fsSL "https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${RELEASE}.zip" -o $temp_file + unzip -q "$temp_file" -d /opt + mv /opt/sonarqube-* /opt/sonarqube + msg_ok "Installed sonarqube" + + msg_info "Restoring backup" + cp -rp ${BACKUP_DIR}/data/ /opt/sonarqube/data/ + cp -rp ${BACKUP_DIR}/extensions/ /opt/sonarqube/extensions/ + cp -p ${BACKUP_DIR}/conf/sonar.properties /opt/sonarqube/conf/sonar.properties + rm -rf ${BACKUP_DIR} + chown -R sonarqube:sonarqube /opt/sonarqube + msg_ok "Backup restored" + + msg_info "Starting service" + systemctl start sonarqube + msg_ok "Service started" + msg_ok "Updated Successfully" + fi + exit } start diff --git a/install/sonarqube-install.sh b/install/sonarqube-install.sh index cac2de19..57211e96 100644 --- a/install/sonarqube-install.sh +++ b/install/sonarqube-install.sh @@ -14,7 +14,6 @@ update_os JAVA_VERSION="21" setup_java PG_VERSION="17" setup_postgresql -fetch_and_deploy_gh_release "sonarqube" "SonarSource/sonarqube" "tarball" msg_info "Installing Postgresql" DB_NAME="sonarqube" @@ -31,11 +30,16 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;" msg_ok "Installed PostgreSQL" msg_info "Configuring SonarQube" +temp_file=$(mktemp) +RELEASE=$(curl -fsSL https://api.github.com/repos/SonarSource/sonarqube/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +curl -fsSL "https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${RELEASE}.zip" -o $temp_file +unzip -q "$temp_file" -d /opt +mv /opt/sonarqube-* /opt/sonarqube $STD useradd -r -m -U -d /opt/sonarqube -s /bin/bash sonarqube chown -R sonarqube:sonarqube /opt/sonarqube chmod -R 755 /opt/sonarqube mkdir -p /opt/sonarqube/conf -cat </opt/sonarqube/conf/sonar.properties +cat </opt/sonarqube/conf/sonar.properties sonar.jdbc.username=${DB_USER} sonar.jdbc.password=${DB_PASS} sonar.jdbc.url=jdbc:postgresql://localhost/${DB_NAME} @@ -43,6 +47,7 @@ sonar.web.host=0.0.0.0 sonar.web.port=9000 EOF chmod +x /opt/sonarqube/bin/linux-x86-64/sonar.sh +echo ${RELEASE} >>~/.sonarqube msg_ok "Configured SonarQube" msg_info "Creating Service"