Use GH release deploy for SurrealDB

Replace the old curl-based installer and interactive update menu with unified GitHub release deployment helpers. ct/surrealdb.sh now checks for a new surrealdb release via check_for_gh_release, stops the service, uses fetch_and_deploy_gh_release to deploy the prebuilt binary to /usr/local/bin, sets exec permissions, and restarts the service (also use ${APP} in an error message). The previous menu-driven update and storage-switch options (memory vs rocksdb) were removed. install/surrealdb-install.sh now skips the removed mc dependency install, uses fetch_and_deploy_gh_release instead of the install.surrealdb.com script, makes the binary executable, and no longer writes a release-version file. Overall moves to a consistent release fetch/deploy flow and simplifies update/install logic.
This commit is contained in:
Poulette
2026-02-26 23:33:34 +01:00
parent c90a7dd972
commit 810902fce1
2 changed files with 14 additions and 54 deletions

View File

@@ -26,56 +26,23 @@ function update_script() {
check_container_resources check_container_resources
if [[ ! -f /usr/local/bin/surreal ]]; then if [[ ! -f /usr/local/bin/surreal ]]; then
msg_error "No SurrealDB Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} Management" \ if check_for_gh_release "surrealdb" "surrealdb/surrealdb"; then
--menu "Select an option:" 12 58 3 \ msg_info "Stopping Service"
"1" "Update SurrealDB" \ systemctl stop surrealdb
"2" "Switch to Memory Storage" \ msg_ok "Stopped Service"
"3" "Switch to Disk Storage (RocksDB)" \
3>&1 1>&2 2>&3) || exit
case "$UPD" in fetch_and_deploy_gh_release "surrealdb" "surrealdb/surrealdb" "prebuild" "latest" "/usr/local/bin" "surreal-v*.linux-amd64.tgz"
1) chmod +x /usr/local/bin/surreal
RELEASE=$(curl -fsSL https://api.github.com/repos/surrealdb/surrealdb/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_info "Stopping ${APP}"
systemctl stop surrealdb
msg_ok "Stopped ${APP}"
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Starting Service"
$STD bash <(curl -sSf https://install.surrealdb.com) systemctl start surrealdb
echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Started Service"
msg_ok "Updated ${APP} to v${RELEASE}" msg_ok "Updated successfully!"
fi
msg_info "Starting ${APP}"
systemctl start surrealdb
msg_ok "Started ${APP}"
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
;;
2)
msg_info "Switching to Memory Storage"
sed -i 's|^ExecStart=.*|ExecStart=/usr/local/bin/surreal start --bind 0.0.0.0:8000 --user root --pass ${SURREALDB_PASS} memory|' /etc/systemd/system/surrealdb.service
systemctl daemon-reload
systemctl restart surrealdb
msg_ok "Switched to Memory Storage"
msg_ok "Warning: Data will not persist across restarts"
;;
3)
msg_info "Switching to Disk Storage (RocksDB)"
mkdir -p /opt/surrealdb/data
sed -i 's|^ExecStart=.*|ExecStart=/usr/local/bin/surreal start --bind 0.0.0.0:8000 --user root --pass ${SURREALDB_PASS} rocksdb:///opt/surrealdb/data/srdb.db|' /etc/systemd/system/surrealdb.service
systemctl daemon-reload
systemctl restart surrealdb
msg_ok "Switched to Disk Storage (RocksDB)"
;;
esac
exit exit
} }

View File

@@ -13,13 +13,9 @@ setting_up_container
network_check network_check
update_os update_os
msg_info "Installing Dependencies"
$STD apt install -y \
mc
msg_ok "Installed Dependencies"
msg_info "Installing SurrealDB" msg_info "Installing SurrealDB"
$STD bash <(curl -sSf https://install.surrealdb.com) fetch_and_deploy_gh_release "surrealdb" "surrealdb/surrealdb" "prebuild" "latest" "/usr/local/bin" "surreal-v*.linux-amd64.tgz"
chmod +x /usr/local/bin/surreal
msg_ok "Installed SurrealDB" msg_ok "Installed SurrealDB"
msg_info "Configuring SurrealDB" msg_info "Configuring SurrealDB"
@@ -54,9 +50,6 @@ EOF
systemctl enable -q --now surrealdb systemctl enable -q --now surrealdb
msg_ok "Created Service" msg_ok "Created Service"
RELEASE=$(curl -fsSL https://api.github.com/repos/surrealdb/surrealdb/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
echo "${RELEASE}" >/opt/SurrealDB_version.txt
motd_ssh motd_ssh
customize customize
cleanup_lxc cleanup_lxc