kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo

Enhance environment variable replacement script

- Replace inefficient find+sed loop with grep -l filtering
- Use # delimiter instead of | for safer URL handling
- Add xargs -r to prevent errors on empty results
- Add dedicated block for KANEO_CLIENT_URL like KANEO_API_URL
- Reduces startup time from minutes to seconds

authored by

fsmeets84 and committed by
GitHub
7fc4c076 c4a48bcf

+32 -15
+32 -15
apps/web/env.sh
··· 3 3 4 4 echo "Starting environment variable replacement..." 5 5 6 - # Look specifically for the KANEO_API_URL environment variable 6 + # Process KANEO_API_URL first (with special handling) 7 7 if [ ! -z "$KANEO_API_URL" ]; then 8 8 echo "Found KANEO_API_URL: $KANEO_API_URL" 9 - 9 + 10 10 # First, replace the exact string "KANEO_API_URL" in all JavaScript files 11 - find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "KANEO_API_URL" {} \; | xargs -I{} sed -i "s|KANEO_API_URL|$KANEO_API_URL|g" {} 12 - 11 + # Use grep -l to only process files that contain the string 12 + find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "KANEO_API_URL" {} \; | xargs -r sed -i "s#KANEO_API_URL#$KANEO_API_URL#g" 13 + 13 14 # Also check for the escaped version which might appear in some files 14 - find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "\"KANEO_API_URL\"" {} \; | xargs -I{} sed -i "s|\"KANEO_API_URL\"|\"$KANEO_API_URL\"|g" {} 15 - 16 - echo "Replaced KANEO_API_URL with $KANEO_API_URL" 15 + find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "\"KANEO_API_URL\"" {} \; | xargs -r sed -i "s#\"KANEO_API_URL\"#\"$KANEO_API_URL\"#g" 16 + 17 + echo "✅ Replaced KANEO_API_URL with $KANEO_API_URL" 17 18 else 18 19 echo "WARNING: KANEO_API_URL environment variable is not set. API calls may fail." 19 20 fi 20 21 21 - # Process any other KANEO_ prefixed environment variables 22 - for envvar in $(env | grep KANEO_ | grep -v KANEO_API_URL) 23 - do 24 - key=$(echo $envvar | cut -d '=' -f 1) 25 - value=$(echo $envvar | cut -d '=' -f 2-) 26 - echo "Replacing $key with $value" 22 + # Process KANEO_CLIENT_URL efficiently 23 + if [ ! -z "$KANEO_CLIENT_URL" ]; then 24 + echo "Found KANEO_CLIENT_URL: $KANEO_CLIENT_URL" 25 + 26 + # Only process files that actually contain the string 27 + find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "KANEO_CLIENT_URL" {} \; | xargs -r sed -i "s#KANEO_CLIENT_URL#$KANEO_CLIENT_URL#g" 28 + find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "\"KANEO_CLIENT_URL\"" {} \; | xargs -r sed -i "s#\"KANEO_CLIENT_URL\"#\"$KANEO_CLIENT_URL\"#g" 29 + 30 + echo "✅ Replaced KANEO_CLIENT_URL with $KANEO_CLIENT_URL" 31 + fi 27 32 28 - find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.css" \) -exec sed -i "s|$key|$value|g" {} \; 33 + # Process any other KANEO_ prefixed environment variables (for future extensibility) 34 + # Exclude the ones we've already processed 35 + for key in $(env | grep '^KANEO_' | grep -v 'KANEO_API_URL\|KANEO_CLIENT_URL' | cut -d= -f1); do 36 + value=$(printenv "$key") 37 + 38 + if [ ! -z "$value" ]; then 39 + echo "Found $key: $value" 40 + 41 + # Only process files that contain this specific key 42 + find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.css" \) -exec grep -l "$key" {} \; | xargs -r sed -i "s#$key#$value#g" 43 + 44 + echo "✅ Replaced $key with $value" 45 + fi 29 46 done 30 47 31 - echo "Environment variable replacement complete" 48 + echo "✅ Environment variable replacement complete"