SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | # /etc/php/php.ini | |
| 4 | # uncomment and set cgi.fix_pathinfo to 0 | |
| 5 | sed -i -e 's/\;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/php.ini | |
| 6 | ||
| 7 | # /etc/php/php-fpm.conf | |
| 8 | sed -i -e "s/;pid = run\/php-fpm.pid/pid = \/run\/php-fpm\/php-fpm.pid/; | |
| 9 | s/user = nobody/user = nginx/; | |
| 10 | s/group = nobody/group = nginx/; | |
| 11 | s/;listen.owner = nobody/listen.owner = nginx/; | |
| 12 | s/;listen.group = nobody/listen.group = nginx/; | |
| 13 | s/;listen.mode = 0660/listen.mode = 0660/;" /etc/php/php-fpm.conf | |
| 14 | ||
| 15 | # Setup Wordpress | |
| 16 | if [[ -f /var/www/config/example-config.php ]]; then | |
| 17 | ||
| 18 | # start mysql | |
| 19 | service mysql start & | |
| 20 | sleep 10 | |
| 21 | ||
| 22 | # determine environment | |
| 23 | if [[ ! -z $CONTAINER_ENVIRONMENT+x ]]; then | |
| 24 | CONTAINER_ENVIRONMENT="local" | |
| 25 | fi | |
| 26 | ||
| 27 | # output environment | |
| 28 | echo "CONTAINER_ENVIRONMENT: ${CONTAINER_ENVIRONMENT}"
| |
| 29 | ||
| 30 | # what database is wordpress going to use? | |
| 31 | WORDPRESS_DB="wordpress" | |
| 32 | ||
| 33 | # generate passwords | |
| 34 | MYSQL_PASSWORD=`pwgen -c -n -1 12` | |
| 35 | WORDPRESS_PASSWORD=`pwgen -c -n -1 12` | |
| 36 | ||
| 37 | # echo passwords (logs can see them) | |
| 38 | # if you wanted to, you could output them to files. | |
| 39 | echo "" | |
| 40 | echo "--------------------------------------------------------------" | |
| 41 | echo "" | |
| 42 | echo "[ ! ] MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}"
| |
| 43 | echo "[ ! ] WORDPRESS_PASSWORD: ${WORDPRESS_PASSWORD}"
| |
| 44 | echo "" | |
| 45 | echo "--------------------------------------------------------------" | |
| 46 | echo "" | |
| 47 | ||
| 48 | # Replace text in the example config file and output to config-${ENVIRONMENT}.php
| |
| 49 | sed -e "s/database_name_here/$WORDPRESS_DB/; | |
| 50 | s/username_here/$WORDPRESS_DB/; | |
| 51 | s/password_here/$WORDPRESS_PASSWORD/; | |
| 52 | /'AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 53 | /'SECURE_AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 54 | /'LOGGED_IN_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 55 | /'NONCE_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 56 | /'AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 57 | /'SECURE_AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 58 | /'LOGGED_IN_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/; | |
| 59 | /'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
| |
| 60 | ||
| 61 | # Remove the example config file | |
| 62 | rm /var/www/config/example-config.php | |
| 63 | ||
| 64 | # Plugin: wpMandrill | |
| 65 | echo "Downloading and unpacking plugin: wpmandrill..." | |
| 66 | curl -O `curl -i -s https://wordpress.org/plugins/wpmandrill/ | egrep -o "https://downloads.wordpress.org/plugin/[^']+"` | |
| 67 | unzip -qqo wpmandrill.zip -d /var/www/wp-content/plugins | |
| 68 | echo "Plugin unpacked." | |
| 69 | echo "" | |
| 70 | ||
| 71 | # Plugin: WP Migrate DB | |
| 72 | echo "Downloading and unpacking plugin: wp-migrate-db..." | |
| 73 | curl -O `curl -i -s https://wordpress.org/plugins/wp-migrate-db/ | egrep -o "https://downloads.wordpress.org/plugin/[^']+"` | |
| 74 | unzip -qqo wp-migrate-db.*.zip -d /var/www/wp-content/plugins | |
| 75 | echo "Plugin unpacked." | |
| 76 | echo "" | |
| 77 | ||
| 78 | # Set permissions on the new plugins | |
| 79 | find /var/www/wp-content -type d -print0 | xargs -0 chmod 0755 | |
| 80 | find /var/www/wp-content -type f -print0 | xargs -0 chmod 0644 | |
| 81 | ||
| 82 | # Clean up: Remove the downloaded zip files | |
| 83 | rm nginx-helper.*.zip wpmandrill.zip wp-migrate-db.*.zip | |
| 84 | ||
| 85 | # Ensure nginx owns all the things | |
| 86 | chown nginx:nginx /var/www/config/config-${CONTAINER_ENVIRONMENT}.php
| |
| 87 | chown -R nginx:nginx /var/www/wp-content/* | |
| 88 | ||
| 89 | # Setup MySQL | |
| 90 | /usr/bin/mysqladmin -u root password $MYSQL_PASSWORD | |
| 91 | mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
| 92 | mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;" | |
| 93 | killall mysqld | |
| 94 | ||
| 95 | # wait so we can restart mysqld | |
| 96 | echo "Environment configuration complete." | |
| 97 | echo "Please wait..." | |
| 98 | sleep 10 | |
| 99 | fi | |
| 100 | ||
| 101 | echo "" | |
| 102 | echo "Starting container services..." | |
| 103 | ||
| 104 | # Start services | |
| 105 | service mysql start | |
| 106 | ||
| 107 | echo "Starting php-fpm..." | |
| 108 | php-fpm | |
| 109 | ||
| 110 | echo "Starting nginx..." | |
| 111 | nginx |