From 7343501b25701497c95ef5d52cd0f0539e8cb031 Mon Sep 17 00:00:00 2001 From: "l.kirchner" Date: Thu, 21 May 2026 23:05:38 +0200 Subject: [PATCH] Add docs/adding-a-script.md --- docs/adding-a-script.md | 118 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 docs/adding-a-script.md diff --git a/docs/adding-a-script.md b/docs/adding-a-script.md new file mode 100644 index 0000000..1a6ea39 --- /dev/null +++ b/docs/adding-a-script.md @@ -0,0 +1,118 @@ +# Adding a new script + +Two files per app, both sourcing the shared libs at runtime. + +## 1. `install/-install.sh` — runs inside the LXC + +```bash +#!/usr/bin/env bash +set -euo pipefail + +APP="myapp" +LIB_URL="${LIB_URL:-https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/lib}" +source <(curl -fsSL "$LIB_URL/install.func") + +[[ "$EUID" -eq 0 ]] || { msg_err "Must run as root"; exit 1; } + +setup_base_apt git some-package # base packages + extras +create_system_user myapp /opt/myapp + +# ... app-specific install ... + +write_systemd_unit myapp "$(cat <.sh` — runs on the Proxmox host + +```bash +#!/usr/bin/env bash +set -euo pipefail + +APP="myapp" +APP_DESCRIPTION="short tagline" +APP_PORT="8080" + +LIB_URL="${LIB_URL:-https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/lib}" +INSTALL_SCRIPT_URL="${INSTALL_SCRIPT_URL:-https://gitea.luki-net.org/luki-net/proxmox-scripts/raw/branch/main/install/myapp-install.sh}" + +# App-specific defaults +DEFAULT_HOSTNAME="myapp" +DEFAULT_DISK="10" +DEFAULT_CORES="2" +DEFAULT_RAM="1024" + +source <(curl -fsSL "$LIB_URL/build.func") + +# Override the default summary printer with whatever the app needs. +print_app_summary() { + cat <.credentials` (chmod 600). The host-side `print_app_summary` can `pct exec` to read them back. +- **Env-driven non-interactive use**: + ```bash + CTID=200 HOSTNAME=myapp DISK_SIZE=30 RAM=4096 IPCFG=dhcp \ + bash -c "$(curl -fsSL .../ct/myapp.sh)" + ``` +- **Local testing**: set `LIB_URL` to your fork's URL or a feature branch to test lib changes without touching `main`.