2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # This code runs after package variable definitions, before the actual
7 # pre/post package work, to set some variable and function defaults.
9 if [ -z "$INSTALL_PATH" ]; then
12 PACKAGE BUILD ERROR: $0 is missing package metadata.
14 This package is buggy. Please mail <packaging@arvados.org> to let
15 us know the name and version number of the package you tried to
16 install, and we'll get it fixed.
22 RELEASE_PATH=$INSTALL_PATH/current
23 RELEASE_CONFIG_PATH=$RELEASE_PATH/config
24 SHARED_PATH=$INSTALL_PATH/shared
26 if ! type setup_extra_conffiles >/dev/null 2>&1; then
27 setup_extra_conffiles() { return; }
29 if ! type setup_before_nginx_restart >/dev/null 2>&1; then
30 setup_before_nginx_restart() { return; }
33 if [ -e /run/systemd/system ]; then
39 if which service >/dev/null 2>&1; then
45 guess_service_manager() {
46 if [ 1 = "$USING_SYSTEMD" ]; then
48 elif [ 1 = "$USING_SERVICE" ]; then
55 list_services_systemd() {
56 test 1 = "$USING_SYSTEMD" || return
57 # Print only service names, without the `.service` suffix.
58 systemctl list-unit-files '*.service' \
59 | awk '($1 ~ /\.service/){print substr($1, 1, length($1) - 8)}'
62 list_services_service() {
63 test 1 = "$USING_SERVICE" || return
64 # Output is completely different across Debian and Red Hat.
65 # We can't really parse it.
66 service --status-all 2>/dev/null
70 local service_manager="$1"; shift
71 local command="$1"; shift
72 local service="$1"; shift
73 case "$service_manager" in
74 systemd) systemctl "$command" "$service" ;;
75 service) service "$service" "$command" ;;
79 if ! guess_service_manager >/dev/null; then
80 echo "WARNING: Unsupported init system. Can't manage web service." >&2