LXC: optional root password/SSH keys, console banner with address and login hint

This commit is contained in:
zyphlar
2026-11-02 01:47:09 -08:00
parent df48ae7f6f
commit 01266e9d28
2 changed files with 31 additions and 1 deletions
+6 -1
View File
@@ -30,7 +30,12 @@ It downloads the Debian 13 template if needed and creates an unprivileged contai
It then installs everything and prints the container's address. Optional settings: `CTID`, `CT_HOSTNAME`, `STORAGE` It then installs everything and prints the container's address. Optional settings: `CTID`, `CT_HOSTNAME`, `STORAGE`
(`local-lvm`), `TEMPLATE_STORAGE` (`local`), `BRIDGE` (`vmbr0`), `IP` (`dhcp` or `192.168.1.50/24`), `GATEWAY`, (`local-lvm`), `TEMPLATE_STORAGE` (`local`), `BRIDGE` (`vmbr0`), `IP` (`dhcp` or `192.168.1.50/24`), `GATEWAY`,
`VLAN`, `CORES` (1), `MEMORY` (512 MB), `DISK` (4 GB), `PORT` (3000), `SITE_NAME`, `DIGEST_HOUR`, `TZ` (defaults to `VLAN`, `CORES` (1), `MEMORY` (512 MB), `DISK` (4 GB), `PORT` (3000), `SITE_NAME`, `DIGEST_HOUR`, `TZ` (defaults to
the host's), and `SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`/`SMTP_SECURE` instead of `SMTP_URL`. the host's), `ROOT_PASSWORD`, `SSH_PUBLIC_KEYS` (a file of keys for root), and
`SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`/`SMTP_SECURE` instead of `SMTP_URL`.
`ADMIN_PASSWORD` is only for the web `/admin` page, not the container's root account. To log in at the Proxmox
console, set `ROOT_PASSWORD`. Without it, get a shell with `pct enter <ctid>` on the host. The console's login screen
shows the container's address and the `/admin` URL.
Then point your reverse proxy (HTTPS) at the container's port 3000, open `/admin`, and sign in. Then point your reverse proxy (HTTPS) at the container's port 3000, open `/admin`, and sign in.
+25
View File
@@ -11,6 +11,9 @@
# TEMPLATE_STORAGE [local] BRIDGE [vmbr0] IP [dhcp, or e.g. 192.168.1.50/24] # TEMPLATE_STORAGE [local] BRIDGE [vmbr0] IP [dhcp, or e.g. 192.168.1.50/24]
# GATEWAY [] VLAN [] CORES [1] MEMORY [512] DISK [4] PORT [3000] # GATEWAY [] VLAN [] CORES [1] MEMORY [512] DISK [4] PORT [3000]
# SMTP_URL MAIL_FROM SITE_NAME DIGEST_HOUR TZ [host's timezone] # SMTP_URL MAIL_FROM SITE_NAME DIGEST_HOUR TZ [host's timezone]
# ROOT_PASSWORD [] SSH_PUBLIC_KEYS [] (a file of public keys for root)
# Without ROOT_PASSWORD, root can't log in at the Proxmox console; use
# `pct enter <ctid>` on the host instead. ADMIN_PASSWORD is only for /admin.
set -euo pipefail set -euo pipefail
die () { echo "error: $*" >&2; exit 1; } die () { echo "error: $*" >&2; exit 1; }
@@ -42,6 +45,11 @@ TZ=${TZ:-$(cat /etc/timezone 2>/dev/null || timedatectl show -p Timezone --value
net="name=eth0,bridge=$BRIDGE,ip=$IP" net="name=eth0,bridge=$BRIDGE,ip=$IP"
[ -n "${GATEWAY:-}" ] && net="$net,gw=$GATEWAY" [ -n "${GATEWAY:-}" ] && net="$net,gw=$GATEWAY"
[ -n "${VLAN:-}" ] && net="$net,tag=$VLAN" [ -n "${VLAN:-}" ] && net="$net,tag=$VLAN"
ssh_args=()
if [ -n "${SSH_PUBLIC_KEYS:-}" ]; then
[ -f "$SSH_PUBLIC_KEYS" ] || die "SSH_PUBLIC_KEYS must be a file of public keys"
ssh_args=(--ssh-public-keys "$SSH_PUBLIC_KEYS")
fi
# ----- Debian 13 template ---------------------------------------------------- # ----- Debian 13 template ----------------------------------------------------
log "Finding the Debian 13 template" log "Finding the Debian 13 template"
@@ -64,9 +72,25 @@ pct create "$CTID" "$TEMPLATE_STORAGE:vztmpl/$template" \
--net0 "$net" \ --net0 "$net" \
--timezone "$TZ" \ --timezone "$TZ" \
--onboot 1 \ --onboot 1 \
"${ssh_args[@]}" \
--description "Immich Magic Proxy: invite-only sharing for Immich" --description "Immich Magic Proxy: invite-only sharing for Immich"
pct start "$CTID" pct start "$CTID"
# Root password goes in over stdin, so it never shows in the process list
if [ -n "${ROOT_PASSWORD:-}" ]; then
printf 'root:%s\n' "$ROOT_PASSWORD" | pct exec "$CTID" -- chpasswd
fi
# Console login banner. agetty fills in \4{eth0} with the current IPv4
# address, and redraws it when the address changes (e.g. DHCP renewal).
{
printf 'Immich Magic Proxy (Debian \\r)\n\n'
printf ' Web: http://\\4{eth0}:%s Admin: %s/admin\n' "$PORT" "$PUBLIC_BASE_URL"
printf ' Login: root at this console needs ROOT_PASSWORD set at install;\n'
printf ' otherwise run "pct enter %s" on the Proxmox host.\n' "$CTID"
printf ' The /admin password is not the root password.\n\n'
} | pct exec "$CTID" -- sh -c 'cat > /etc/issue'
log "Waiting for the network" log "Waiting for the network"
for _ in $(seq 1 60); do for _ in $(seq 1 60); do
pct exec "$CTID" -- sh -c 'getent hosts deb.debian.org >/dev/null' && break pct exec "$CTID" -- sh -c 'getent hosts deb.debian.org >/dev/null' && break
@@ -126,6 +150,7 @@ Immich Magic Proxy is running in container $CTID at http://$address:$PORT
Next: Next:
1. Point your reverse proxy for $PUBLIC_BASE_URL at http://$address:$PORT 1. Point your reverse proxy for $PUBLIC_BASE_URL at http://$address:$PORT
2. Open $PUBLIC_BASE_URL/admin and sign in with ADMIN_PASSWORD 2. Open $PUBLIC_BASE_URL/admin and sign in with ADMIN_PASSWORD
Shell: pct enter $CTID (the console login needs ROOT_PASSWORD; /admin uses ADMIN_PASSWORD)
Settings: pct exec $CTID -- nano /etc/immich-magic-proxy/env (then: systemctl restart immich-magic-proxy) Settings: pct exec $CTID -- nano /etc/immich-magic-proxy/env (then: systemctl restart immich-magic-proxy)
Logs: pct exec $CTID -- journalctl -u immich-magic-proxy -f Logs: pct exec $CTID -- journalctl -u immich-magic-proxy -f
Upgrade: pct push $CTID <new tarball> /root/release.tar.gz && pct push $CTID install.sh /root/install.sh --perms 0755 && Upgrade: pct push $CTID <new tarball> /root/release.tar.gz && pct push $CTID install.sh /root/install.sh --perms 0755 &&