8784: Fix test for latest firefox.
[arvados.git] / build / rails-package-scripts / step2.sh
1 #!/bin/sh
2 # This code runs after package variable definitions, before the actual
3 # pre/post package work, to set some variable and function defaults.
4
5 if [ -z "$INSTALL_PATH" ]; then
6     cat >&2 <<EOF
7
8 PACKAGE BUILD ERROR: $0 is missing package metadata.
9
10 This package is buggy.  Please mail <support@curoverse.com> to let
11 us know the name and version number of the package you tried to
12 install, and we'll get it fixed.
13
14 EOF
15     exit 3
16 fi
17
18 RELEASE_PATH=$INSTALL_PATH/current
19 RELEASE_CONFIG_PATH=$RELEASE_PATH/config
20 SHARED_PATH=$INSTALL_PATH/shared
21
22 RAILSPKG_SUPPORTS_CONFIG_CHECK=${RAILSPKG_SUPPORTS_CONFIG_CHECK:-1}
23 if ! type setup_extra_conffiles >/dev/null 2>&1; then
24     setup_extra_conffiles() { return; }
25 fi
26 if ! type setup_before_nginx_restart >/dev/null 2>&1; then
27     setup_before_nginx_restart() { return; }
28 fi
29
30 if [ -e /run/systemd/system ]; then
31     USING_SYSTEMD=1
32 else
33     USING_SYSTEMD=0
34 fi
35
36 if which service >/dev/null 2>&1; then
37     USING_SERVICE=1
38 else
39     USING_SERVICE=0
40 fi
41
42 guess_service_manager() {
43     if [ 1 = "$USING_SYSTEMD" ]; then
44         echo systemd
45     elif [ 1 = "$USING_SERVICE" ]; then
46         echo service
47     else
48         return 1
49     fi
50 }
51
52 list_services_systemd() {
53     test 1 = "$USING_SYSTEMD" || return
54     # Print only service names, without the `.service` suffix.
55     systemctl list-unit-files '*.service' \
56         | awk '($1 ~ /\.service/){print substr($1, 1, length($1) - 8)}'
57 }
58
59 list_services_service() {
60     test 1 = "$USING_SERVICE" || return
61     # Output is completely different across Debian and Red Hat.
62     # We can't really parse it.
63     service --status-all 2>/dev/null
64 }
65
66 service_command() {
67     local service_manager="$1"; shift
68     local command="$1"; shift
69     local service="$1"; shift
70     case "$service_manager" in
71         systemd) systemctl "$command" "$service" ;;
72         service) service "$service" "$command" ;;
73     esac
74 }
75
76 if ! guess_service_manager >/dev/null; then
77     echo "WARNING: Unsupported init system. Can't manage web service." >&2
78 fi