@@ -15,6 +15,7 @@ if test -L "$symlink"; then
1515fi
1616
1717SERVICE_NAME=" ElasticEndpoint"
18+ should_restart_endpoint=false
1819
1920echo " Checking if $SERVICE_NAME is installed"
2021if systemctl list-unit-files --type=service | grep -q " ^${SERVICE_NAME} .service" ; then
@@ -27,8 +28,7 @@ if systemctl list-unit-files --type=service | grep -q "^${SERVICE_NAME}.service"
2728 echo " $SERVICE_NAME is installed but not running"
2829 if [[ " $installed_endpoint_version " == " $archive_endpoint_version " ]]; then
2930 echo " New endpoint and installed endpoint versions are the same: \" ${installed_endpoint_version} \" "
30- echo " Starting $SERVICE_NAME "
31- sudo systemctl start ${SERVICE_NAME}
31+ should_restart_endpoint=true
3232 else
3333 echo " New endpoint version \" ${archive_endpoint_version} \" is different than the one that's already
3434 installed \" ${installed_endpoint_version} \" "
@@ -53,4 +53,9 @@ echo "systemd enable/restart elastic-agent"
5353systemctl daemon-reload 2> /dev/null
5454systemctl enable elastic-agent 2> /dev/null || true
5555systemctl 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
5661exit 0
0 commit comments