Эх сурвалжийг харах

Install oauth plugin with cloudron support

Girish Ramakrishnan 10 жил өмнө
parent
commit
09f993bb00
4 өөрчлөгдсөн 40 нэмэгдсэн , 7 устгасан
  1. 2 1
      CloudronManifest.json
  2. 1 0
      Dockerfile
  3. 24 0
      README.md
  4. 13 6
      start.sh

+ 2 - 1
CloudronManifest.json

@@ -14,6 +14,7 @@
   "addons": {
     "mysql": {},
     "localstorage": {},
-    "sendmail": {}
+    "sendmail": {},
+    "oauth": {}
   }
 }

+ 1 - 0
Dockerfile

@@ -14,6 +14,7 @@ RUN chmod +x /app/code/start.sh
 RUN curl -o /app/code/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 
 RUN chmod +x /app/code/wp
 
+RUN curl -L -o /app/code/wp-oauth.zip https://github.com//cloudron-io/WP-OAuth/archive/master.zip
 RUN ln -sf /app/data/wp-config.php /app/code/wp-config.php
 
 # configure apache

+ 24 - 0
README.md

@@ -2,6 +2,30 @@ Notes
 =====
 The site_url() will always be the location where you can reach the site by tacking on /wp-admin on the end, while home_url() would not reliably be this location.
 
+put this in wp-config.php for debugging
+
+ // Enable WP_DEBUG mode
+define('WP_DEBUG', true);
+
+// Enable Debug logging to the /wp-content/debug.log file
+define('WP_DEBUG_LOG', true);
+
+// Disable display of errors and warnings 
+define('WP_DEBUG_DISPLAY', false);
+@ini_set('display_errors',0);
+
+// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
+define('SCRIPT_DEBUG', true);
+
+
+
+if ( true === WP_DEBUG ) {
+    if ( is_array( $log ) || is_object( $log ) ) {
+        error_log( print_r( $log, true ) );
+    } else {
+        error_log( $log );
+    }
+}
 Building
 ========
 

+ 13 - 6
start.sh

@@ -2,7 +2,9 @@
 
 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
     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
     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.
     define('WP_HOME',    'https://$(hostname -f)');
     define('WP_SITEURL', 'https://$(hostname -f)');
@@ -29,12 +31,9 @@ if [[ -z "$(ls -A /app/data)" ]]; then
     }
 EOF
 
-    readonly admin_password=$(pwgen -1)
     readonly admin_email=${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}
-    echo "Admin password is ${admin_password}"
 
     $WP --url="https://$(hostname -f)" core install \
-        --allow-root \
         --url="https://$(hostname -f)" \
         --title="My blog" \
         --admin_user=admin \
@@ -42,10 +41,15 @@ EOF
         --admin_email="${admin_email}"
 
     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
     rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data
     ln -sf /app/data/wp-content /app/code/wp-content
+
+    $WP user update "$($WP user get admin --field=ID)" --user_pass="${admin_password}"
 fi
 
 # 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}');/" \
     -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