ProxmoxVE/install/semaphore-install.sh

88 lines
2.4 KiB
Bash
Raw Normal View History

2024-11-30 00:02:06 +00:00
#!/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 \
2024-12-26 12:39:17 +00:00
curl \
mc \
git \
gpg \
sudo
2024-11-30 00:02:06 +00:00
wget -qO- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | gpg --dearmour >/usr/share/keyrings/ansible-archive-keyring.gpg
2024-12-26 12:39:17 +00:00
cat <<EOF >/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
2024-12-26 12:04:48 +00:00
$STD apt install -y ansible
2024-11-30 00:02:06 +00:00
msg_ok "Installed Dependencies"
2024-12-26 12:04:48 +00:00
msg_info "Setup Semaphore"
2024-11-30 00:02:06 +00:00
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
2024-12-26 12:39:17 +00:00
$STD dpkg -i semaphore_${RELEASE}_linux_amd64.deb
2024-11-30 00:02:06 +00:00
2024-12-26 12:04:48 +00:00
SEM_HASH=$(openssl rand -base64 32)
SEM_ENCRYPTION=$(openssl rand -base64 32)
SEM_KEY=$(openssl rand -base64 32)
2024-12-26 12:17:00 +00:00
SEM_PW=$(openssl rand -base64 12)
2024-11-30 00:02:06 +00:00
cat <<EOF >/opt/semaphore/config.json
{
"bolt": {
"host": "/opt/semaphore/semaphore_db.bolt"
},
"tmp_path": "/opt/semaphore/tmp",
2024-12-26 12:04:48 +00:00
"cookie_hash": "${SEM_HASH}",
"cookie_encryption": "${SEM_ENCRYPTION}",
"access_key_encryption": "${SEM_KEY}"
2024-11-30 00:02:06 +00:00
}
EOF
2024-12-26 12:04:48 +00:00
$STD semaphore user add --admin --login admin --email admin@helper-scripts.com --name Administrator --password ${SEM_PW} --config /opt/semaphore/config.json
2024-12-26 12:17:00 +00:00
echo "${SEM_PW}" >~/semaphore.creds
2024-11-30 00:02:06 +00:00
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
2024-12-26 12:04:48 +00:00
msg_ok "Setup Semaphore"
2024-11-30 00:02:06 +00:00
msg_info "Creating Service"
cat <<EOF >/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"
2024-12-26 12:39:17 +00:00
rm -rf semaphore_${RELEASE}_linux_amd64.deb
2024-11-30 00:02:06 +00:00
$STD apt-get -y autoremove
$STD apt-get -y autoclean
2024-12-26 12:39:17 +00:00
msg_ok "Cleaned"