Add VPS step-1 installer for Rubix releases

- install-rubix.sh: apt update/upgrade, token prompt, download rubix zip into /home/www/callcenter
- Document clone/raw URLs for rubix-deploy; ignore downloaded zip artifacts
This commit is contained in:
Sinisa Madzar
2026-05-31 22:27:35 +02:00
commit 7060b5682c
3 changed files with 128 additions and 0 deletions
+99
View File
@@ -0,0 +1,99 @@
#!/bin/bash
# Step 1 on a new VPS: apt update/upgrade, token prompt, /home/www/callcenter, download rubix release.
#
# Publish: https://gitea.dialer.work/swissdatabase/rubix-deploy
# Clone: https://gitea.dialer.work/swissdatabase/rubix-deploy.git
#
# On the VPS:
# wget -O install-rubix.sh \
# https://gitea.dialer.work/swissdatabase/rubix-deploy/raw/branch/main/install-rubix.sh
# chmod +x install-rubix.sh
# sudo ./install-rubix.sh
set -euo pipefail
RUBIX_DEPLOY_REPO="https://gitea.dialer.work/swissdatabase/rubix-deploy"
RUBIX_DEPLOY_RAW="${RUBIX_DEPLOY_REPO}/raw/branch/main/install-rubix.sh"
GITEA_HOST="${GITEA_HOST:-gitea.dialer.work}"
GITEA_OWNER="${GITEA_OWNER:-swissdatabase}"
GITEA_REPO="${GITEA_REPO:-rubix}"
RUBIX_INSTALL_PATH="${RUBIX_INSTALL_PATH:-/home/www/callcenter}"
GITEA_TOKEN="${GITEA_TOKEN:-${GITEA_REGISTRY_PULL_TOKEN:-}}"
TAG="${1:-}"
APT_PACKAGES=(unzip wget curl python3 ca-certificates git rsync)
prepare_system() {
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run with sudo: sudo ./install-rubix.sh" >&2
exit 1
fi
if ! command -v apt-get >/dev/null 2>&1; then
echo "apt-get not found — install ${APT_PACKAGES[*]} manually." >&2
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
echo "[install-rubix] apt-get update ..."
apt-get update -y
if [[ "${SKIP_APT_UPGRADE:-}" != "1" ]]; then
echo "[install-rubix] apt-get upgrade ..."
apt-get upgrade -y
fi
echo "[install-rubix] apt-get install ${APT_PACKAGES[*]} ..."
apt-get install -y "${APT_PACKAGES[@]}"
}
prompt_token() {
if [[ -n "${GITEA_TOKEN}" ]]; then
return 0
fi
echo "Gitea token (private rubix repo — same as registry / GITEA_REGISTRY_PULL_TOKEN):"
read -r -s GITEA_TOKEN
echo ""
if [[ -z "${GITEA_TOKEN}" ]]; then
echo "Token is required." >&2
exit 1
fi
}
prepare_system
prompt_token
echo "[install-rubix] install path: ${RUBIX_INSTALL_PATH}"
mkdir -p "${RUBIX_INSTALL_PATH}"
cd "${RUBIX_INSTALL_PATH}"
if [[ -z "${TAG}" ]]; then
echo "[install-rubix] fetching latest release tag ..."
wget -q --header="Authorization: token ${GITEA_TOKEN}" \
-O /tmp/rubix-release.json \
"https://${GITEA_HOST}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases/latest"
TAG="$(python3 -c 'import json; print(json.load(open("/tmp/rubix-release.json"))["tag_name"])')"
rm -f /tmp/rubix-release.json
fi
ZIP_URL="https://${GITEA_HOST}/${GITEA_OWNER}/${GITEA_REPO}/archive/${TAG}.zip"
echo "[install-rubix] downloading ${TAG} ..."
wget --header="Authorization: token ${GITEA_TOKEN}" -O rubix.zip "${ZIP_URL}"
unzip -oq rubix.zip
TOP="$(find . -maxdepth 1 -type d ! -name '.' | head -1)"
if [[ -n "${TOP}" ]]; then
echo "[install-rubix] flatten ${TOP}/ into ${RUBIX_INSTALL_PATH}"
shopt -s dotglob
mv "${TOP}"/* .
rmdir "${TOP}"
shopt -u dotglob
fi
rm -f rubix.zip
echo ""
echo "[install-rubix] done — ${RUBIX_INSTALL_PATH} (${TAG})"
echo "[install-rubix] next (see rubix README step 2):"
echo " cd ${RUBIX_INSTALL_PATH}/deploy/docker"
echo " cp .env.example .env"
echo " nano .env"
echo " sudo ./up.sh"