Make swapfile a default for every install, not just Asterisk droplets
Extracts the swapfile logic out of services/asterisk.sh (previously DigitalOcean-droplet-gated) into lib/common.sh's ensure_swapfile() — provider detection was never really the point, the actual condition that matters is "modest RAM, no swap yet," which applies just as much to a non-DO VPS running several Docker services at once as it did to a single-purpose droplet. - lib/common.sh: new ensure_swapfile(), same fallocate/mkswap/fstab/ swappiness logic as before, threshold raised from 2048MB to 4096MB (a 4GB box running a full service stack is exactly the case that motivated this change — the old threshold would have skipped it). - services/base.sh: calls it unconditionally so every install gets the same check regardless of which other services get chosen. - services/asterisk.sh: swapfile call is no longer gated behind IS_DO — calls the shared helper directly. Kept a standalone-mode stub (same pattern as this file's other stubbed helpers) so `sudo bash asterisk.sh` with no base.sh in the picture still gets it. Idempotent either way: a box that already has swap, or already got it from base.sh earlier in the same run, no-ops immediately. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBtExJcqxnokyZZKmphdug
This commit is contained in:
@@ -13,6 +13,7 @@ install_base() {
|
||||
echo "[DRY-RUN] Would install Docker CE + Compose plugin"
|
||||
echo "[DRY-RUN] Would detect an NVIDIA GPU and offer to install the driver"
|
||||
echo " + NVIDIA Container Toolkit (for GPU-accelerated Docker services)"
|
||||
echo "[DRY-RUN] Would add a swapfile if RAM <= 4096MB and none exists"
|
||||
echo "[DRY-RUN] Would install/configure openssh-server"
|
||||
echo "[DRY-RUN] Would offer SSH key import from GitHub/Launchpad"
|
||||
echo "[DRY-RUN] Would offer to disable SSH password auth"
|
||||
@@ -38,6 +39,9 @@ install_base() {
|
||||
# ── Docker ───────────────────────────────────────────────────────────────
|
||||
require_docker || log_warning "Docker install failed — will retry after base setup"
|
||||
|
||||
# ── Swapfile — default for every install, not just Asterisk droplets ────
|
||||
ensure_swapfile
|
||||
|
||||
# ── NVIDIA GPU (driver + container toolkit) ─────────────────────────────
|
||||
_base_setup_nvidia_gpu
|
||||
|
||||
|
||||
Reference in New Issue
Block a user