Skip to content

Instantly share code, notes, and snippets.

@adrian7
Created February 10, 2016 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrian7/96940b05ce8526da9ae3 to your computer and use it in GitHub Desktop.
Save adrian7/96940b05ce8526da9ae3 to your computer and use it in GitHub Desktop.
Copies environment variables strarting with prefixes_ to php-fpm pool.conf file
### Append Container variables to PHP-FPM pool configuration ###
PHP5_CONFIG_FILE=/etc/php5/fpm/pool.d/www.conf
echo "" >> $PHP5_CONFIG_FILE;
echo ";container environment variables" >> $PHP5_CONFIG_FILE;
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for i in $(env)
do
variable=$(echo "$i" | cut -d'=' -f1)
value=$(echo "$i" | cut -d'=' -f2)
if [[ $variable == ENV_* ]] || [[ $variable == AWS_* ]] || [[ $variable == APP_* ]] || [[ $variable == PHP_* ]] ;
then
#Append variable to PHP5 www.conf file
echo "env[$variable] = \"$value\"" >> $PHP5_CONFIG_FILE;
fi
done
IFS=$SAVEIFS
### Append Container variables to PHP-FPM pool configuration ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment