From 411f42edb238275aa8ec2a74262bd8abef77b454 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 27 May 2022 16:30:45 -0700 Subject: [PATCH] wordpress: Allow installing/updating plugins and themes Based on work by Benedek Nagy at: https://salsa.debian.org/freedombox-team/freedombox/-/merge_requests/2198 Tests: - Install WordPress without this patch. Then switch to code with this patch. Restart FreedomBox. WordPress setup should get executed and the setup version should get incremented to 2. The configuration file should contain the include line for freedombox-static.php. freedombox-static.php should be installed and should contain the line for setting FS_METHOD to 'direct'. - Uninstall WordPress and wipe everything. Install WordPress freshly using this patch. The line to include freedombox-static.php should be present in the default configuration file. freedombox-static.php should be installed and should contain the line for setting FS_METHOD to 'direct'. - Installing a new theme using a URL and setting the default theme to the new theme should work. - Installing a plugin and enabling it should work. - Installing an older version of a plugin and then updating it should work. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/wordpress | 14 ++++++++++++++ plinth/modules/wordpress/__init__.py | 5 +++-- .../data/etc/wordpress/freedombox-static.php | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 plinth/modules/wordpress/data/etc/wordpress/freedombox-static.php diff --git a/actions/wordpress b/actions/wordpress index 45397027e..fe9fb2aa0 100755 --- a/actions/wordpress +++ b/actions/wordpress @@ -18,6 +18,7 @@ from plinth import action_utils from plinth.modules.wordpress import PUBLIC_ACCESS_FILE _config_file_path = pathlib.Path('/etc/wordpress/config-default.php') +_static_config_file_path = pathlib.Path('/etc/wordpress/freedombox-static.php') _db_file_path = pathlib.Path('/etc/wordpress/database.php') _db_backup_file = pathlib.Path( '/var/lib/plinth/backups-data/wordpress-database.sql') @@ -48,6 +49,9 @@ def parse_arguments(): def subcommand_setup(_): """Create initial configuration and database for WordPress.""" if _db_file_path.exists() or _config_file_path.exists(): + if _config_file_path.exists(): + _upgrade_config_file() + return db_password = _generate_secret_key(16) @@ -63,6 +67,7 @@ def _create_config_file(db_host, db_name, db_user, db_password): config_contents = f'''