|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
| 5 | +SERVICE_NAME="ElasticEndpoint" |
5 | 6 | endpoint_active=false |
6 | 7 |
|
7 | 8 | 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 |
18 | 19 | else |
19 | | - echo "ElasticEndpoint is already running" |
| 20 | + echo "$SERVICE_NAME is already running" |
20 | 21 | fi |
21 | 22 | exit 1 |
22 | | - } |
| 23 | + } |
23 | 24 |
|
24 | | - trap restore_endpoint ERR |
| 25 | + trap restore_endpoint ERR |
25 | 26 |
|
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" |
30 | 31 |
|
31 | | - rm -rf "/opt/Elastic/Endpoint/state/vault" |
| 32 | + rm -rf "/opt/Elastic/Endpoint/state/vault" |
32 | 33 |
|
33 | | - echo "Stopping ElasticEndpoint" |
34 | | - systemctl --quiet stop ElasticEndpoint |
| 34 | + echo "Stopping $SERVICE_NAME" |
| 35 | + systemctl --quiet stop $SERVICE_NAME |
35 | 36 | 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 |
39 | 40 | } |
40 | 41 |
|
41 | 42 | handle_endpoint |
|
0 commit comments