Use telemetry_id file

This commit is contained in:
Jamil Bou Kheir
2022-02-05 13:44:16 -08:00
parent b4ed7311be
commit 5a019cd57e
13 changed files with 48 additions and 37 deletions

View File

@@ -10,7 +10,7 @@ Resets the password for admin with email specified by default['firezone']['admin
DESC
def capture
telemetry_file = "/opt/firezone/sv/phoenix/env/TELEMETRY_ID"
telemetry_file = "/var/opt/firezone/cache/telemetry_id"
if File.exist?(telemetry_file)
telemetry_id = File.read(telemetry_file)
if telemetry_id
@@ -22,7 +22,7 @@ def capture
distinct_id: telemetry_id
}
}
unless File.exist?("#{base_path}/.disable-telemetry") || ENV["TELEMETRY_ENABLED"] == "false"
unless File.exist?("/var/opt/firezone/.disable_telemetry") || ENV["TELEMETRY_ENABLED"] == "false"
Net::HTTP.post(uri, data.to_json, "Content-Type" => "application/json")
end
end

View File

@@ -6,7 +6,7 @@ require 'net/http'
require 'json'
def capture
telemetry_file = "/opt/firezone/sv/phoenix/env/TELEMETRY_ID"
telemetry_file = "/var/opt/firezone/cache/telemetry_id"
if File.exist?(telemetry_file)
telemetry_id = File.read(telemetry_file)
if telemetry_id
@@ -18,7 +18,7 @@ def capture
distinct_id: telemetry_id
}
}
unless File.exist?("#{base_path}/.disable-telemetry") || ENV["TELEMETRY_ENABLED"] == "false"
unless File.exist?("/var/opt/firezone/.disable_telemetry") || ENV["TELEMETRY_ENABLED"] == "false"
Net::HTTP.post(uri, data.to_json, "Content-Type" => "application/json")
end
end

View File

@@ -225,7 +225,6 @@ class Firezone
'WIREGUARD_IPV6_ADDRESS' => attributes['wireguard']['ipv6']['address'],
# Allow env var to override config
'TELEMETRY_ENABLED' => ENV.fetch('TELEMETRY_ENABLED', attributes['telemetry']['enabled'] == false ? "false" : "true"),
'TELEMETRY_ID' => attributes['telemetry_id'],
'CONNECTIVITY_CHECKS_ENABLED' => attributes['connectivity_checks']['enabled'].to_s,
'CONNECTIVITY_CHECKS_INTERVAL' => attributes['connectivity_checks']['interval'].to_s,

View File

@@ -41,7 +41,8 @@ file 'environment-variables' do
# updated when config is updated.
attributes.merge!(
'force_ssl' => node['firezone']['nginx']['force_ssl'],
'mix_env' => 'prod'
'mix_env' => 'prod',
'telemetry_id' => File.read("#{node["firezone"]["var_directory"]}/cache/telemetry_id")
)
content Firezone::Config.environment_variables_from(attributes)

View File

@@ -60,6 +60,7 @@ if node['firezone']['phoenix']['enabled']
action :enable
subscribes :restart, 'file[environment-variables]'
subscribes :restart, 'file[disable-telemetry]'
subscribes :restart, 'file[telemetry-id]'
end
else
runit_service 'phoenix' do

View File

@@ -11,15 +11,7 @@ require "securerandom"
include_recipe 'firezone::config'
disable_telemetry_path = "#{node['firezone']['install_directory']}/.disable-telemetry"
telemetry_id =
if /[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}/.match?(node['firezone']['telemetry_id'].to_s)
# already generated
node["firezone"]["telemetry_id"]
else
SecureRandom.uuid
end
node.consume_attributes("firezone" => { "telemetry_id" => telemetry_id })
disable_telemetry_path = "#{node['firezone']['var_directory']}/.disable_telemetry"
if node['firezone']['telemetry']['enabled'] == false
file 'disable_telemetry' do
@@ -34,3 +26,20 @@ else
action :delete
end
end
file "telemetry-id" do
telemetry_id =
if /[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}/.match?(node['firezone']['telemetry_id'].to_s)
# already generated
node["firezone"]["telemetry_id"]
else
SecureRandom.uuid
end
path "#{node['firezone']['var_directory']}/cache/telemetry_id"
mode "0440"
owner node["firezone"]["user"]
group node["firezone"]["group"]
content telemetry_id
action :create_if_missing
end

View File

