blob: de5b7d85a51ce4e8d5ec68727f248856045db2ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#!/bin/sh
#
# Installer for support files needed by Pacemaker's Cluster Test Suite
#
# Copyright 2018-2022 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
USAGE_TEXT="Usage: $0 <install|uninstall|--help>"
HELP_TEXT="$USAGE_TEXT
Commands (must be run as root):
install Install support files needed by Pacemaker CTS
uninstall Remove support files needed by Pacemaker CTS"
# These constants must track crm_exit_t values
CRM_EX_OK=0
CRM_EX_ERROR=1
CRM_EX_USAGE=64
UNIT_DIR="@systemdsystemunitdir@"
RUNTIME_UNIT_DIR="@runstatedir@/systemd/system"
LIBEXEC_DIR="@libexecdir@/pacemaker"
INIT_DIR="@INITDIR@"
PCMK__FENCE_BINDIR="@PCMK__FENCE_BINDIR@"
DATA_DIR="@datadir@/pacemaker/tests/cts"
UPSTART_DIR="/etc/init"
DUMMY_DAEMON="pacemaker-cts-dummyd"
DUMMY_DAEMON_UNIT="pacemaker-cts-dummyd@.service"
COROSYNC_RUNTIME_UNIT="corosync.service.d"
COROSYNC_RUNTIME_CONF="cts.conf"
LSB_DUMMY="LSBDummy"
UPSTART_DUMMY="pacemaker-cts-dummyd.conf"
FENCE_DUMMY="fence_dummy"
FENCE_DUMMY_ALIASES="auto_unfence no_reboot no_on"
# If the install directory doesn't exist, assume we're in a build directory.
if [ ! -d "$DATA_DIR" ]; then
# If readlink supports -e (i.e. GNU), use it.
readlink -e / >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
DATA_DIR="$(dirname "$(readlink -e "$0")")"
else
DATA_DIR="$(dirname "$0")"
fi
fi
usage() {
echo "Error:" "$@"
echo "$USAGE_TEXT"
exit $CRM_EX_USAGE
}
must_be_root() {
if ! [ "$(id -u)" = "0" ]; then
usage "this command must be run as root"
return $CRM_EX_ERROR
fi
return $CRM_EX_OK
}
support_uninstall() {
must_be_root || return $CRM_EX_ERROR
if [ -e "$UNIT_DIR/$DUMMY_DAEMON_UNIT" ]; then
echo "Removing $UNIT_DIR/$DUMMY_DAEMON_UNIT ..."
rm -f "$UNIT_DIR/$DUMMY_DAEMON_UNIT"
systemctl daemon-reload # Ignore failure
fi
if [ -e "$RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT" ]; then
echo "Removing $RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT ..."
rm -rf "$RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT"
systemctl daemon-reload # Ignore failure
fi
for FILE in \
"$LIBEXEC_DIR/$DUMMY_DAEMON" \
"$UPSTART_DIR/$UPSTART_DUMMY" \
"$PCMK__FENCE_BINDIR/$FENCE_DUMMY" \
"$INIT_DIR/$LSB_DUMMY"
do
if [ -e "$FILE" ]; then
echo "Removing $FILE ..."
rm -f "$FILE"
fi
done
for ALIAS in $FENCE_DUMMY_ALIASES; do \
FILE="$PCMK__FENCE_BINDIR/fence_dummy_$ALIAS"
if [ -L "$FILE" ] || [ -e "$FILE" ]; then
echo "Removing $FILE ..."
rm -f "$FILE"
fi
done
return $CRM_EX_OK
}
support_install() {
support_uninstall || return $CRM_EX_ERROR
cd "$DATA_DIR" || return $CRM_EX_ERROR
if [ -d "$UNIT_DIR" ]; then
echo "Installing $DUMMY_DAEMON ..."
mkdir -p "$LIBEXEC_DIR"
install -m 0755 "$DUMMY_DAEMON" "$LIBEXEC_DIR" || return $CRM_EX_ERROR
echo "Installing $DUMMY_DAEMON_UNIT ..."
install -m 0644 "$DUMMY_DAEMON_UNIT" "$UNIT_DIR" || return $CRM_EX_ERROR
systemctl daemon-reload # Ignore failure
fi
if [ -d "$RUNTIME_UNIT_DIR" ]; then
echo "Installing $COROSYNC_RUNTIME_CONF to $RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT ..."
mkdir -p "$RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT"
install -m 0644 "$COROSYNC_RUNTIME_CONF" "$RUNTIME_UNIT_DIR/$COROSYNC_RUNTIME_UNIT" || return $CRM_EX_ERROR
systemctl daemon-reload # Ignore failure
fi
echo "Installing $FENCE_DUMMY to $PCMK__FENCE_BINDIR ..."
mkdir -p "$PCMK__FENCE_BINDIR"
install -m 0755 "$FENCE_DUMMY" "$PCMK__FENCE_BINDIR" || return $CRM_EX_ERROR
for alias in $FENCE_DUMMY_ALIASES; do \
echo "Installing fence_dummy_$alias to $PCMK__FENCE_BINDIR ..."
ln -s "$FENCE_DUMMY" "$PCMK__FENCE_BINDIR/fence_dummy_$alias"
if [ $? -ne 0 ]; then
return $CRM_EX_ERROR
fi
done
echo "Installing $LSB_DUMMY to $INIT_DIR ..."
mkdir -p "$INIT_DIR"
install -m 0755 "$LSB_DUMMY" "$INIT_DIR" || return $CRM_EX_ERROR
if [ -d "$UPSTART_DIR" ] && [ -f "$UPSTART_DUMMY" ]; then
echo "Installing $UPSTART_DUMMY to $UPSTART_DIR ..."
install -m 0644 "$UPSTART_DUMMY" "$UPSTART_DIR" || return $CRM_EX_ERROR
fi
return $CRM_EX_OK
}
COMMAND=""
while [ $# -gt 0 ] ; do
case "$1" in
--help)
echo "$HELP_TEXT"
exit $CRM_EX_OK
;;
install|uninstall)
COMMAND="$1"
shift
;;
*)
usage "unknown option '$1'"
;;
esac
done
case "$COMMAND" in
install) support_install ;;
uninstall) support_uninstall ;;
*) usage "must specify command" ;;
esac
|