Initial commit: KillSwitch CLI and systemd target

This commit is contained in:
2026-03-21 20:15:02 +01:00
commit 2eaa499d34
3 changed files with 65 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.swp
*.bak
*.tmp

60
killsw Executable file
View File

@@ -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 <command>
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 <your-service>.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

2
killswitch.target Normal file
View File

@@ -0,0 +1,2 @@
[Unit]
Description=KillSwitch Target