@@ -3,8 +3,8 @@ exec 2>&1
capture () {
if type curl > /dev/null; then
if [ -e /opt/firezone/sv/phoenix/env/TELEMETRY_ID ]; then
telemetry_id=`cat /opt/firezone/sv/phoenix/env/TELEMETRY_ID`
if [ -e /var/opt/firezone/cache/telemetry_id ]; then
telemetry_id=`cat /var/opt/firezone/cache/telemetry_id`
if [ ! -z "$telemetry_id" ]; then
curl -s -XPOST \
-H 'Content-Type: application/json' \
@@ -22,7 +22,7 @@ capture () {
}
if [ $1 -eq "1" ]; then
if [ ! -e /opt/firezone/.disable-telemetry ]; then
if [ ! -e /var/opt/firezone/.disable_telemetry ]; then
capture || true
fi

View File

@@ -16,12 +16,8 @@
# -------------------------------------------------------------------
if ENV["CI"]
base_dir("/opt/runner/omnibus-local")
elsif Dir.exist?("/vagrant")
# Running inside vagrant, use tmp dir
base_dir("/tmp/omnibus-local")
else
# Running on build server, use fast SSD array dir
base_dir("/data/omnibus-local")
base_dir("/tmp/omnibus-local")
end
#
# Alternatively you can tune the individual values

View File

@@ -4,8 +4,8 @@
capture () {
if type curl > /dev/null; then
if [ -e /opt/firezone/sv/phoenix/env/TELEMETRY_ID ]; then
telemetry_id=`cat /opt/firezone/sv/phoenix/env/TELEMETRY_ID`
if [ -e /var/opt/firezone/cache/telemetry_id ]; then
telemetry_id=`cat /var/opt/firezone/cache/telemetry_id`
if [ ! -z "$telemetry_id" ]; then
curl -s -XPOST \
-H 'Content-Type: application/json' \
@@ -21,7 +21,7 @@ capture () {
fi
fi
}
if [ ! -e /opt/firezone/.disable-telemetry ]; then
if [ ! -e /var/opt/firezone/.disable_telemetry ]; then
capture || true
fi

View File

@@ -7,8 +7,8 @@ set -e
capture () {
if type curl > /dev/null; then
if [ -e /opt/firezone/sv/phoenix/env/TELEMETRY_ID ]; then
telemetry_id=`cat /opt/firezone/sv/phoenix/env/TELEMETRY_ID`
if [ -e /var/opt/firezone/cache/telemetry_id ]; then
telemetry_id=`cat /var/opt/firezone/cache/telemetry_id`
if [ ! -z "$telemetry_id" ]; then
curl -s -XPOST \
-H 'Content-Type: application/json' \
@@ -24,7 +24,7 @@ capture () {
fi
fi
}
if [ ! -e /opt/firezone/.disable-telemetry ]; then
if [ ! -e /var/opt/firezone/.disable_telemetry ]; then
capture || true
fi

View File

@@ -7,8 +7,8 @@ set -e
capture () {
if type curl > /dev/null; then
if [ -e /opt/firezone/sv/phoenix/env/TELEMETRY_ID ]; then
telemetry_id=`cat /opt/firezone/sv/phoenix/env/TELEMETRY_ID`
if [ -e /var/opt/firezone/cache/telemetry_id ]; then
telemetry_id=`cat /var/opt/firezone/cache/telemetry_id`
if [ ! -z "$telemetry_id" ]; then
curl -s -XPOST \
-H 'Content-Type: application/json' \
@@ -24,7 +24,7 @@ capture () {
fi
fi
}
if [ ! -e /opt/firezone/.disable-telemetry ]; then
if [ ! -e /var/opt/firezone/.disable_telemetry ]; then
capture || true
fi

View File

@@ -8,8 +8,8 @@ PROGNAME=`basename $0`
capture () {
if type curl > /dev/null; then
if [ -e /opt/firezone/sv/phoenix/env/TELEMETRY_ID ]; then
telemetry_id=`cat /opt/firezone/sv/phoenix/env/TELEMETRY_ID`
if [ -e /var/opt/firezone/cache/telemetry_id ]; then
telemetry_id=`cat /var/opt/firezone/cache/telemetry_id`
if [ ! -z "$telemetry_id" ]; then
curl -s -XPOST \
-H 'Content-Type: application/json' \
@@ -26,7 +26,7 @@ capture () {
fi
}
if [ ! -e /opt/firezone/.disable-telemetry ]; then
if [ ! -e /var/opt/firezone/.disable_telemetry ]; then
capture || true
fi

View File

@@ -1,2 +1,7 @@
{result, 0} = System.cmd(Path.join([__DIR__, "semver.sh"]), [], stderr_to_stdout: true)
result |> String.trim()
case System.cmd(Path.join([__DIR__, "semver.sh"]), [], stderr_to_stdout: true) do
{result, 0} ->
result |> String.trim()
{_error, _exit_code} ->
"0.0.0+git.0.deadbeef"
end