Files
cloudron-box/src/scripts/restartservice.sh
Girish Ramakrishnan 19c744b17d unbound-anchor is now part of ExecStartPre
it seems unbound-anchor is not a dep of unbound in ubuntu 24. some
installations are thus missing this package.

in any case, ignore unbound-anchor exit status
2024-09-20 10:00:01 +02:00

49 lines
1.1 KiB
Bash
Executable File

#!/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
systemctl restart --no-block unbound
elif [[ "${service}" == "nginx" ]]; then
if systemctl -q is-active nginx; then
nginx -s reload
else
systemctl restart --no-block nginx
fi
elif [[ "${service}" == "docker" ]]; then
systemctl restart --no-block docker
elif [[ "${service}" == "collectd" ]]; then
systemctl restart --no-block collectd
elif [[ "${service}" == "box" ]]; then
readonly ubuntu_version=$(lsb_release -rs)
if [[ "${ubuntu_version}" == "18.04" ]]; then
pid=$(systemctl show box -p MainPID | sed 's/MainPID=//g')
kill -HUP $pid
else
systemctl reload --no-block box
fi
else
echo "Unknown service ${service}"
exit 1
fi