feat: Add SurrealDB
Added scripts for SurrealDB, a multi-modal database
This commit is contained in:
89
ct/surrealdb.sh
Normal file
89
ct/surrealdb.sh
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main}"
|
||||||
|
source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func")
|
||||||
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
|
# Author: PouletteMC
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://surrealdb.com
|
||||||
|
|
||||||
|
APP="SurrealDB"
|
||||||
|
var_tags="${var_tags:-database;nosql}"
|
||||||
|
var_cpu="${var_cpu:-2}"
|
||||||
|
var_ram="${var_ram:-1024}"
|
||||||
|
var_disk="${var_disk:-4}"
|
||||||
|
var_os="${var_os:-debian}"
|
||||||
|
var_version="${var_version:-13}"
|
||||||
|
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 /usr/local/bin/surreal ]]; then
|
||||||
|
msg_error "No ${APP} Installation Found!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} Management" \
|
||||||
|
--menu "Select an option:" 12 58 3 \
|
||||||
|
"1" "Update SurrealDB" \
|
||||||
|
"2" "Switch to Memory Storage" \
|
||||||
|
"3" "Switch to Disk Storage (RocksDB)" \
|
||||||
|
3>&1 1>&2 2>&3) || exit
|
||||||
|
|
||||||
|
case "$UPD" in
|
||||||
|
1)
|
||||||
|
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}"
|
||||||
|
$STD bash <(curl -sSf https://install.surrealdb.com)
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
|
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||||
|
|
||||||
|
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 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 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
|
||||||
|
}
|
||||||
|
|
||||||
|
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}:8000${CL}"
|
||||||
44
frontend/public/json/surrealdb.json
Normal file
44
frontend/public/json/surrealdb.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "SurrealDB",
|
||||||
|
"slug": "surrealdb",
|
||||||
|
"categories": [
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"date_created": "2026-02-26",
|
||||||
|
"type": "ct",
|
||||||
|
"updateable": true,
|
||||||
|
"privileged": false,
|
||||||
|
"interface_port": 8000,
|
||||||
|
"documentation": "https://surrealdb.com/docs",
|
||||||
|
"website": "https://surrealdb.com/",
|
||||||
|
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/surrealdb.webp",
|
||||||
|
"config_path": "/opt/surrealdb/.env",
|
||||||
|
"description": "SurrealDB is a multi-model database that combines the power of document, graph, and relational databases into a single platform, offering real-time queries, built-in permissions, and a simplified backend stack.",
|
||||||
|
"install_methods": [
|
||||||
|
{
|
||||||
|
"type": "default",
|
||||||
|
"script": "ct/surrealdb.sh",
|
||||||
|
"resources": {
|
||||||
|
"cpu": 2,
|
||||||
|
"ram": 1024,
|
||||||
|
"hdd": 4,
|
||||||
|
"os": "debian",
|
||||||
|
"version": "13"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default_credentials": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null
|
||||||
|
},
|
||||||
|
"notes": [
|
||||||
|
{
|
||||||
|
"text": "SurrealDB web interface is available on port 8000.",
|
||||||
|
"type": "info"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Default credentials are saved in ~/surrealdb.creds.",
|
||||||
|
"type": "info"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
64
install/surrealdb-install.sh
Normal file
64
install/surrealdb-install.sh
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
|
# Author: PouletteMC
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://surrealdb.com
|
||||||
|
|
||||||
|
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 \
|
||||||
|
sudo \
|
||||||
|
mc
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Installing SurrealDB"
|
||||||
|
$STD bash <(curl -sSf https://install.surrealdb.com)
|
||||||
|
msg_ok "Installed SurrealDB"
|
||||||
|
|
||||||
|
msg_info "Configuring SurrealDB"
|
||||||
|
mkdir -p /opt/surrealdb/data
|
||||||
|
SURREALDB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||||
|
cat <<EOF >/opt/surrealdb/.env
|
||||||
|
SURREALDB_PASS=${SURREALDB_PASS}
|
||||||
|
EOF
|
||||||
|
{
|
||||||
|
echo "SurrealDB Credentials"
|
||||||
|
echo "Username: root"
|
||||||
|
echo "Password: ${SURREALDB_PASS}"
|
||||||
|
} >>~/surrealdb.creds
|
||||||
|
msg_ok "Configured SurrealDB"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/surrealdb.service
|
||||||
|
[Unit]
|
||||||
|
Description=SurrealDB Server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
EnvironmentFile=/opt/surrealdb/.env
|
||||||
|
ExecStart=/usr/local/bin/surreal start --bind 0.0.0.0:8000 --user root --pass \${SURREALDB_PASS} rocksdb:///opt/surrealdb/data/srdb.db
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now surrealdb
|
||||||
|
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
|
||||||
|
customize
|
||||||
|
cleanup_lxc
|
||||||
Reference in New Issue
Block a user