Standardiser les scripts créateurs de LXC (template, autologin, update) #16

Merged
Damien merged 10 commits from chore/standardize-lxc-scripts into main 2026-07-30 12:19:38 +00:00
2 changed files with 11 additions and 22 deletions
Showing only changes of commit d86848eb71 - Show all commits
+11 -11
View File
@@ -117,7 +117,7 @@ exec_in_lxc() {
local ctid="$1" local ctid="$1"
local mode="$2" # --install or --update local mode="$2" # --install or --update
pct exec "$ctid" -- sh -c "apk add --no-cache bash curl jq > /dev/null 2>&1" pct exec "$ctid" -- sh -c "apk add --no-cache bash curl jq ca-certificates > /dev/null 2>&1"
curl -fsSL "$SCRIPT_URL" \ curl -fsSL "$SCRIPT_URL" \
| pct exec "$ctid" -- env \ | pct exec "$ctid" -- env \
SCRIPT_URL="$SCRIPT_URL" \ SCRIPT_URL="$SCRIPT_URL" \
@@ -144,11 +144,7 @@ create_lxc() {
log_info "Auto-selected CTID: $CTID" log_info "Auto-selected CTID: $CTID"
fi fi
# Download template if needed ensure_template_present "$TEMPLATE"
if ! pveam list "$TEMPLATE_STORAGE" 2>/dev/null | grep -q "$TEMPLATE"; then
log_info "Downloading template $TEMPLATE..."
pveam download "$TEMPLATE_STORAGE" "$TEMPLATE"
fi
log_info "Creating LXC $CTID ($HOSTNAME_LXC)..." log_info "Creating LXC $CTID ($HOSTNAME_LXC)..."
pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" \ pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" \
@@ -396,12 +392,16 @@ main() {
else else
create_lxc create_lxc
fi fi
elif [[ -f /usr/local/bin/act_runner ]]; then
# act_runner exists — update mode
update_runner
else else
# Fresh LXC — install mode # Inside a container (no Proxmox tooling)
install_runner require_root
if [[ -f /usr/local/bin/act_runner ]]; then
# act_runner exists — update mode
update_runner
else
# Fresh LXC — install mode
install_runner
fi
fi fi
} }
-11
View File
@@ -237,17 +237,6 @@ configure_tailscale_proxy() {
# Proxmox-host helpers # Proxmox-host helpers
# ============================================================ # ============================================================
ensure_template_present() {
local tmpl="$1"
if ! pveam list "$TEMPLATE_STORAGE" 2>/dev/null | grep -q "$tmpl"; then
log_info "Downloading template ${tmpl} to storage ${TEMPLATE_STORAGE}..."
pveam update >/dev/null
pveam download "$TEMPLATE_STORAGE" "$tmpl"
else
log_info "Template ${tmpl} already present on ${TEMPLATE_STORAGE}."
fi
}
# Pick next available CTID if user did not provide one. # Pick next available CTID if user did not provide one.
allocate_ctid() { allocate_ctid() {
pvesh get /cluster/nextid 2>/dev/null \ pvesh get /cluster/nextid 2>/dev/null \