Files
cloudron-box/src/scripts/stoptask.sh
T

32 lines
867 B
Bash
Raw Normal View History

2020-08-06 14:36:25 -07:00
#!/bin/bash
set -eu -o pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "This script should be run as root." > /dev/stderr
exit 1
fi
if [[ $# -eq 0 ]]; then
echo "No arguments supplied"
exit 1
fi
if [[ "$1" == "--check" ]]; then
echo "OK"
exit 0
fi
task_id="$1"
2020-08-06 22:04:46 -07:00
if [[ "${task_id}" == "all" ]]; then
2020-08-09 07:07:19 -07:00
systemctl list-units --full --no-legend box-task-* # just to show who was running
systemctl kill --signal=SIGTERM box-task-* || true
systemctl reset-failed box-task-* || true
systemctl stop box-task-* || true # because of remain-after-exit in Ubuntu 16 we have to deactivate the service
2020-08-06 22:04:46 -07:00
else
2020-08-09 07:07:19 -07:00
readonly service_name="box-task-${task_id}"
2020-08-06 22:04:46 -07:00
systemctl kill --signal=SIGTERM "${service_name}" || true
2020-08-08 11:10:02 -07:00
systemctl stop "${service_name}" || true # because of remain-after-exit in Ubuntu 16 we have to deactivate the service
2020-08-06 22:04:46 -07:00
fi