From de944792de142478f5c42e029e6584d98afcd9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:52:49 +0100 Subject: [PATCH] SonarQube: Fixes (#9875) * Fixes * Update --- ct/sonarqube.sh | 16 ++++++++-------- install/sonarqube-install.sh | 19 +++---------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/ct/sonarqube.sh b/ct/sonarqube.sh index 821c6479fd..39c2cffd89 100644 --- a/ct/sonarqube.sh +++ b/ct/sonarqube.sh @@ -33,30 +33,30 @@ function update_script() { systemctl stop sonarqube msg_ok "Stopped Service" - msg_info "Creating backup" + msg_info "Creating Backup" BACKUP_DIR="/opt/sonarqube-backup" mv /opt/sonarqube ${BACKUP_DIR} - msg_ok "Backup created" + msg_ok "Created Backup" - msg_info "Installing sonarqube" + msg_info "Updating 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) }') + RELEASE=$(get_latest_github_release "SonarSource/sonarqube") 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_ok "Updated SonarQube" - msg_info "Restoring backup" + 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_ok "Restored Backup" msg_info "Starting Service" systemctl start sonarqube - msg_ok "Service started" + msg_ok "Service Started" msg_ok "Updated successfully!" fi exit diff --git a/install/sonarqube-install.sh b/install/sonarqube-install.sh index e8e9ce8f71..e2ecc10ab6 100644 --- a/install/sonarqube-install.sh +++ b/install/sonarqube-install.sh @@ -14,24 +14,11 @@ update_os JAVA_VERSION="21" setup_java PG_VERSION="17" setup_postgresql +PG_DB_NAME="sonarqube" PG_DB_USER="sonarqube" setup_postgresql_db -msg_info "Installing Postgresql" -DB_NAME="sonarqube" -DB_USER="sonarqube" -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) -$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;" -{ - echo "Application Credentials" - echo "DB_NAME: $DB_NAME" - echo "DB_USER: $DB_USER" - echo "DB_PASS: $DB_PASS" -} >>~/sonarqube.creds -msg_ok "Installed PostgreSQL" - -msg_info "Configuring SonarQube" +msg_info "Setting up 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) }') +RELEASE=$(get_latest_github_release "SonarSource/sonarqube") 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