-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpostinstall
More file actions
executable file
·80 lines (69 loc) · 2.77 KB
/
Copy pathpostinstall
File metadata and controls
executable file
·80 lines (69 loc) · 2.77 KB
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
#!/bin/sh
set -eu
BEACON_BIN="${BEACON_BIN:-/opt/beacon/bin/beacon}" \
BEACON_COLLECTOR="${BEACON_COLLECTOR:-/opt/beacon/bin/beacon-otelcol}" \
BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-claude,codex}" \
BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-full}" \
BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-4317}" \
BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-4318}" \
BEACON_SPLUNK_HEC_ENDPOINT="${BEACON_SPLUNK_HEC_ENDPOINT:-}" \
BEACON_SPLUNK_HEC_TOKEN="${BEACON_SPLUNK_HEC_TOKEN:-}" \
BEACON_SPLUNK_INDEX="${BEACON_SPLUNK_INDEX:-}" \
BEACON_SPLUNK_SOURCE="${BEACON_SPLUNK_SOURCE:-}" \
BEACON_SPLUNK_SOURCETYPE="${BEACON_SPLUNK_SOURCETYPE:-}" \
BEACON_SPLUNK_INSECURE_SKIP_VERIFY="${BEACON_SPLUNK_INSECURE_SKIP_VERIFY:-0}" \
BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-}" \
BEACON_NO_START=1 \
/opt/beacon/scripts/install-endpoint.sh
forwarder_running() {
label="$1"
launchctl print "system/$label" 2>/dev/null | grep -Eq 'state = running|pid ='
}
restore_existing_forwarder() {
label="$1"
plist_path="$2"
target="system/$label"
# No plist means the customer has not installed this optional forwarder.
if [ ! -f "$plist_path" ]; then
return 0
fi
if forwarder_running "$label"; then
out="$(launchctl kickstart -k "$target" 2>&1)" || {
echo "Warning: launchctl kickstart failed for $label: $out" >&2
}
if forwarder_running "$label"; then
return 0
fi
fi
for delay in 1 2 4 8 16; do
out="$(launchctl bootstrap system "$plist_path" 2>&1)" || {
echo "Warning: launchctl bootstrap failed for $label: $out" >&2
}
if forwarder_running "$label"; then
return 0
fi
out="$(launchctl kickstart -k "$target" 2>&1)" || {
echo "Warning: launchctl kickstart retry failed for $label: $out" >&2
}
if forwarder_running "$label"; then
return 0
fi
sleep "$delay"
done
out="$(launchctl print "$target" 2>&1)" || true
echo "Error: could not restore existing forwarder $label after package install. launchctl print: $out" >&2
return 1
}
if command -v launchctl >/dev/null 2>&1; then
launchctl bootout system/com.beacon.endpoint.collector >/dev/null 2>&1 || true
launchctl bootstrap system /Library/LaunchDaemons/com.beacon.endpoint.collector.plist >/dev/null 2>&1 || {
launchctl print system/com.beacon.endpoint.collector >/dev/null 2>&1 || exit 1
}
restore_existing_forwarder "com.beacon.endpoint.falcon-forwarder" "/Library/LaunchDaemons/com.beacon.endpoint.falcon-forwarder.plist"
restore_existing_forwarder "com.beacon.endpoint.s3-forwarder" "/Library/LaunchDaemons/com.beacon.endpoint.s3-forwarder.plist"
"${BEACON_BIN:-/opt/beacon/bin/beacon}" endpoint update install-daemon || {
echo "Error: could not reconcile Beacon endpoint updater daemon" >&2
exit 1
}
fi
exit 0