|  | @@ -2,7 +2,9 @@
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  set -eux
 |  |  set -eux
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -readonly WP=/app/code/wp
 |  | 
 | 
											
												
													
														|  | 
 |  | +readonly WP="/app/code/wp --allow-root"
 | 
											
												
													
														|  | 
 |  | +readonly admin_password=$(pwgen -1)
 | 
											
												
													
														|  | 
 |  | +echo "Admin password is ${admin_password}"
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  if [[ -z "$(ls -A /app/data)" ]]; then
 |  |  if [[ -z "$(ls -A /app/data)" ]]; then
 | 
											
												
													
														|  |      echo "Copying wp-content files on first run"
 |  |      echo "Copying wp-content files on first run"
 | 
											
										
											
												
													
														|  | @@ -10,7 +12,7 @@ if [[ -z "$(ls -A /app/data)" ]]; then
 | 
											
												
													
														|  |      rm -rf /app/code/wp-content
 |  |      rm -rf /app/code/wp-content
 | 
											
												
													
														|  |      ln -sf /app/data/wp-content /app/code/wp-content
 |  |      ln -sf /app/data/wp-content /app/code/wp-content
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    $WP core config --allow-root --dbname="${MYSQL_DATABASE}" --dbuser="${MYSQL_USERNAME}" --dbpass="${MYSQL_PASSWORD}" --dbhost="${MYSQL_HOST}" --extra-php <<EOF
 |  | 
 | 
											
												
													
														|  | 
 |  | +    $WP core config --dbname="${MYSQL_DATABASE}" --dbuser="${MYSQL_USERNAME}" --dbpass="${MYSQL_PASSWORD}" --dbhost="${MYSQL_HOST}" --extra-php <<EOF
 | 
											
												
													
														|  |      // prevent user from changing the Settings->General, WordPress and Blog address values.
 |  |      // prevent user from changing the Settings->General, WordPress and Blog address values.
 | 
											
												
													
														|  |      define('WP_HOME',    'https://$(hostname -f)');
 |  |      define('WP_HOME',    'https://$(hostname -f)');
 | 
											
												
													
														|  |      define('WP_SITEURL', 'https://$(hostname -f)');
 |  |      define('WP_SITEURL', 'https://$(hostname -f)');
 | 
											
										
											
												
													
														|  | @@ -29,12 +31,9 @@ if [[ -z "$(ls -A /app/data)" ]]; then
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  EOF
 |  |  EOF
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    readonly admin_password=$(pwgen -1)
 |  | 
 | 
											
												
													
														|  |      readonly admin_email=${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}
 |  |      readonly admin_email=${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}
 | 
											
												
													
														|  | -    echo "Admin password is ${admin_password}"
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      $WP --url="https://$(hostname -f)" core install \
 |  |      $WP --url="https://$(hostname -f)" core install \
 | 
											
												
													
														|  | -        --allow-root \
 |  | 
 | 
											
												
													
														|  |          --url="https://$(hostname -f)" \
 |  |          --url="https://$(hostname -f)" \
 | 
											
												
													
														|  |          --title="My blog" \
 |  |          --title="My blog" \
 | 
											
												
													
														|  |          --admin_user=admin \
 |  |          --admin_user=admin \
 | 
											
										
											
												
													
														|  | @@ -42,10 +41,15 @@ EOF
 | 
											
												
													
														|  |          --admin_email="${admin_email}"
 |  |          --admin_email="${admin_email}"
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      echo "Installing OAuth plugin"
 |  |      echo "Installing OAuth plugin"
 | 
											
												
													
														|  | -    ./wp plugin install --allow-root --activate --force https://github.com//cloudron-io/WP-OAuth/archive/5e77ff326b26f6175fefcd25f46d6c45e0fa14fa.zip
 |  | 
 | 
											
												
													
														|  | 
 |  | +    $WP plugin install --activate --force /app/code/wp-oauth.zip
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    $WP option update users_can_register 1
 | 
											
												
													
														|  | 
 |  | +    $WP option update wpoa_cloudron_api_enabled 1
 | 
											
												
													
														|  |  else
 |  |  else
 | 
											
												
													
														|  |      rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data
 |  |      rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data
 | 
											
												
													
														|  |      ln -sf /app/data/wp-content /app/code/wp-content
 |  |      ln -sf /app/data/wp-content /app/code/wp-content
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    $WP user update "$($WP user get admin --field=ID)" --user_pass="${admin_password}"
 | 
											
												
													
														|  |  fi
 |  |  fi
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  # Settings to be updated on every run
 |  |  # Settings to be updated on every run
 | 
											
										
											
												
													
														|  | @@ -55,5 +59,8 @@ sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${MYSQL_DATABASE}');/" \
 | 
											
												
													
														|  |      -e "s/define('DB_HOST',.*/define('DB_HOST', '${MYSQL_HOST}');/" \
 |  |      -e "s/define('DB_HOST',.*/define('DB_HOST', '${MYSQL_HOST}');/" \
 | 
											
												
													
														|  |      -i /app/data/wp-config.php # sed -i seems to destroy symlink
 |  |      -i /app/data/wp-config.php # sed -i seems to destroy symlink
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +$WP option update wpoa_cloudron_api_id "${OAUTH_CLIENT_ID}"
 | 
											
												
													
														|  | 
 |  | +$WP option update wpoa_cloudron_api_secret "${OAUTH_CLIENT_SECRET}"
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i WordPress
 |  |  /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i WordPress
 | 
											
												
													
														|  |  
 |  |  
 |