From 2eaa499d34b8e2d453dcd7ea41abcd948d05fdc2 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 21 Mar 2026 20:15:02 +0100 Subject: [PATCH] Initial commit: KillSwitch CLI and systemd target --- .gitignore | 3 +++ killsw | 60 +++++++++++++++++++++++++++++++++++++++++++++++ killswitch.target | 2 ++ 3 files changed, 65 insertions(+) create mode 100644 .gitignore create mode 100755 killsw create mode 100644 killswitch.target diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0403db5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.bak +*.tmp diff --git a/killsw b/killsw new file mode 100755 index 0000000..ccb1e14 --- /dev/null +++ b/killsw @@ -0,0 +1,60 @@ +#!/bin/bash + +VERSION="1.0.0" + +cmd="$1" + +case "$cmd" in + stop) + systemctl stop killswitch.target + echo "Killswitch activated: all linked services have been stopped." + ;; + start) + systemctl start killswitch.target + echo "Killswitch deactivated: all linked services have been started." + ;; + status) + systemctl status killswitch.target + ;; + help|-h|--help) + cat << EOF +KillSwitch CLI Tool - v$VERSION + +USAGE: + killsw + +COMMANDS: + stop Stop all services linked to killswitch.target + start Start all services linked to killswitch.target + status Show the current status of the killswitch target + -h, --help Show this help message + -v, --version Show version information + +ABOUT KILLSWITCH: + What it does: + Stops all services that are linked to 'killswitch.target'. This allows + you to perform an emergency stop or centralized management of multiple + services. + + Why it's needed: + Useful for quickly stopping servers or services in case of maintenance, + emergency, or to prevent unsafe operations. + + How to enable it on your services: + 1) Create or edit your systemd service to link it to killswitch.target: + Add the following to your [Unit] section: + PartOf=killswitch.target + 2) Optionally, enable the service to start at boot: + sudo systemctl enable .service + 3) Start/stop via this script: + killsw start + killsw stop +EOF + ;; + -v|--version) + echo "KillSwitch CLI Tool version $VERSION" + ;; + *) + echo "Unknown command: $cmd. Use --help to see available commands." + ;; +esac diff --git a/killswitch.target b/killswitch.target new file mode 100644 index 0000000..66700cb --- /dev/null +++ b/killswitch.target @@ -0,0 +1,2 @@ +[Unit] +Description=KillSwitch Target