From 93809e578466af79bb0844238c1666e546a6bf91 Mon Sep 17 00:00:00 2001 From: Enzo Legrand Date: Tue, 30 Sep 2025 16:51:05 +0200 Subject: [PATCH] add: sonarqube installation script --- install/sonarqube-install.sh | 93 ++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 install/sonarqube-install.sh diff --git a/install/sonarqube-install.sh b/install/sonarqube-install.sh new file mode 100644 index 00000000..eb9c5de2 --- /dev/null +++ b/install/sonarqube-install.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2025 community-scripts ORG +# Author: prop4n +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://docs.sonarsource.com/sonarqube-server + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y openjdk-17-jdk curl unzip +msg_ok "Installed Dependencies" + +RELEASE=$(curl -s https://api.github.com/repos/SonarSource/sonarqube/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +PG_VERSION="17" setup_postgresql + +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) +systemctl start postgresql +$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 "Creating SonarQube User" +useradd -r -m -U -d /opt/sonarqube -s /bin/bash sonarqube 2>/dev/null || true + +msg_info "SonarQube Installation" +curl -fsSL -o /tmp/sonarqube.zip "https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${RELEASE}.zip" +unzip -q /tmp/sonarqube.zip -d /tmp +cp -r /tmp/sonarqube-*/* /opt/sonarqube/ +rm -rf /tmp/sonarqube* +chown -R sonarqube:sonarqube /opt/sonarqube +chmod -R 755 /opt/sonarqube +msg_ok "Installed SonarQube" + +msg_info "Configuring SonarQube" +mkdir -p /opt/sonarqube/conf +cat >/opt/sonarqube/conf/sonar.properties </etc/systemd/system/sonarqube.service <