feat: add domain and install scripts for apps

This commit is contained in:
lolwierd
2026-03-27 19:32:47 +05:30
parent 442ae83280
commit 9b93d6898b
26 changed files with 900 additions and 13 deletions

49
plausible/domain.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
APP_NAME="plausible"
APP_DIR="/var/excloud/apps"
APP_UPSTREAM_PORT="${EXC_APP_UPSTREAM_PORT:-8000}"
DOMAIN="${1}"
if [ -z "${DOMAIN}" ]; then
echo "Error: URL argument is required. Example:" >&2
echo "domain.sh sub.example.com" >&2
exit 1
fi
PLAUSIBLE_DIR="${APP_DIR}/${APP_NAME}"
ENV_FILE="${PLAUSIBLE_DIR}/.env"
OVERRIDE_FILE="${PLAUSIBLE_DIR}/compose.override.yml"
SECRET_KEY_FILE="${PLAUSIBLE_DIR}/.secret_key_base"
if [ ! -f "${SECRET_KEY_FILE}" ]; then
openssl rand -base64 48 > "${SECRET_KEY_FILE}"
fi
SECRET_KEY_BASE="$(tr -d '\n' < "${SECRET_KEY_FILE}")"
cat > "${ENV_FILE}" <<EOF
BASE_URL=https://${DOMAIN}
SECRET_KEY_BASE=${SECRET_KEY_BASE}
HTTP_PORT=80
EOF
cat > "${OVERRIDE_FILE}" <<EOF
services:
plausible:
ports:
- "127.0.0.1:${APP_UPSTREAM_PORT}:80"
EOF
cat > /etc/caddy/Caddyfile <<EOF
https://${DOMAIN} {
reverse_proxy 127.0.0.1:${APP_UPSTREAM_PORT}
}
EOF
echo "Caddyfile updated"
systemctl enable caddy
docker compose -f "${PLAUSIBLE_DIR}/compose.yml" -f "${OVERRIDE_FILE}" up -d
systemctl reload caddy

29
plausible/install.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
APP_NAME="plausible"
APP_DIR="/var/excloud/apps"
SCRIPT_DIR="/var/excloud/scripts"
APP_UPSTREAM_PORT="${EXC_APP_UPSTREAM_PORT:-8000}"
REPO_URL="https://github.com/plausible/community-edition.git"
REPO_REF="v3.2.0"
mkdir -p "${APP_DIR}"
mkdir -p "${SCRIPT_DIR}"
DOMAIN="${1}"
if [ -z "${DOMAIN}" ]; then
echo "Error: URL argument is required. Example:" >&2
echo "install.sh sub.example.com" >&2
exit 1
fi
PLAUSIBLE_DIR="${APP_DIR}/${APP_NAME}"
apt-get install -y caddy git openssl
if [ ! -d "${PLAUSIBLE_DIR}/.git" ]; then
git clone -b "${REPO_REF}" --single-branch "${REPO_URL}" "${PLAUSIBLE_DIR}"
fi
bash "${SCRIPT_DIR}/domain.sh" "${DOMAIN}"