Skip to content

Commit 46ff905

Browse files
author
kaanyalti
committed
enhancement(6394): using service name, fixed indentation
1 parent e46a25b commit 46ff905

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

dev-tools/packaging/templates/linux/preinstall.sh.tmpl

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,41 @@
22

33
set -e
44

5+
SERVICE_NAME="ElasticEndpoint"
56
endpoint_active=false
67

78
handle_endpoint() {
8-
echo "Checking if ElasticEndpoint is an active service"
9-
if systemctl --quiet is-active ElasticEndpoint; then
10-
endpoint_active=true
11-
12-
# restore endpoint and vault by restarting the service
13-
restore_endpoint() {
14-
echo "Restore ElasticEndpoint"
15-
if ! systemctl --quiet is-active ElasticEndpoint; then
16-
echo "Starting ElasticEndpoint"
17-
systemctl --quiet start ElasticEndpoint
9+
echo "Checking if $SERVICE_NAME is an active service"
10+
if systemctl --quiet is-active $SERVICE_NAME; then
11+
endpoint_active=true
12+
13+
# restore endpoint and vault by restarting the service
14+
restore_endpoint() {
15+
echo "Restore $SERVICE_NAME"
16+
if ! systemctl --quiet is-active $SERVICE_NAME; then
17+
echo "Starting $SERVICE_NAME"
18+
systemctl --quiet start $SERVICE_NAME
1819
else
19-
echo "ElasticEndpoint is already running"
20+
echo "$SERVICE_NAME is already running"
2021
fi
2122
exit 1
22-
}
23+
}
2324

24-
trap restore_endpoint ERR
25+
trap restore_endpoint ERR
2526

26-
# Remove the vault directory if it exists
27-
if [ -d "/opt/Elastic/Endpoint/state/vault" ]; then
28-
echo "ElasticEndpoint is tamper protected"
29-
echo "Removing ElasticEndpoint vault"
27+
# Remove the vault directory if it exists
28+
if [ -d "/opt/Elastic/Endpoint/state/vault" ]; then
29+
echo "$SERVICE_NAME is tamper protected"
30+
echo "Removing $SERVICE_NAME vault"
3031

31-
rm -rf "/opt/Elastic/Endpoint/state/vault"
32+
rm -rf "/opt/Elastic/Endpoint/state/vault"
3233

33-
echo "Stopping ElasticEndpoint"
34-
systemctl --quiet stop ElasticEndpoint
34+
echo "Stopping $SERVICE_NAME"
35+
systemctl --quiet stop $SERVICE_NAME
3536
else
36-
echo "ElasticEndpoint tamper protection is not enabled"
37-
fi
38-
fi
37+
echo "$SERVICE_NAME tamper protection is not enabled"
38+
fi
39+
fi
3940
}
4041

4142
handle_endpoint

0 commit comments

Comments
 (0)