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:
@@ -0,0 +1,3 @@
|
|||||||
|
*.zip
|
||||||
|
release.json
|
||||||
|
rubix.zip
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# rubix-deploy
|
||||||
|
|
||||||
|
Bootstrap **step 1** for new Rubix servers (install app from Gitea release).
|
||||||
|
|
||||||
|
**Repository:** https://gitea.dialer.work/swissdatabase/rubix-deploy
|
||||||
|
**Clone:** `git clone https://gitea.dialer.work/swissdatabase/rubix-deploy.git`
|
||||||
|
|
||||||
|
## On a new VPS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
If the repo is **Internal** (not Public), use a token to fetch the script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget --header="Authorization: token <GITEA_TOKEN>" -O install-rubix.sh \
|
||||||
|
https://gitea.dialer.work/swissdatabase/rubix-deploy/raw/branch/main/install-rubix.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script: `apt update` + `apt upgrade`, installs tools, asks for token, creates `/home/www/callcenter`, downloads **rubix**.
|
||||||
|
|
||||||
|
**Step 2+** (`.env`, Docker, `up.sh`): [swissdatabase/rubix](https://gitea.dialer.work/swissdatabase/rubix) README.
|
||||||
Executable
+99
@@ -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"
|
||||||
Reference in New Issue
Block a user