Skip to content

Commit be4692c

Browse files
pkoutsovasilismergify[bot]
authored andcommitted
[deb/rpm] restart endpoint with tamper protection after elastic-agent (#8637)
* fix: use rpm from local build (cherry picked from commit 249885f) # Conflicts: # dev-tools/packaging/templates/linux/postinstall.sh.tmpl # testing/integration/endpoint_security_test.go
1 parent 844427e commit be4692c

File tree

2 files changed

+404
-2
lines changed

2 files changed

+404
-2
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,37 @@ if test -L "$symlink"; then
1313
unlink "$symlink"
1414
fi
1515

16+
<<<<<<< HEAD
17+
=======
18+
SERVICE_NAME="ElasticEndpoint"
19+
should_restart_endpoint=false
20+
21+
echo "Checking if $SERVICE_NAME is installed"
22+
if systemctl list-unit-files --type=service | grep -q "^${SERVICE_NAME}.service"; then
23+
24+
installed_endpoint_version="$(/opt/Elastic/Endpoint/elastic-endpoint version)"
25+
archive_endpoint_version="$("$new_endpoint_component_bin" version)"
26+
27+
echo "${SERVICE_NAME} is installed at version ${installed_endpoint_version}"
28+
if ! systemctl is-active --quiet "$SERVICE_NAME"; then
29+
echo "$SERVICE_NAME is installed but not running"
30+
if [[ "$installed_endpoint_version" == "$archive_endpoint_version" ]]; then
31+
echo "New endpoint and installed endpoint versions are the same: \"${installed_endpoint_version}\""
32+
should_restart_endpoint=true
33+
else
34+
echo "New endpoint version \"${archive_endpoint_version}\" is different than the one that's already
35+
installed \"${installed_endpoint_version}\""
36+
fi
37+
else
38+
# Endpoint can already be running if tamper protection is not enabled
39+
echo "$SERVICE_NAME is already running"
40+
fi
41+
else
42+
echo "$SERVICE_NAME is not installed"
43+
fi
44+
45+
46+
>>>>>>> 249885f9f ([deb/rpm] restart endpoint with tamper protection after elastic-agent (#8637))
1647
# create symlink to the new agent
1748
echo "create symlink "$symlink" to "$new_agent_dir/elastic-agent""
1849
ln -s "$new_agent_dir/elastic-agent" "$symlink"
@@ -22,4 +53,9 @@ echo "systemd enable/restart elastic-agent"
2253
systemctl daemon-reload 2> /dev/null
2354
systemctl enable elastic-agent 2> /dev/null || true
2455
systemctl restart elastic-agent 2> /dev/null || true
56+
# restart endpoint if needed
57+
if [ "$should_restart_endpoint" = true ]; then
58+
echo "Starting $SERVICE_NAME after elastic-agent"
59+
systemctl restart "$SERVICE_NAME" 2> /dev/null || true
60+
fi
2561
exit 0

0 commit comments

Comments
 (0)