From 50f7ae12372f0de61f29c6f392567e8388945271 Mon Sep 17 00:00:00 2001 From: Kristo Copani <31226503+quantumryuu@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:56:38 +0200 Subject: [PATCH] New Script: Semaphore (#596) * re-add files * update a lot of things * more stuff * update password generation * Ready to PR! * remove empty end lines * Ready to PR! * Update semaphore.json --------- Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- ct/semaphore.sh | 71 +++++++++++++++++++++++++++++ install/semaphore-install.sh | 87 ++++++++++++++++++++++++++++++++++++ json/semaphore.json | 41 +++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 ct/semaphore.sh create mode 100644 install/semaphore-install.sh create mode 100644 json/semaphore.json diff --git a/ct/semaphore.sh b/ct/semaphore.sh new file mode 100644 index 00000000..5f84faa5 --- /dev/null +++ b/ct/semaphore.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 community-scripts ORG +# Author: kristocopani +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://semaphoreui.com/ + +# App Default Values +APP="Semaphore" +var_tags="dev_ops" +var_cpu="2" +var_ram="2048" +var_disk="4" +var_os="debian" +var_version="12" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /etc/systemd/system/semaphore.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/semaphoreui/semaphore/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Service" + systemctl stop semaphore + msg_ok "Stopped Service" + + msg_info "Updating ${APP} to v${RELEASE}" + cd /opt + wget -q https://github.com/semaphoreui/semaphore/releases/download/v${RELEASE}/semaphore_${RELEASE}_linux_amd64.deb + dpkg -i semaphore_${RELEASE}_linux_amd64.deb &>/dev/null + echo "${RELEASE}" >"/opt/${APP}_version.txt" + msg_ok "Updated ${APP} to v${RELEASE}" + + msg_info "Starting Service" + systemctl start semaphore + msg_ok "Started Service" + + msg_info "Cleaning up" + rm -rf /opt/semaphore_${RELEASE}_linux_amd64.deb + msg_ok "Cleaned" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}." + 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}:3000${CL}" \ No newline at end of file diff --git a/install/semaphore-install.sh b/install/semaphore-install.sh new file mode 100644 index 00000000..0f40928f --- /dev/null +++ b/install/semaphore-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 community-scripts ORG +# Author: kristocopani +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + mc \ + git \ + gpg \ + sudo + +wget -qO- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | gpg --dearmour >/usr/share/keyrings/ansible-archive-keyring.gpg +cat </etc/apt/sources.list.d/ansible.list +deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu jammy main +EOF +$STD apt update +$STD apt install -y ansible +msg_ok "Installed Dependencies" + +msg_info "Setup Semaphore" +RELEASE=$(curl -s https://api.github.com/repos/semaphoreui/semaphore/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +mkdir -p /opt/semaphore +cd /opt/semaphore +wget -q https://github.com/semaphoreui/semaphore/releases/download/v${RELEASE}/semaphore_${RELEASE}_linux_amd64.deb +$STD dpkg -i semaphore_${RELEASE}_linux_amd64.deb + +SEM_HASH=$(openssl rand -base64 32) +SEM_ENCRYPTION=$(openssl rand -base64 32) +SEM_KEY=$(openssl rand -base64 32) +SEM_PW=$(openssl rand -base64 12) +cat </opt/semaphore/config.json +{ + "bolt": { + "host": "/opt/semaphore/semaphore_db.bolt" + }, + "tmp_path": "/opt/semaphore/tmp", + "cookie_hash": "${SEM_HASH}", + "cookie_encryption": "${SEM_ENCRYPTION}", + "access_key_encryption": "${SEM_KEY}" +} +EOF + +$STD semaphore user add --admin --login admin --email admin@helper-scripts.com --name Administrator --password ${SEM_PW} --config /opt/semaphore/config.json +echo "${SEM_PW}" >~/semaphore.creds +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +msg_ok "Setup Semaphore" + +msg_info "Creating Service" +cat </etc/systemd/system/semaphore.service +[Unit] +Description=Semaphore UI +Documentation=https://docs.semaphoreui.com/ +Wants=network-online.target +After=network-online.target + +[Service] +ExecStart=/usr/bin/semaphore server --config /opt/semaphore/config.json +Restart=always +RestartSec=10s + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable --now -q semaphore.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf semaphore_${RELEASE}_linux_amd64.deb +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/json/semaphore.json b/json/semaphore.json new file mode 100644 index 00000000..89433239 --- /dev/null +++ b/json/semaphore.json @@ -0,0 +1,41 @@ +{ + "name": "Semaphore", + "slug": "semaphore", + "categories": [], + "date_created": "2025-01-01", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://docs.semaphoreui.com/", + "website": "https://semaphoreui.com/", + "logo": "https://docs.semaphoreui.com/favicon.png?x=", + "description": "Semaphore UI is a modern web interface for managing popular DevOps tools", + "install_methods": [ + { + "type": "default", + "script": "ct/semaphore.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 4, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": "admin", + "password": null + }, + "notes": [ + { + "text": "This instance uses BoltDB", + "type": "info" + }, + { + "text": "Admin password: `cat ~/semaphore.creds`", + "type": "info" + } + ] +}