27 lines
1.0 KiB
Bash
Executable File
27 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BIN="$ROOT/target/release/rustbox"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "error: run as root (sudo ./scripts/install-systemd.sh)" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -x "$BIN" ]; then
|
|
echo "error: $BIN not found; run ./scripts/build-release.sh first" >&2
|
|
exit 1
|
|
fi
|
|
|
|
getent group rustbox >/dev/null || groupadd --system rustbox
|
|
id rustbox >/dev/null 2>&1 || useradd --system --gid rustbox --home-dir /var/lib/rustbox --shell /usr/sbin/nologin rustbox
|
|
install -d -o root -g rustbox -m 0750 /etc/rustbox
|
|
install -m 0755 "$BIN" /usr/local/bin/rustbox
|
|
install -m 0644 "$ROOT/packaging/systemd/rustbox.service" /etc/systemd/system/rustbox.service
|
|
if [ ! -f /etc/rustbox/rustbox.toml ]; then
|
|
install -o root -g rustbox -m 0640 "$ROOT/config.example.toml" /etc/rustbox/rustbox.toml
|
|
fi
|
|
RUSTBOX_CONFIG=/etc/rustbox/rustbox.toml /usr/local/bin/rustbox --check-config
|
|
systemctl daemon-reload
|
|
echo "Installed. Review /etc/rustbox/rustbox.toml, then: systemctl enable --now rustbox"
|