:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(hobby): preserve .env on reinstall instead of overwriting (#59486)
Georges-Antoine Assi926e4b0b011f
diff --git a/bin/deploy-hobby b/bin/deploy-hobbyindex 36384ef4bbeb..06f9df546c51 100755--- a/bin/deploy-hobby+++ b/bin/deploy-hobby@@ -9,12 +9,6 @@ export DEBIAN_FRONTEND=noninteractiveexport RESTART_MODE=lexport POSTHOG_APP_TAG="${POSTHOG_APP_TAG:-latest}"-POSTHOG_SECRET=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)-export POSTHOG_SECRET--ENCRYPTION_SALT_KEYS=$(openssl rand -hex 16)-export ENCRYPTION_SALT_KEYS-# Talk to the userecho "Welcome to the single instance PostHog installer 🦔"echo ""@@ -129,10 +123,18 @@ thenexport REGISTRY_URL="posthog/posthog"fi---# Write .env file-cat > .env <<EOF+# Write .env only on a fresh install. On a re-run (e.g. after a partial+# failure) preserve the existing file, so POSTHOG_SECRET and+# ENCRYPTION_SALT_KEYS are not regenerated, as it would invalidate active+# sessions and corrupt encrypted data on a live instance.+# Mirrors the FileExists(".env") guard in bin/hobby-installer.+# Tag changes on an existing instance are handled by bin/upgrade-hobby.+if [ -f .env ]; then+ echo "Existing .env found, preserving configuration"+else+ POSTHOG_SECRET=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)+ ENCRYPTION_SALT_KEYS=$(openssl rand -hex 16)+ cat > .env <<EOFPOSTHOG_SECRET=$POSTHOG_SECRETENCRYPTION_SALT_KEYS=$ENCRYPTION_SALT_KEYSDOMAIN=$DOMAIN@@ -142,6 +144,7 @@ CADDY_TLS_BLOCK=$TLS_BLOCKCADDY_HOST="$DOMAIN, http://, https://"POSTHOG_APP_TAG=$POSTHOG_APP_TAGEOF+fi# Download GeoLite2-City.mmdb if it doesn't existecho "Downloading GeoIP database file"