Files
killswitch-cli/src/killsw
2026-03-24 19:47:14 +01:00

69 lines
2.1 KiB
Bash

#!/bin/bash
VERSION="1.0.1"
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
;;
add)
if [[ -n "$2" && "$3" == "to" && -n "$4" ]]; then
echo "Called add $2 to $4"
else
echo "Usage: killsw add [service] to [group]"
fi
;;
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
add [service] to [name] adds services to different groups. (not doing anything at the moment)
-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 "Ahoy, matey! No command provided. Check --help for guidance."
;;
esac