mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-27 04:28:05 +00:00
* Fix Semaphore BoltDB migration * Update ct/semaphore.sh Co-authored-by: pavlojs <63199635+pavlojs@users.noreply.github.com> --------- Co-authored-by: pavlojs <63199635+pavlojs@users.noreply.github.com>
109 lines
4.0 KiB
Bash
109 lines
4.0 KiB
Bash
#!/usr/bin/env bash
|
|
_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main"
|
|
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
|
|
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
|
# Author: kristocopani
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://semaphoreui.com/ | Github: https://github.com/semaphoreui/semaphore
|
|
|
|
APP="Semaphore"
|
|
var_tags="${var_tags:-dev_ops}"
|
|
var_cpu="${var_cpu:-2}"
|
|
var_ram="${var_ram:-2048}"
|
|
var_disk="${var_disk:-4}"
|
|
var_os="${var_os:-ubuntu}"
|
|
var_version="${var_version:-24.04}"
|
|
var_arm64="${var_arm64:-yes}"
|
|
var_unprivileged="${var_unprivileged:-1}"
|
|
|
|
header_info "$APP"
|
|
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
|
|
|
|
# Outside the release check on purpose: a container left behind by the old
|
|
# order already carries the newest version, so the check would skip it.
|
|
local migrated=0
|
|
if [[ -f /opt/semaphore/semaphore_db.bolt ]]; then
|
|
msg_warn "WARNING: Due to bugs with BoltDB database, update script will move your application"
|
|
msg_warn "to use SQLite database instead. Make sure you have a backup of your data!"
|
|
echo ""
|
|
read -r -p "${TAB3}Do you want to continue? (y/N): " CONFIRM
|
|
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
msg_info "Stopping Service"
|
|
systemctl stop semaphore
|
|
msg_ok "Stopped Service"
|
|
|
|
msg_info "Moving from BoltDB to SQLite"
|
|
sed -i \
|
|
-e 's|"bolt": {|"sqlite": {|' \
|
|
-e 's|/semaphore_db.bolt"|/database.sqlite"|' \
|
|
-e '/semaphore_db.bolt/d' \
|
|
-e '/"dialect"/d' \
|
|
-e '/^ },$/a\ "dialect": "sqlite",' \
|
|
/opt/semaphore/config.json
|
|
msg_ok "Moved from BoltDB to SQLite"
|
|
|
|
# 2.19 dropped BoltDB along with the migration flag, so this has to run on
|
|
# the last release that still has it.
|
|
fetch_and_deploy_gh_release "semaphore" "semaphoreui/semaphore" "binary" "v2.18.30" "/opt/semaphore" "semaphore_*_linux_$(arch_resolve).deb"
|
|
|
|
msg_info "Migrating BoltDB to SQLite"
|
|
if [[ -f /opt/semaphore/database.sqlite ]]; then
|
|
mkdir -p /opt/semaphore/sqlite.bak
|
|
mv /opt/semaphore/database.sqlite* /opt/semaphore/sqlite.bak/
|
|
fi
|
|
sed '/"dialect": "sqlite",/a\ "apps": {"ansible": {}, "terraform": {}, "tofu": {}, "terragrunt": {}, "bash": {}, "powershell": {}, "python": {}, "pulumi": {}},' \
|
|
/opt/semaphore/config.json >/opt/semaphore/migrate.json
|
|
if ! $STD semaphore migrate --from-boltdb /opt/semaphore/semaphore_db.bolt --config /opt/semaphore/migrate.json; then
|
|
msg_error "Migration failed - semaphore_db.bolt was kept, run the update again to retry"
|
|
exit 1
|
|
fi
|
|
rm -f /opt/semaphore/migrate.json
|
|
mv /opt/semaphore/semaphore_db.bolt /opt/semaphore/semaphore_db.bolt.bak
|
|
msg_ok "Migrated BoltDB to SQLite"
|
|
migrated=1
|
|
fi
|
|
|
|
if check_for_gh_release "semaphore" "semaphoreui/semaphore"; then
|
|
msg_info "Stopping Service"
|
|
systemctl stop semaphore
|
|
msg_ok "Stopped Service"
|
|
|
|
fetch_and_deploy_gh_release "semaphore" "semaphoreui/semaphore" "binary" "latest" "/opt/semaphore" "semaphore_*_linux_$(arch_resolve).deb"
|
|
|
|
msg_info "Starting Service"
|
|
systemctl start semaphore
|
|
msg_ok "Started Service"
|
|
msg_ok "Updated successfully!"
|
|
elif ((migrated)); then
|
|
msg_info "Starting Service"
|
|
systemctl start semaphore
|
|
msg_ok "Started Service"
|
|
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 "${GATEWAY}${BGN}http://${IP}:3000${CL}"
|