1. Prerequisites and least-privilege account
The command fails closed if required distribution-provided tools are missing. Install missing packages from your trusted operating-system repository before continuing.
set -euo pipefail
for required in curl jq flock systemctl systemd-analyze getent id install; do
command -v "$required" >/dev/null || {
echo "Missing required command: $required" >&2
exit 1
}
done
test -x /usr/sbin/nologin || {
echo "/usr/sbin/nologin is required" >&2
exit 1
}
if ! getent group bonynode-monitor >/dev/null; then
sudo groupadd --system bonynode-monitor
fi
if ! id -u bonynode-monitor >/dev/null 2>&1; then
sudo useradd --system --gid bonynode-monitor --home-dir /var/lib/bonynode-monitor --shell /usr/sbin/nologin bonynode-monitor
fi
test "$(id -gn bonynode-monitor)" = "bonynode-monitor" || {
echo "Existing bonynode-monitor user has an unexpected primary group" >&2
exit 1
}
sudo install -d -o root -g root -m 0755 /usr/local/libexec/bonynode
sudo install -d -o root -g root -m 0755 /etc/bonynode-monitor
sudo install -d -o bonynode-monitor -g bonynode-monitor -m 0750 /var/lib/bonynode-monitor/airchains-testnet