-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathstart-clp.sh
More file actions
executable file
·103 lines (91 loc) · 4.2 KB
/
start-clp.sh
File metadata and controls
executable file
·103 lines (91 loc) · 4.2 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
common_env_path="$script_dir/.common-env.sh"
# shellcheck source=.common-env.sh
source "$common_env_path"
# --- Telemetry consent prompt ---
# Determines whether to show the first-run telemetry consent prompt.
# The prompt is skipped if:
# 1. CLP_DISABLE_TELEMETRY or DO_NOT_TRACK env vars are set
# 2. telemetry.disable is explicitly set in clp-config.yaml
# 3. instance-id file already exists (not a first run)
# If shown and the user declines, telemetry.disable is written to clp-config.yaml.
telemetry_prompt_needed=false
# Find the config file path (mirror the default in start_clp.py)
clp_config_path="${CLP_HOME}/etc/clp-config.yaml"
# Check env vars first
clp_disable_telemetry_lower="${CLP_DISABLE_TELEMETRY:-}"
clp_disable_telemetry_lower="${clp_disable_telemetry_lower,,}"
if [[ "$clp_disable_telemetry_lower" == "true" ]] || [[ "$clp_disable_telemetry_lower" == "1" ]]; then
telemetry_prompt_needed=false
elif [[ "${DO_NOT_TRACK:-}" == "1" ]]; then
telemetry_prompt_needed=false
# Check if telemetry is already configured in the config file
elif [[ -f "$clp_config_path" ]] && grep -q -E '^telemetry:' "$clp_config_path" 2>/dev/null; then
telemetry_prompt_needed=false
# Check if instance-id exists (not first run)
elif [[ -f "${CLP_HOME}/var/log/instance-id" ]]; then
telemetry_prompt_needed=false
else
telemetry_prompt_needed=true
fi
if [[ "$telemetry_prompt_needed" == "true" ]]; then
if [[ -t 0 ]]; then
# Interactive: show the consent prompt
echo "================================================================================"
echo "CLP collects anonymous usage telemetry to help improve the software."
echo "This includes: CLP version, OS/architecture, deployment method, and"
echo "component health status. It does NOT include: log content, queries,"
echo "hostnames, IP addresses, or any personally identifiable"
echo "information."
echo ""
echo "Telemetry is sent to: https://telemetry.yscope.io"
echo "For details, see: https://docs.yscope.com/clp/main/user-guide/telemetry"
echo ""
echo "You can disable telemetry at any time by setting CLP_DISABLE_TELEMETRY=true"
echo "or by blocking https://telemetry.yscope.io at the network level."
echo ""
read -r -p "Enable anonymous telemetry to help improve CLP? [Y/n] " telemetry_response
echo "================================================================================"
if [[ "$telemetry_response" =~ ^[Nn]$ ]]; then
# User opted out — persist to config
if [[ -f "$clp_config_path" ]]; then
if grep -q "^telemetry:" "$clp_config_path" 2>/dev/null; then
# Replace existing telemetry block (key + indented lines)
sed -i '/^telemetry:/,/^[^[:space:]]/{/^telemetry:/!{/^[^[:space:]]/!d};}' \
"$clp_config_path"
sed -i 's/^telemetry:.*/telemetry:\n disable: true/' "$clp_config_path"
else
# Append telemetry block with grouped redirect
{
echo ""
echo "telemetry:"
echo " disable: true"
} >> "$clp_config_path"
fi
else
printf "telemetry:\n disable: true\n" > "$clp_config_path"
fi
echo "Telemetry has been disabled. You can re-enable it in ${clp_config_path}."
fi
fi
# Non-interactive: default to enabled (no prompt, no config write needed)
fi
# --- Export host OS info for telemetry ---
export CLP_HOST_OS="linux"
if [[ -f /etc/os-release ]]; then
CLP_HOST_OS_VERSION="$(. /etc/os-release && echo "${ID:-unknown}-${VERSION_ID:-unknown}")"
else
CLP_HOST_OS_VERSION="unknown"
fi
export CLP_HOST_OS_VERSION
export CLP_HOST_ARCH
CLP_HOST_ARCH="$(uname -m)"
docker compose -f "$CLP_HOME/docker-compose.runtime.yaml" \
run --rm "${CLP_COMPOSE_RUN_EXTRA_FLAGS[@]}" clp-runtime \
python3 \
-m clp_package_utils.scripts.start_clp \
"$@"