Files
ferrum/scripts/linux/uninstall.sh
T
Anand 7d3a1fa134 Add git hygiene, screenshots, and cross-platform deployment tooling
- .gitignore/.dockerignore: cover Go build artifacts, env files, logs,
  editor/OS cruft, and local runtime data (sqlite db/secret, config.yaml).
- README: add a Screenshots section (captured against a mock Proxmox
  cluster) and a Deploying a release build section.
- LICENSE: MIT.

Deployable binaries:
- cmd/ferrum: -version flag with build-time version/commit/date via
  -ldflags; -log-file flag (Windows services don't capture stdout/stderr
  the way systemd does); native Windows Service Control Manager support
  (service_windows.go) so ferrum.exe manages its own start/stop lifecycle
  under a Windows service, same graceful-shutdown path SIGTERM already used
  on Linux.
- packaging/systemd/ferrum.service: hardened systemd unit.
- scripts/build.sh, build.ps1: cross-compile linux/windows/darwin x
  amd64/arm64, package as .tar.gz/.zip with an install script and
  checksums.txt.
- scripts/linux/install.sh, uninstall.sh: create a dedicated system user,
  install the binary, seed /etc/ferrum/config.yaml, enable + start the
  systemd service.
- scripts/get.sh: one-line curl-pipeable installer (get.docker.com style)
  that resolves the latest release, verifies its checksum, and hands off
  to install.sh.
- scripts/windows/install-service.ps1, uninstall-service.ps1: register/
  remove the self-managing Windows service.
- .github/workflows/release.yml: publish all platform archives + checksums
  as GitHub Release assets on a vX.Y.Z tag push.
- .github/workflows/ci.yml: go vet/build/test, frontend lint/test/build,
  and shell-script syntax checks on push/PR.
2026-09-03 13:38:12 +05:30

46 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Stops and removes the ferrum systemd service and binary. Configuration
# (/etc/ferrum) and data (/var/lib/ferrum) are kept by default — pass
# --purge to remove those too, and --purge-user to also drop the 'ferrum'
# system user.
#
# Usage: sudo ./uninstall.sh [--purge] [--purge-user]
set -euo pipefail
if [ "$(id -u)" -ne 0 ]; then
echo "error: must be run as root (sudo ./uninstall.sh)" >&2
exit 1
fi
purge=false
purge_user=false
for arg in "$@"; do
case "$arg" in
--purge) purge=true ;;
--purge-user) purge_user=true ;;
*) echo "unknown argument: $arg" >&2; exit 1 ;;
esac
done
echo "==> Stopping and disabling ferrum.service"
systemctl disable --now ferrum.service 2>/dev/null || true
echo "==> Removing systemd unit and binary"
rm -f /etc/systemd/system/ferrum.service
systemctl daemon-reload
rm -f /usr/local/bin/ferrum
if $purge; then
echo "==> Purging /etc/ferrum and /var/lib/ferrum"
rm -rf /etc/ferrum /var/lib/ferrum
else
echo "==> Keeping /etc/ferrum and /var/lib/ferrum (pass --purge to remove them)"
fi
if $purge_user; then
echo "==> Removing system user 'ferrum'"
userdel ferrum 2>/dev/null || true
fi
echo "==> Done."