[verified] Remove cwctl telemetry from installer
This commit is contained in:
@@ -21,7 +21,6 @@ LONGOPTS=console,debug,help,install,Install:,logs:,restart,ssl,upgrade,Upgrade:,
|
||||
OPTIONS=cdhiI:l:rsuU:wvWK
|
||||
CWCTL_VERSION="3.5.0"
|
||||
pg_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15 ; echo '')
|
||||
CHATWOOT_HUB_URL="https://hub.2.chatwoot.com/events"
|
||||
|
||||
# if user does not specify an option
|
||||
if [ "$#" -eq 0 ]; then
|
||||
@@ -629,44 +628,44 @@ EOF
|
||||
read -rp 'Would you like to install Postgres and Redis? (Answer no if you plan to use external services)(yes or no): ' install_pg_redis
|
||||
|
||||
echo -en "\n➥ 1/9 Installing dependencies. This takes a while.\n"
|
||||
install_dependencies &>> "${LOG_FILE}"
|
||||
install_dependencies >> "${LOG_FILE}" 2>&1
|
||||
|
||||
if [ "$install_pg_redis" != "no" ]; then
|
||||
echo "➥ 2/9 Installing databases."
|
||||
install_databases &>> "${LOG_FILE}"
|
||||
install_databases >> "${LOG_FILE}" 2>&1
|
||||
else
|
||||
echo "➥ 2/9 Skipping Postgres and Redis installation."
|
||||
fi
|
||||
|
||||
if [ "$configure_webserver" == "yes" ]; then
|
||||
echo "➥ 3/9 Installing webserver."
|
||||
install_webserver &>> "${LOG_FILE}"
|
||||
install_webserver >> "${LOG_FILE}" 2>&1
|
||||
else
|
||||
echo "➥ 3/9 Skipping webserver installation."
|
||||
fi
|
||||
|
||||
echo "➥ 4/9 Setting up Ruby"
|
||||
configure_rvm &>> "${LOG_FILE}"
|
||||
configure_rvm >> "${LOG_FILE}" 2>&1
|
||||
|
||||
if [ "$install_pg_redis" != "no" ]; then
|
||||
echo "➥ 5/9 Setting up the database."
|
||||
configure_db &>> "${LOG_FILE}"
|
||||
configure_db >> "${LOG_FILE}" 2>&1
|
||||
else
|
||||
echo "➥ 5/9 Skipping database setup."
|
||||
fi
|
||||
|
||||
echo "➥ 6/9 Installing Chatwoot. This takes a long while."
|
||||
setup_chatwoot &>> "${LOG_FILE}"
|
||||
setup_chatwoot >> "${LOG_FILE}" 2>&1
|
||||
|
||||
if [ "$install_pg_redis" != "no" ]; then
|
||||
echo "➥ 7/9 Running database migrations."
|
||||
run_db_migrations &>> "${LOG_FILE}"
|
||||
run_db_migrations >> "${LOG_FILE}" 2>&1
|
||||
else
|
||||
echo "➥ 7/9 Skipping database migrations."
|
||||
fi
|
||||
|
||||
echo "➥ 8/9 Setting up systemd services."
|
||||
configure_systemd_services &>> "${LOG_FILE}"
|
||||
configure_systemd_services >> "${LOG_FILE}" 2>&1
|
||||
|
||||
public_ip=$(curl http://checkip.amazonaws.com -s)
|
||||
|
||||
@@ -689,7 +688,7 @@ EOF
|
||||
cwctl_message
|
||||
else
|
||||
echo "➥ 9/9 Setting up SSL/TLS."
|
||||
setup_ssl &>> "${LOG_FILE}"
|
||||
setup_ssl >> "${LOG_FILE}" 2>&1
|
||||
ssl_success_message
|
||||
cwctl_message
|
||||
fi
|
||||
@@ -958,7 +957,6 @@ EOF
|
||||
# None
|
||||
##############################################################################
|
||||
function upgrade() {
|
||||
cwctl_upgrade_check
|
||||
get_cw_version
|
||||
echo "Upgrading Chatwoot to v$CW_VERSION (branch: $BRANCH)"
|
||||
|
||||
@@ -1129,56 +1127,6 @@ function webserver() {
|
||||
#TODO(@vn): allow installing nginx only without SSL
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Report cwctl events to hub
|
||||
# Globals:
|
||||
# CHATWOOT_HUB_URL
|
||||
# Arguments:
|
||||
# event_name: Name of the event to report
|
||||
# event_data: Data to report
|
||||
# installation_identifier: Installation identifier
|
||||
# Outputs:
|
||||
# None
|
||||
##############################################################################
|
||||
function report_event() {
|
||||
local event_name="$1"
|
||||
local event_data="$2"
|
||||
|
||||
CHATWOOT_HUB_URL="https://hub.2.chatwoot.com/events"
|
||||
|
||||
# get installation identifier
|
||||
local installation_identifier=$(get_installation_identifier)
|
||||
|
||||
# Prepare the data for the request
|
||||
local data="{\"installation_identifier\":\"$installation_identifier\",\"event_name\":\"$event_name\",\"event_data\":{\"action\":\"$event_data\"}}"
|
||||
|
||||
# Make the curl request to report the event
|
||||
curl -X POST -H "Content-Type: application/json" -d "$data" "$CHATWOOT_HUB_URL" -s -o /dev/null
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Get installation identifier
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# None
|
||||
# Outputs:
|
||||
# installation_identifier
|
||||
##############################################################################
|
||||
function get_installation_identifier() {
|
||||
|
||||
local installation_identifier
|
||||
|
||||
installation_identifier=$(sudo -i -u chatwoot << "EOF"
|
||||
cd chatwoot
|
||||
RAILS_ENV=production bundle exec rake instance_id:get_installation_identifier
|
||||
EOF
|
||||
)
|
||||
echo "$installation_identifier"
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Print cwctl version (-v/--version)
|
||||
# Globals:
|
||||
@@ -1192,83 +1140,6 @@ function version() {
|
||||
echo "cwctl v$CWCTL_VERSION"
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Check if there is newer version of cwctl and upgrade if found
|
||||
# Globals:
|
||||
# CWCTL_VERSION
|
||||
# Arguments:
|
||||
# remote_version_url = URL to fetch the remote version from
|
||||
# remote_version = Remote version of cwctl
|
||||
# Outputs:
|
||||
# None
|
||||
##############################################################################
|
||||
function cwctl_upgrade_check() {
|
||||
echo "Checking for cwctl updates..."
|
||||
|
||||
local remote_version_url="https://raw.githubusercontent.com/chatwoot/chatwoot/master/VERSION_CWCTL"
|
||||
local remote_version=$(curl -s "$remote_version_url")
|
||||
|
||||
#Check if pip is not installed, and install it if not
|
||||
if ! command -v pip3 &> /dev/null; then
|
||||
echo "Installing pip..."
|
||||
apt-get install -y python3-pip
|
||||
fi
|
||||
|
||||
# Check if packaging library is installed, and install it if not
|
||||
if ! python3 -c "import packaging.version" &> /dev/null; then
|
||||
echo "Installing packaging library..."
|
||||
install_packaging
|
||||
fi
|
||||
|
||||
needs_update=$(python3 -c "from packaging import version; v1 = version.parse('$CWCTL_VERSION'); v2 = version.parse('$remote_version'); print(1 if v2 > v1 else 0)")
|
||||
|
||||
if [ "$needs_update" -eq 1 ]; then
|
||||
echo "Upgrading cwctl from $CWCTL_VERSION to $remote_version"
|
||||
upgrade_cwctl
|
||||
echo $'\U0002713 Done'
|
||||
echo $'\U0001F680 Please re-run your command'
|
||||
exit 0
|
||||
else
|
||||
echo "Your cwctl is up to date"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Check for PEP 668 restrictions and install packaging accordingly
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# None
|
||||
# Outputs:
|
||||
# None
|
||||
##############################################################################
|
||||
function install_packaging() {
|
||||
ubuntu_version=$(lsb_release -r | awk '{print $2}')
|
||||
if [[ "$ubuntu_version" == "24.04" ]]; then
|
||||
echo "Detected Ubuntu 24.04. Installing packaging library using apt."
|
||||
apt-get install -y python3-packaging
|
||||
else
|
||||
echo "Installing packaging library using pip."
|
||||
python3 -m pip install packaging
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
# upgrade cwctl
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# None
|
||||
# Outputs:
|
||||
# None
|
||||
##############################################################################
|
||||
function upgrade_cwctl() {
|
||||
wget https://get.chatwoot.app/linux/install.sh -O /usr/local/bin/cwctl > /dev/null 2>&1 && chmod +x /usr/local/bin/cwctl
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# main function that handles the control flow
|
||||
# Globals:
|
||||
@@ -1282,52 +1153,42 @@ function main() {
|
||||
setup_logging
|
||||
|
||||
if [ "$c" == "y" ]; then
|
||||
report_event "cwctl" "console" > /dev/null 2>&1
|
||||
get_console
|
||||
fi
|
||||
|
||||
if [ "$h" == "y" ]; then
|
||||
report_event "cwctl" "help" > /dev/null 2>&1
|
||||
help
|
||||
fi
|
||||
|
||||
if [ "$i" == "y" ] || [ "$I" == "y" ]; then
|
||||
install
|
||||
report_event "cwctl" "install" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ "$l" == "y" ]; then
|
||||
report_event "cwctl" "logs" > /dev/null 2>&1
|
||||
get_logs
|
||||
fi
|
||||
|
||||
if [ "$r" == "y" ]; then
|
||||
report_event "cwctl" "restart" > /dev/null 2>&1
|
||||
restart
|
||||
fi
|
||||
|
||||
if [ "$s" == "y" ]; then
|
||||
report_event "cwctl" "ssl" > /dev/null 2>&1
|
||||
ssl
|
||||
fi
|
||||
|
||||
if [ "$u" == "y" ] || [ "$U" == "y" ]; then
|
||||
report_event "cwctl" "upgrade" > /dev/null 2>&1
|
||||
upgrade
|
||||
fi
|
||||
|
||||
if [ "$w" == "y" ]; then
|
||||
report_event "cwctl" "webserver" > /dev/null 2>&1
|
||||
webserver
|
||||
fi
|
||||
|
||||
if [ "$v" == "y" ]; then
|
||||
report_event "cwctl" "version" > /dev/null 2>&1
|
||||
version
|
||||
fi
|
||||
|
||||
if [ "$C" == "y" ]; then
|
||||
report_event "cwctl" "convert" > /dev/null 2>&1
|
||||
convert_deployment
|
||||
fi
|
||||
|
||||
|
||||
35
deployment/spec/setup_20.04_privacy_test.sh
Normal file
35
deployment/spec/setup_20.04_privacy_test.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -u
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
SETUP_SCRIPT="$SCRIPT_DIR/../setup_20.04.sh"
|
||||
|
||||
fail() {
|
||||
printf 'FAIL: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -f "$SETUP_SCRIPT" ] || fail "setup script not found"
|
||||
|
||||
forbidden_patterns=(
|
||||
'report_event'
|
||||
'hub\.2\.chatwoot\.com/events'
|
||||
'installation_identifier.*event_name'
|
||||
'raw\.githubusercontent\.com/chatwoot/chatwoot/master/VERSION_CWCTL'
|
||||
'get\.chatwoot\.app/linux/install\.sh'
|
||||
'cwctl_upgrade_check'
|
||||
'upgrade_cwctl'
|
||||
)
|
||||
|
||||
for pattern in "${forbidden_patterns[@]}"; do
|
||||
if grep -E -q "$pattern" "$SETUP_SCRIPT"; then
|
||||
fail "forbidden cwctl telemetry or vendor updater pattern: $pattern"
|
||||
else
|
||||
grep_status=$?
|
||||
if [ "$grep_status" -ne 1 ]; then
|
||||
fail "unable to scan setup script for pattern: $pattern (grep status $grep_status)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
printf '%s\n' 'PASS: cwctl privacy test'
|
||||
Reference in New Issue
Block a user