Files
cloudron-box/src/scripts/restartservice.sh

42 lines
876 B
Bash
Raw Normal View History

2021-03-23 11:01:14 -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
[[ "${BOX_ENV}" != "cloudron" ]] && exit
service="$1"
if [[ "${service}" == "unbound" ]]; then
2021-06-21 10:05:22 -07:00
systemctl restart --no-block unbound
2021-03-23 11:01:14 -07:00
elif [[ "${service}" == "nginx" ]]; then
if systemctl -q is-active nginx; then
nginx -s reload
else
systemctl restart --no-block nginx
fi
2021-03-23 11:01:14 -07:00
elif [[ "${service}" == "docker" ]]; then
2021-06-21 10:05:22 -07:00
systemctl restart --no-block docker
2021-03-23 11:01:14 -07:00
elif [[ "${service}" == "collectd" ]]; then
2021-06-21 10:05:22 -07:00
systemctl restart --no-block collectd
elif [[ "${service}" == "box" ]]; then
2025-06-15 13:58:28 +02:00
systemctl reload --no-block box
2021-03-23 11:01:14 -07:00
else
echo "Unknown service ${service}"
exit 1
fi