Merge pull request #964 from prop4n/add-script-sonarqube
Add sonarqube script
This commit is contained in:
commit
81b83889b7
66
ct/sonarqube.sh
Normal file
66
ct/sonarqube.sh
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
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
|
||||||
|
# Source: https://docs.sonarsource.com/sonarqube-server
|
||||||
|
|
||||||
|
APP="SonarQube"
|
||||||
|
var_tags="${var_tags:-automation}"
|
||||||
|
var_cpu="${var_cpu:-4}"
|
||||||
|
var_ram="${var_ram:-6144}"
|
||||||
|
var_disk="${var_disk:-25}"
|
||||||
|
var_os="${var_os:-debian}"
|
||||||
|
var_version="${var_version:-12}"
|
||||||
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
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
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9000${CL}"
|
36
frontend/public/json/sonarqube.json
Normal file
36
frontend/public/json/sonarqube.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "sonarqube",
|
||||||
|
"slug": "sonarqube",
|
||||||
|
"categories": [
|
||||||
|
20,
|
||||||
|
19
|
||||||
|
],
|
||||||
|
"date_created": "2025-09-30",
|
||||||
|
"type": "ct",
|
||||||
|
"updateable": true,
|
||||||
|
"privileged": false,
|
||||||
|
"interface_port": 9000,
|
||||||
|
"documentation": "https://docs.sonarsource.com/sonarqube-server",
|
||||||
|
"config_path": "/opt/sonarqube/conf/sonar.properties",
|
||||||
|
"website": "https://www.sonarsource.com/products/sonarqube/",
|
||||||
|
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/sonarqube.webp",
|
||||||
|
"description": "SonarQube Server automates code quality and security reviews and provides actionable code intelligence so developers can focus on building better, faster.",
|
||||||
|
"install_methods": [
|
||||||
|
{
|
||||||
|
"type": "default",
|
||||||
|
"script": "ct/sonarqube.sh",
|
||||||
|
"resources": {
|
||||||
|
"cpu": 4,
|
||||||
|
"ram": 6144,
|
||||||
|
"hdd": 25,
|
||||||
|
"os": "Debian",
|
||||||
|
"version": "12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default_credentials": {
|
||||||
|
"username": "admin",
|
||||||
|
"password": "admin"
|
||||||
|
},
|
||||||
|
"notes": []
|
||||||
|
}
|
76
install/sonarqube-install.sh
Normal file
76
install/sonarqube-install.sh
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
$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 <<EOF >/opt/sonarqube/conf/sonar.properties
|
||||||
|
sonar.jdbc.username=${DB_USER}
|
||||||
|
sonar.jdbc.password=${DB_PASS}
|
||||||
|
sonar.jdbc.url=jdbc:postgresql://localhost/${DB_NAME}
|
||||||
|
sonar.web.host=0.0.0.0
|
||||||
|
sonar.web.port=9000
|
||||||
|
EOF
|
||||||
|
chmod +x /opt/sonarqube/bin/linux-x86-64/sonar.sh
|
||||||
|
msg_ok "Configured SonarQube"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/sonarqube.service
|
||||||
|
[Unit]
|
||||||
|
Description=SonarQube service
|
||||||
|
After=postgresql.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
|
||||||
|
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
|
||||||
|
User=sonarqube
|
||||||
|
Group=sonarqube
|
||||||
|
Restart=on-failure
|
||||||
|
LimitNOFILE=131072
|
||||||
|
LimitNPROC=8192
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now sonarqube
|
||||||
|
msg_ok "Service Created"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
Loading…
x
Reference in New Issue
Block a user