SonarQube: Fixes (#9875)

* Fixes

* Update
This commit is contained in:
Slaviša Arežina 2025-12-11 10:52:49 +01:00 committed by GitHub
parent 091271c8d6
commit de944792de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 24 deletions

View File

@ -33,30 +33,30 @@ function update_script() {
systemctl stop sonarqube systemctl stop sonarqube
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Creating backup" msg_info "Creating Backup"
BACKUP_DIR="/opt/sonarqube-backup" BACKUP_DIR="/opt/sonarqube-backup"
mv /opt/sonarqube ${BACKUP_DIR} mv /opt/sonarqube ${BACKUP_DIR}
msg_ok "Backup created" msg_ok "Created Backup"
msg_info "Installing sonarqube" msg_info "Updating SonarQube"
temp_file=$(mktemp) 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 curl -fsSL "https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${RELEASE}.zip" -o $temp_file
unzip -q "$temp_file" -d /opt unzip -q "$temp_file" -d /opt
mv /opt/sonarqube-* /opt/sonarqube 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}/data/ /opt/sonarqube/data/
cp -rp ${BACKUP_DIR}/extensions/ /opt/sonarqube/extensions/ cp -rp ${BACKUP_DIR}/extensions/ /opt/sonarqube/extensions/
cp -p ${BACKUP_DIR}/conf/sonar.properties /opt/sonarqube/conf/sonar.properties cp -p ${BACKUP_DIR}/conf/sonar.properties /opt/sonarqube/conf/sonar.properties
rm -rf ${BACKUP_DIR} rm -rf ${BACKUP_DIR}
chown -R sonarqube:sonarqube /opt/sonarqube chown -R sonarqube:sonarqube /opt/sonarqube
msg_ok "Backup restored" msg_ok "Restored Backup"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start sonarqube systemctl start sonarqube
msg_ok "Service started" msg_ok "Service Started"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
fi fi
exit exit

View File

@ -14,24 +14,11 @@ update_os
JAVA_VERSION="21" setup_java JAVA_VERSION="21" setup_java
PG_VERSION="17" setup_postgresql PG_VERSION="17" setup_postgresql
PG_DB_NAME="sonarqube" PG_DB_USER="sonarqube" setup_postgresql_db
msg_info "Installing Postgresql" msg_info "Setting up SonarQube"
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"
temp_file=$(mktemp) 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 curl -fsSL "https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${RELEASE}.zip" -o $temp_file
unzip -q "$temp_file" -d /opt unzip -q "$temp_file" -d /opt
mv /opt/sonarqube-* /opt/sonarqube mv /opt/sonarqube-* /opt/sonarqube