Rename log-file-path -> log-directory (maps to DECNET_LOG_DIRECTORY). Bundle
now ships three systemd units rendered with agent_name/master_host and installs
them into /etc/systemd/system/. Bootstrap replaces direct 'decnet X --daemon'
calls with systemctl enable --now. Each unit pins DECNET_SYSTEM_LOGS so agent,
forwarder, and deckies logs land at decnet.{agent,forwarder}.log and decnet.log
under /var/log/decnet.
68 lines
2.6 KiB
Django/Jinja
68 lines
2.6 KiB
Django/Jinja
#!/usr/bin/env bash
|
|
# DECNET bootstrap installer for agent {{ agent_name }} -> master {{ master_host }}.
|
|
# Fetches the code+certs payload, installs, and starts the agent daemon.
|
|
# Generated by the master at {{ generated_at }}. Expires {{ expires_at }}.
|
|
set -euo pipefail
|
|
|
|
[[ $EUID -eq 0 ]] || { echo "decnet-install: must run as root (use sudo)"; exit 1; }
|
|
for bin in python3 curl tar systemctl; do
|
|
command -v "$bin" >/dev/null || { echo "decnet-install: $bin required"; exit 1; }
|
|
done
|
|
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
echo "[DECNET] fetching payload..."
|
|
curl -fsSL "{{ tarball_url }}" | tar -xz -C "$WORK"
|
|
|
|
INSTALL_DIR=/opt/decnet
|
|
mkdir -p "$INSTALL_DIR"
|
|
cp -a "$WORK/." "$INSTALL_DIR/"
|
|
cd "$INSTALL_DIR"
|
|
|
|
echo "[DECNET] building venv..."
|
|
python3 -m venv .venv
|
|
.venv/bin/pip install -q --upgrade pip
|
|
.venv/bin/pip install -q -e .
|
|
|
|
install -Dm0644 etc/decnet/decnet.ini /etc/decnet/decnet.ini
|
|
[[ -f services.ini ]] && install -Dm0644 services.ini /etc/decnet/services.ini
|
|
|
|
# Log directory the baked-in INI points at — must exist before `decnet` imports config.
|
|
install -d -m0755 /var/log/decnet
|
|
|
|
# Certs live under /etc/decnet/ (root-owned, 0600 keys) — this is a root
|
|
# daemon's data, not a user's. The baked INI's `agent-dir`/`updater-dir`
|
|
# point at these paths.
|
|
for f in ca.crt worker.crt worker.key; do
|
|
install -Dm0600 -o root -g root \
|
|
"home/.decnet/agent/$f" "/etc/decnet/agent/$f"
|
|
done
|
|
chmod 0755 /etc/decnet/agent
|
|
|
|
WITH_UPDATER="{{ with_updater }}"
|
|
if [[ "$WITH_UPDATER" == "true" && -d home/.decnet/updater ]]; then
|
|
for f in ca.crt updater.crt updater.key; do
|
|
install -Dm0600 -o root -g root \
|
|
"home/.decnet/updater/$f" "/etc/decnet/updater/$f"
|
|
done
|
|
chmod 0755 /etc/decnet/updater
|
|
fi
|
|
|
|
# Guarantee the pip-installed entrypoint is executable (some setuptools+editable
|
|
# combos drop it with mode 0644) and expose it on PATH.
|
|
chmod 0755 "$INSTALL_DIR/.venv/bin/decnet"
|
|
ln -sf "$INSTALL_DIR/.venv/bin/decnet" /usr/local/bin/decnet
|
|
|
|
echo "[DECNET] installing systemd units..."
|
|
install -Dm0644 etc/systemd/system/decnet-agent.service /etc/systemd/system/decnet-agent.service
|
|
install -Dm0644 etc/systemd/system/decnet-forwarder.service /etc/systemd/system/decnet-forwarder.service
|
|
install -Dm0644 etc/systemd/system/decnet-engine.service /etc/systemd/system/decnet-engine.service
|
|
systemctl daemon-reload
|
|
systemctl enable --now decnet-agent.service decnet-forwarder.service
|
|
|
|
if [[ "$WITH_UPDATER" == "true" ]]; then
|
|
/usr/local/bin/decnet updater --daemon
|
|
fi
|
|
echo "[DECNET] agent {{ agent_name }} enrolled -> {{ master_host }}. Units: decnet-agent, decnet-forwarder active."
|