Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # /etc/php/php.ini
- # uncomment and set cgi.fix_pathinfo to 0
- sed -i -e 's/\;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/php.ini
- # /etc/php/php-fpm.conf
- sed -i -e "s/;pid = run\/php-fpm.pid/pid = \/run\/php-fpm\/php-fpm.pid/;
- s/user = nobody/user = nginx/;
- s/group = nobody/group = nginx/;
- s/;listen.owner = nobody/listen.owner = nginx/;
- s/;listen.group = nobody/listen.group = nginx/;
- s/;listen.mode = 0660/listen.mode = 0660/;" /etc/php/php-fpm.conf
- # Setup Wordpress
- if [[ -f /var/www/config/example-config.php ]]; then
- # start mysql
- service mysql start &
- sleep 10
- # determine environment
- if [[ ! -z $CONTAINER_ENVIRONMENT+x ]]; then
- CONTAINER_ENVIRONMENT="local"
- fi
- # output environment
- echo "CONTAINER_ENVIRONMENT: ${CONTAINER_ENVIRONMENT}"
- # what database is wordpress going to use?
- WORDPRESS_DB="wordpress"
- # generate passwords
- MYSQL_PASSWORD=`pwgen -c -n -1 12`
- WORDPRESS_PASSWORD=`pwgen -c -n -1 12`
- # echo passwords (logs can see them)
- # if you wanted to, you could output them to files.
- echo ""
- echo "--------------------------------------------------------------"
- echo ""
- echo "[ ! ] MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}"
- echo "[ ! ] WORDPRESS_PASSWORD: ${WORDPRESS_PASSWORD}"
- echo ""
- echo "--------------------------------------------------------------"
- echo ""
- # Replace text in the example config file and output to config-${ENVIRONMENT}.php
- sed -e "s/database_name_here/$WORDPRESS_DB/;
- s/username_here/$WORDPRESS_DB/;
- s/password_here/$WORDPRESS_PASSWORD/;
- /'AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'SECURE_AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'LOGGED_IN_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'NONCE_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'SECURE_AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'LOGGED_IN_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/;
- /'NONCE_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/" /var/www/config/example-config.php > /var/www/config/config-${CONTAINER_ENVIRONMENT}.php
- # Remove the example config file
- rm /var/www/config/example-config.php
- # Plugin: wpMandrill
- echo "Downloading and unpacking plugin: wpmandrill..."
- curl -O `curl -i -s https://wordpress.org/plugins/wpmandrill/ | egrep -o "https://downloads.wordpress.org/plugin/[^']+"`
- unzip -qqo wpmandrill.zip -d /var/www/wp-content/plugins
- echo "Plugin unpacked."
- echo ""
- # Plugin: WP Migrate DB
- echo "Downloading and unpacking plugin: wp-migrate-db..."
- curl -O `curl -i -s https://wordpress.org/plugins/wp-migrate-db/ | egrep -o "https://downloads.wordpress.org/plugin/[^']+"`
- unzip -qqo wp-migrate-db.*.zip -d /var/www/wp-content/plugins
- echo "Plugin unpacked."
- echo ""
- # Set permissions on the new plugins
- find /var/www/wp-content -type d -print0 | xargs -0 chmod 0755
- find /var/www/wp-content -type f -print0 | xargs -0 chmod 0644
- # Clean up: Remove the downloaded zip files
- rm nginx-helper.*.zip wpmandrill.zip wp-migrate-db.*.zip
- # Ensure nginx owns all the things
- chown nginx:nginx /var/www/config/config-${CONTAINER_ENVIRONMENT}.php
- chown -R nginx:nginx /var/www/wp-content/*
- # Setup MySQL
- /usr/bin/mysqladmin -u root password $MYSQL_PASSWORD
- mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
- mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;"
- killall mysqld
- # wait so we can restart mysqld
- echo "Environment configuration complete."
- echo "Please wait..."
- sleep 10
- fi
- echo ""
- echo "Starting container services..."
- # Start services
- service mysql start
- echo "Starting php-fpm..."
- php-fpm
- echo "Starting nginx..."
- nginx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement