12 Commits

Author SHA1 Message Date
Gabriel Cossette d0e5df6476 Merge branch 'testing' of https://git.weblibre.ca/gabriel/wordpress_ynh 5 years ago
Gabriel Cossette 6f0bdaf821 update 5 years ago
Gabriel Cossette 0c187f0f8a update 5 years ago
Gabriel Cossette 3c95a557d8 update 5 years ago
Gabriel Cossette ad1a11782f update 5 years ago
Gabriel Cossette 8b0653084b update 5 years ago
Gabriel Cossette 8f9d3742aa update 5 years ago
Kay0u a1f5170497
fix the url 5 years ago
Kay0u 232c2a1cde
5.7.2 5 years ago
Kayou cec3f6705c
Merge pull request #141 from YunoHost-Apps/fix-upgrade 5 years ago
Kay0u 9a8862cc87
replace db_prefix in the install script 5 years ago
Kay0u 31018d9a47
fix upgrade 5 years ago
  1. 2
      README.md
  2. 2
      README_fr.md
  3. 4
      conf/app.src
  4. 6
      conf/extra_php-fpm.conf
  5. 123
      conf/fastcgi.conf
  6. 31
      conf/nginx-cache-custom/includes/settings-page.css
  7. 41
      conf/nginx-cache-custom/includes/settings-page.php
  8. 95
      conf/nginx-cache-custom/languages/nginx-cache.pot
  9. 316
      conf/nginx-cache-custom/nginx-cache.php
  10. 66
      conf/nginx-cache-custom/readme.txt
  11. 312
      conf/nginx-cache.conf
  12. 268
      conf/nginx-standard.conf
  13. 37
      conf/nginx.conf
  14. 2
      conf/sql/multisite.sql
  15. 2
      conf/sql/single.sql
  16. 16
      config_panel.toml
  17. 66
      manifest.json
  18. 2
      scripts/_common.sh
  19. 15
      scripts/config
  20. 134
      scripts/install
  21. 36
      scripts/remove
  22. 6
      scripts/upgrade

2
README.md

@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
WordPress is open source software you can use to create a beautiful website, blog, or app. WordPress is open source software you can use to create a beautiful website, blog, or app.
With this package, you can even activate the [multisite](https://wordpress.org/support/article/glossary/#multisite) option. With this package, you can even activate the [multisite](https://wordpress.org/support/article/glossary/#multisite) option.
**Shipped version:** 5.7
**Shipped version:** 5.7.2
## Screenshots ## Screenshots

2
README_fr.md

@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install
WordPress est un logiciel libre que vous pouvez utiliser pour créer un site ou un blog. WordPress est un logiciel libre que vous pouvez utiliser pour créer un site ou un blog.
Avec ce package, vous pouvez même activer l'option [multisite](https://codex.wordpress.org/Glossary#Multisite). Avec ce package, vous pouvez même activer l'option [multisite](https://codex.wordpress.org/Glossary#Multisite).
**Version incluse :** 5.7
**Version incluse :** 5.7.2
## Captures d'écran ## Captures d'écran

4
conf/app.src

@ -1,5 +1,5 @@
SOURCE_URL=https://wordpress.org/wordpress-5.7.tar.gz
SOURCE_SUM=92be8c4afd0186f783a12bad994baecc8f941a88535acddecbae0d7702169b71
SOURCE_URL=https://wordpress.org/wordpress-5.7.2.tar.gz
SOURCE_SUM=eb8d05208159469d0be3cb339f7b6a150a39f503faf679c255028433f5131219
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
ARCH_FORMAT=tar.gz ARCH_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

6
conf/extra_php-fpm.conf

@ -1,5 +1,5 @@
; Additional php.ini defines, specific to this pool of workers. ; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 50M
php_admin_value[memory_limit] = 64M
php_admin_value[post_max_size] = 50M
php_admin_value[upload_max_filesize] = 1G
php_admin_value[memory_limit] = 128M
php_admin_value[post_max_size] = 1G

123
conf/fastcgi.conf

@ -0,0 +1,123 @@
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;
fastcgi_cache_lock on;
fastcgi_cache_lock_age 5s;
fastcgi_cache_lock_timeout 5s;
fastcgi_cache_methods GET HEAD;
fastcgi_cache_background_update on;
fastcgi_cache_valid 200 24h;
fastcgi_cache_valid 301 302 30m;
fastcgi_cache_valid 499 502 503 1m;
fastcgi_cache_valid 404 1h;
fastcgi_cache_valid any 1h;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_keep_conn on;
# do not cache xhtml request
map $http_x_requested_with $http_request_no_cache {
default 0;
XMLHttpRequest 1;
}
# do not cache requests on cookies
map $http_cookie $cookie_no_cache {
default 0;
"~*wordpress_[a-f0-9]+" 1;
"~*wp-postpass" 1;
"~*wordpress_logged_in" 1;
"~*wordpress_no_cache" 1;
"~*comment_author" 1;
"~*woocommerce_items_in_cart" 1;
"~*edd_items_in_cart" 1;
"~*woocommerce_cart_hash" 1;
"~*wptouch_switch_toogle" 1;
"~*comment_author_email_" 1;
"~*wptouch_switch_toggle" 1;
"~*edd" 1;
}
# do not cache the following uri
map $request_uri $uri_no_cache {
default 0;
"~*/wp-admin/" 1;
"~*/wp-[a-zA-Z0-9-]+.php" 1;
"~*/feed/" 1;
"~*/index.php" 1;
"~*/[a-z0-9_-]+-sitemap([0-9]+)?.xml" 1;
"~*/sitemap(_index)?.xml" 1;
"~*/wp-comments-popup.php" 1;
"~*/wp-links-opml.php" 1;
"~*/xmlrpc.php" 1;
"~*/edd-sl/*" 1;
"~*/add_to_cart/" 1;
"~*/cart/" 1;
"~*/account/" 1;
"~*/my-account/" 1;
"~*/checkout/" 1;
"~*/addons/" 1;
"~*/wc-api/*" 1;
"~*/logout/" 1;
"~*/lost-password/" 1;
"~*/panier/" 1;
"~*/mon-compte/" 1;
"~*/embed" 1;
"~*/commande/" 1;
"~*/resetpass/" 1;
}
# do not cache requests with query strings
map $is_args $query_no_cache {
default 1;
"" 0;
}
# if all previous check are passed, $skip_cache = 0
map $http_request_no_cache$cookie_no_cache$uri_no_cache$query_no_cache $skip_cache {
default 1;
0000 0;
}
map $http_accept $webp_suffix_valid {
default 1;
"~*webp" 0;
}
map $realip_remote_addr $webp_suffix_cf {
default 0;
103.21.244.0/22 1;
103.22.200.0/22 1;
103.31.4.0/22 1;
104.16.0.0/12 1;
108.162.192.0/18 1;
131.0.72.0/22 1;
141.101.64.0/18 1;
162.158.0.0/15 1;
172.64.0.0/13 1;
173.245.48.0/20 1;
188.114.96.0/20 1;
190.93.240.0/20 1;
197.234.240.0/22 1;
198.41.128.0/17 1;
199.27.128.0/21 1;
2400:cb00::/32 1;
2405:8100::/32 1;
2405:b500::/32 1;
2606:4700::/32 1;
2803:f800::/32 1;
2a06:98c0::/29 1;
2c0f:f248::/32 1;
}
map $webp_suffix_cf$webp_suffix_valid $webp_suffix {
default "";
00 ".webp";
}
# Limit Request
limit_req_status 403;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req_zone $binary_remote_addr zone=two:10m rate=10r/s;

31
conf/nginx-cache-custom/includes/settings-page.css

@ -0,0 +1,31 @@
.wrap .button.delete {
background: #d54e21;
border-color: #a83d1a;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e68260, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e68260, 0 1px 0 rgba(0, 0, 0, 0.15);
}
.wrap .button.delete:hover,
.wrap .button.delete:focus {
background: #be461d;
border-color: #923517;
color: white;
box-shadow: inset 0 1px 0 #e3704a;
}
.wrap .button.delete:focus {
box-shadow: inset 0 1px 0 #e3704a,
0 0 0 1px #d54e21,
0 0 2px 1px rgba( 30, 140, 190, .8 );
}
.wrap .button.delete:active {
background: #a83d1a;
border-color: #923517;
color: white;
box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ),
0 0 0 1px #d54e21,
0 0 2px 1px rgba( 30, 140, 190, .8 );
}

41
conf/nginx-cache-custom/includes/settings-page.php

@ -0,0 +1,41 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<div class="wrap">
<h1><?php _e( 'Nginx Cache', 'nginx' ); ?></h1>
<?php settings_errors(); ?>
<form method="post" action="options.php">
<?php settings_fields( 'nginx-cache' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e( 'Cache Zone Path', 'nginx-cache' ); ?></th>
<td>
<input type="text" class="regular-text code" name="nginx_cache_path" placeholder="/data/nginx/cache" value="<?php echo esc_attr( get_option( 'nginx_cache_path' ) ); ?>" />
<p class="description"><?php _e( 'The absolute path to the location of the cache zone, specified in the Nginx <code>fastcgi_cache_path</code> or <code>proxy_cache_path</code> directive.', 'nginx-cache' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Purge Cache', 'nginx-cache' ); ?></th>
<td>
<label for="nginx_auto_purge">
<input name="nginx_auto_purge" type="checkbox" id="nginx_auto_purge" value="1" <?php checked( get_option( 'nginx_auto_purge' ), '1' ); ?> />
<?php _e( 'Automatically flush the cache when content changes', 'nginx-cache' ); ?>
</label>
</td>
</tr>
</table>
<p class="submit">
<?php echo get_submit_button( null, 'primary large', 'submit', false ); ?>
&nbsp;
<a href="<?php echo wp_nonce_url( admin_url( add_query_arg( 'action', 'purge-cache', $this->admin_page ) ), 'purge-cache' ); ?>" class="button button-secondary button-large delete<?php if ( is_wp_error( $this->is_valid_path() ) ) : ?> disabled<?php endif; ?>"><?php _e( 'Purge Cache', 'nginx-cache' ); ?></a>
</p>
</form>
</div>

95
conf/nginx-cache-custom/languages/nginx-cache.pot

@ -0,0 +1,95 @@
# Copyright (C) 2020 Till Krüss
# This file is distributed under the GPLv3.
msgid ""
msgstr ""
"Project-Id-Version: Nginx Cache 1.0.5\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/trunk\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-11-21T22:49:14+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.4.0\n"
"X-Domain: nginx-cache\n"
#. Plugin Name of the plugin
#: nginx-cache.php:138
#: nginx-cache.php:139
msgid "Nginx Cache"
msgstr ""
#. Plugin URI of the plugin
msgid "http://wordpress.org/plugins/nginx-cache/"
msgstr ""
#. Description of the plugin
msgid "Purge the Nginx cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress."
msgstr ""
#. Author of the plugin
msgid "Till Krüss"
msgstr ""
#. Author URI of the plugin
msgid "http://till.im/"
msgstr ""
#: includes/settings-page.php:16
msgid "Cache Zone Path"
msgstr ""
#: includes/settings-page.php:19
msgid "The absolute path to the location of the cache zone, specified in the Nginx <code>fastcgi_cache_path</code> or <code>proxy_cache_path</code> directive."
msgstr ""
#: includes/settings-page.php:23
#: includes/settings-page.php:36
#: nginx-cache.php:128
msgid "Purge Cache"
msgstr ""
#: includes/settings-page.php:27
msgid "Automatically flush the cache when content changes"
msgstr ""
#: nginx-cache.php:80
msgid "Cache purged."
msgstr ""
#: nginx-cache.php:85
msgid "Cache could not be purged. %s"
msgstr ""
#: nginx-cache.php:120
msgid "Nginx"
msgstr ""
#: nginx-cache.php:155
msgid "Settings"
msgstr ""
#: nginx-cache.php:177
msgid "\"Cache Zone Path\" is not set."
msgstr ""
#: nginx-cache.php:183
msgid "\"Cache Zone Path\" does not exist."
msgstr ""
#: nginx-cache.php:187
msgid "\"Cache Zone Path\" is not a directory."
msgstr ""
#: nginx-cache.php:193
msgid "\"Cache Zone Path\" does not appear to be a Nginx cache zone directory."
msgstr ""
#: nginx-cache.php:197
msgid "\"Cache Zone Path\" is not writable."
msgstr ""
#: nginx-cache.php:204
msgid "Filesystem API could not be initialized."
msgstr ""

316
conf/nginx-cache-custom/nginx-cache.php

@ -0,0 +1,316 @@
<?php
/*
Plugin Name: Nginx Cache Custom
Plugin URI: http://wordpress.org/plugins/nginx-cache/
Description: Purge the Nginx cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress.
Version: 1.0.4
Text Domain: nginx-cache
Domain Path: /languages
Author: Till Krüss
Author URI: http://till.im/
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
if ( ! defined( 'ABSPATH' ) ) exit;
class NginxCache {
private $screen = 'tools_page_nginx-cache';
private $capability = 'manage_options';
private $admin_page = 'tools.php?page=nginx-cache';
public function __construct() {
load_plugin_textdomain( 'nginx-cache', false, 'nginx-cache/languages' );
add_filter( 'option_nginx_cache_path', 'sanitize_text_field' );
add_filter( 'option_nginx_auto_purge', 'absint' );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_actions_links' ) );
// if ( get_option( 'nginx_auto_purge' ) ) {
add_action( 'init', array( $this, 'register_purge_actions' ), 20 );
// }
add_action( 'admin_init', array( $this, 'register_settings' ) );
add_action( 'admin_menu', array( $this, 'add_admin_menu_page' ) );
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_node' ), 100 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
add_action( 'load-' . $this->screen, array( $this, 'do_admin_actions' ) );
add_action( 'load-' . $this->screen, array( $this, 'add_settings_notices' ) );
}
public function register_purge_actions() {
// use `nginx_cache_purge_actions` filter to alter default purge actions
$purge_actions = (array) apply_filters(
'nginx_cache_purge_actions',
array(
'publish_phone', 'save_post', 'edit_post', 'delete_post', 'wp_trash_post', 'clean_post_cache',
'trackback_post', 'pingback_post', 'comment_post', 'edit_comment', 'delete_comment', 'wp_set_comment_status',
'switch_theme', 'wp_update_nav_menu', 'edit_user_profile_update'
)
);
foreach ( $purge_actions as $action ) {
if ( did_action( $action ) ) {
$this->purge_zone_once();
} else {
add_action( $action, array( $this, 'purge_zone_once' ) );
}
}
}
public function register_settings() {
register_setting( 'nginx-cache', 'nginx_cache_path', 'sanitize_text_field' );
register_setting( 'nginx-cache', 'nginx_auto_purge', 'absint' );
}
public function add_settings_notices() {
// $path_error = $this->is_valid_path();
if ( isset( $_GET[ 'message' ] ) && ! isset( $_GET[ 'settings-updated' ] ) ) {
// show cache purge success message
if ( $_GET[ 'message' ] === 'cache-purged' ) {
add_settings_error( '', 'nginx_cache_path', __( 'Cache purged.', 'nginx-cache' ), 'updated' );
}
// show cache purge failure message
if ( $_GET[ 'message' ] === 'purge-cache-failed' ) {
add_settings_error( '', 'nginx_cache_path', sprintf( __( 'Cache could not be purged. %s', 'nginx-cache' ), wptexturize( $path_error->get_error_message() ) ) );
}
} elseif ( is_wp_error( $path_error ) && $path_error->get_error_code() === 'fs' ) {
// show cache path problem message
add_settings_error( '', 'nginx_cache_path', wptexturize( $path_error->get_error_message( 'fs' ) ) );
}
}
public function do_admin_actions() {
// purge cache
if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] === 'purge-cache' && wp_verify_nonce( $_GET[ '_wpnonce' ], 'purge-cache' ) ) {
$result = $this->purge_zone();
wp_safe_redirect( admin_url( add_query_arg( 'message', is_wp_error( $result ) ? 'purge-cache-failed' : 'cache-purged', $this->admin_page ) ) );
exit;
}
}
public function add_admin_bar_node( $wp_admin_bar ) {
// verify user capability
if ( ! current_user_can( $this->capability ) ) {
return;
}
// add "Nginx" node to admin-bar
$wp_admin_bar->add_node( array(
'id' => 'nginx-cache',
'title' => __( 'Nginx', 'nginx-cache' ),
'href' => admin_url( $this->admin_page )
) );
// add "Purge Cache" to "Nginx" node
$wp_admin_bar->add_node( array(
'parent' => 'nginx-cache',
'id' => 'purge-cache',
'title' => __( 'Purge Cache', 'nginx-cache' ),
'href' => wp_nonce_url( admin_url( add_query_arg( 'action', 'purge-cache', $this->admin_page ) ), 'purge-cache' )
) );
}
public function add_admin_menu_page() {
// add "Tools" sub-page
add_management_page(
__( 'Nginx Cache', 'nginx-cache' ),
__( 'Nginx Cache', 'nginx-cache' ),
$this->capability,
'nginx-cache',
array( $this, 'show_settings_page' )
);
}
public function show_settings_page() {
require_once plugin_dir_path( __FILE__ ) . '/includes/settings-page.php';
}
public function add_plugin_actions_links( $links ) {
// add settings link to plugin actions
return array_merge(
array( '<a href="' . admin_url( $this->admin_page ) . '">' . __( 'Settings', 'nginx-cache' ) . '</a>' ),
$links
);
}
public function enqueue_admin_styles( $hook_suffix ) {
if ( $hook_suffix === $this->screen ) {
$plugin = get_plugin_data( __FILE__ );
wp_enqueue_style( 'nginx-cache', plugin_dir_url( __FILE__ ) . 'includes/settings-page.css', null, $plugin[ 'Version' ] );
}
}
private function is_valid_path() {
global $wp_filesystem;
$path = get_option( 'nginx_cache_path' );
if ( empty( $path ) ) {
return new WP_Error( 'empty', __( '"Cache Zone Path" is not set.', 'nginx-cache' ) );
}
if ( $this->initialize_filesystem() ) {
if ( ! $wp_filesystem->exists( $path ) ) {
return new WP_Error( 'fs', __( '"Cache Zone Path" does not exist.', 'nginx-cache' ) );
}
if ( ! $wp_filesystem->is_dir( $path ) ) {
return new WP_Error( 'fs', __( '"Cache Zone Path" is not a directory.', 'nginx-cache' ) );
}
$list = $wp_filesystem->dirlist( $path, true, true );
if ( is_array( $list ) && ! $this->validate_dirlist( $list ) ) {
return new WP_Error( 'fs', __( '"Cache Zone Path" does not appear to be a Nginx cache zone directory.', 'nginx-cache' ) );
}
if ( ! $wp_filesystem->is_writable( $path ) ) {
return new WP_Error( 'fs', __( '"Cache Zone Path" is not writable.', 'nginx-cache' ) );
}
return true;
}
return new WP_Error( 'fs', __( 'Filesystem API could not be initialized.', 'nginx-cache' ) );
}
private function validate_dirlist( $list ) {
foreach ( $list as $item ) {
// abort if file is not a MD5 hash
if ( $item[ 'type' ] === 'f' && ( strlen( $item[ 'name' ] ) !== 32 || ! ctype_xdigit( $item[ 'name' ] ) ) ) {
return false;
}
// validate subdirectories recursively
if ( $item[ 'type' ] === 'd' && ! $this->validate_dirlist( $item[ 'files' ] ) ) {
return false;
}
}
return true;
}
public function purge_zone_once() {
static $completed = false;
if ( ! $completed ) {
$this->purge_zone();
$completed = true;
}
}
private function purge_zone() {
global $wp_filesystem;
if ( ! $this->should_purge() ) {
return false;
}
// $path = get_option( 'nginx_cache_path' );
// $path_error = $this->is_valid_path();
// abort if cache zone path is not valid
// if ( is_wp_error( $path_error ) ) {
// return $path_error;
// }
// delete cache directory (recursively)
// $wp_filesystem->rmdir( $path, true );
// recreate empty cache directory
// $wp_filesystem->mkdir( $path );
system('sudo /bin/rm -r /var/run/nginx-cache/APP_NAME/*');
do_action( 'nginx_cache_zone_purged', $path );
return true;
}
private function should_purge() {
$post_type = get_post_type();
if ( ! $post_type ) {
return true;
}
if ( ! in_array( $post_type, (array) apply_filters( 'nginx_cache_excluded_post_types', array() ) ) ) {
return true;
}
return false;
}
private function initialize_filesystem() {
$path = get_option( 'nginx_cache_path' );
// if the cache directory doesn't exist, try to create it
if ( ! file_exists( $path ) ) {
mkdir( $path );
}
// load WordPress file API?
if ( ! function_exists( 'request_filesystem_credentials' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
ob_start();
$credentials = request_filesystem_credentials( '', '', false, $path, null, true );
ob_end_clean();
if ( $credentials === false ) {
return false;
}
if ( ! WP_Filesystem( $credentials, $path, true ) ) {
return false;
}
return true;
}
}
new NginxCache;

66
conf/nginx-cache-custom/readme.txt

@ -0,0 +1,66 @@
=== Nginx Cache ===
Contributors: tillkruess
Donate link: https://github.com/sponsors/tillkruss
Tags: nginx, nginx cache, cache, caching, purge, purge cache, flush, flush cache, server, performance, optimize, speed, load, fastcgi, fastcgi purge, proxy, proxy purge, reverse proxy
Requires at least: 3.1
Tested up to: 5.6
Stable tag: 1.0.5
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Purge the Nginx cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress.
== Description ==
Purge the [Nginx](http://nginx.org) cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress.
Requirements:
* The [Filesystem API](http://codex.wordpress.org/Filesystem_API) needs to function without asking for credentials.
* Nginx and PHP need to run under the same user, or PHP's user needs write access to Nginx's cache path.
== Installation ==
For detailed installation instructions, please read the [standard installation procedure for WordPress plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
1. Install and activate plugin.
2. Enter "Cache Zone Path" under _Tools -> Nginx_.
3. Done.
== Screenshots ==
1. Plugin settings page.
== Changelog ==
= 1.0.5 =
* Added `nginx_cache_zone_purged` action
= 1.0.4 =
* Improved translatable strings
* Fixed auto-purge bug
* Fixed bug when validating directory
= 1.0.3 =
* Create cache directory if it doesn't exists
* Re-create cache directory after cache purge
* Allow post types to be excluded from triggering a cache purge
= 1.0.2 =
* Fixed 4.6 issue with file-system credentials
= 1.0.1 =
* Improved testing of file-system credentials
= 1.0 =
* Initial release

312
conf/nginx-cache.conf

@ -0,0 +1,312 @@
#--MULTISITE--if (!-e $request_filename) {
#--MULTISITE--rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/wp-.*) __PATH__$2 last;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/.*\.php)$ __PATH__$2 last;
#--MULTISITE--}
# fallback for robots.txt with default wordpress rules
location @robots {
return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n";
}
location @empty_gif {
empty_gif;
}
add_header X-fastcgi-cache $upstream_cache_status;
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
index index.php;
if (!-e $request_filename)
{
rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
}
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
client_max_body_size 1G;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache __NAME__;
fastcgi_cache_valid 60m;
}
##### CACHE CONFIGURATION #####
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location ~ /purge(/.*) {
fastcgi_cache_purge __NAME__ "$scheme$request_method$host$1";
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location ~ /\. { deny all; access_log off; log_not_found off; }
##### SECURITY CONFIGURATION #####
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache __NAME__;
fastcgi_cache_valid 60m;
}
# Prevent DoS attacks on wp-cron
location = /wp-cron.php {
limit_req zone=two burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache __NAME__;
fastcgi_cache_valid 60m;
}
# Prevent DoS attacks with xmlrpc.php
location = /xmlrpc.php {
limit_req zone=two burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache __NAME__;
fastcgi_cache_valid 60m;
}
# Disable wp-config.txt
location = /wp-config.txt {
deny all;
access_log off;
log_not_found off;
}
location = /robots.txt {
# Some WordPress plugin gererate robots.txt file
# Refer #340 issue
try_files $uri $uri/ /index.php?$args @robots;
access_log off;
log_not_found off;
}
# webp rewrite rules for jpg and png images
# try to load alternative image.png.webp before image.png
location /wp-content/uploads {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~* \.(php|gz|log|zip|tar|rar|xz)$ {
#Prevent Direct Access Of PHP Files & Backups from Web Browsers
deny all;
}
}
# webp rewrite rules for EWWW testing image
location /wp-content/plugins/ewww-image-optimizer/images {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# enable gzip on static assets - php files are forbidden
location /wp-content/cache {
# Cache css & js files
location ~* \.(?:css(\.map)?|js(\.map)?|.html)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
access_log off;
log_not_found off;
expires 30d;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# mitigate DoS attack CVE with WordPress script concatenation
# add the following line to wp-config.php
# define( 'CONCATENATE_SCRIPTS', false );
location ~ \/wp-admin\/load-(scripts|styles).php {
deny all;
}
# Protect Easy Digital Download files from being accessed directly.
location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
rewrite / permanent;
}
##### ADDITIONAL LOCATIONS #####
# Basic locations files
location = /favicon.ico {
try_files /wp-content/uploads/fbrfg/favicon.ico $uri $uri/ /index.php?$args @empty_gif;
access_log off;
log_not_found off;
expires max;
}
# Cache static files
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|ttf|m4a|mp4|ttf|rss|atom|jpe?g|gif|cur|heic|png|tiff|ico|webm|mp3|aac|tgz|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp|json|webmanifest|cast)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
}
# Cache css & js files
location ~* \.(?:css(\.map)?|js(\.map)?)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires 30d;
}
# Security settings for better privacy
# Deny hidden files
location ~ /\.(?!well-known\/) {
deny all;
}
# letsencrypt validation
location /.well-known/acme-challenge/ {
alias /var/www/html/.well-known/acme-challenge/;
allow all;
auth_basic off;
}
# Return 403 forbidden for readme.(txt|html) or license.(txt|html) or example.(txt|html) or other common git repository files
location ~* "/(^$|readme|license|example|README|LEGALNOTICE|INSTALLATION|CHANGELOG)\.(txt|html|md)" {
deny all;
}
# Deny backup extensions & log files and return 403 forbidden
location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rdf|gz|zip|bz2|7z|pem|asc|conf|dump)$" {
deny all;
}
location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" {
deny all;
}
# block base64_encoded content
location ~* "(base64_encode)(.*)(\()" {
deny all;
}
# block javascript eval()
location ~* "(eval\()" {
deny all;
}
# Additional security settings
location ~* "(127\.0\.0\.1)" {
deny all;
}
location ~* "([a-z0-9]{2000})" {
deny all;
}
location ~* "(javascript\:)(.*)(\;)" {
deny all;
}
location ~* "(GLOBALS|REQUEST)(=|\[|%)" {
deny all;
}
location ~* "(<|%3C).*script.*(>|%3)" {
deny all;
}
location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" {
deny all;
}
location ~* "(boot\.ini|etc/passwd|self/environ)" {
deny all;
}
location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" {
deny all;
}
location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" {
deny all;
}
location ~* "(https?|ftp|php):/" {
deny all;
}
location ~* "(=\\\'|=\\%27|/\\\'/?)\." {
deny all;
}
location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" {
deny all;
}
location ~ "(~|`|<|>|:|;|%|\\|\s|\{|\}|\[|\]|\|)" {
deny all;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

268
conf/nginx-standard.conf

@ -0,0 +1,268 @@
#--MULTISITE--if (!-e $request_filename) {
#--MULTISITE--rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/wp-.*) __PATH__$2 last;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/.*\.php)$ __PATH__$2 last;
#--MULTISITE--}
# fallback for robots.txt with default wordpress rules
location @robots {
return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n";
}
location @empty_gif {
empty_gif;
}
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
index index.php;
if (!-e $request_filename)
{
rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
}
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
client_max_body_size 1G;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location ~ /\. { deny all; access_log off; log_not_found off; }
##### SECURITY CONFIGURATION #####
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
}
# Prevent DoS attacks on wp-cron
location = /wp-cron.php {
limit_req zone=two burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
}
# Prevent DoS attacks with xmlrpc.php
location = /xmlrpc.php {
limit_req zone=two burst=1 nodelay;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
try_files $uri =404;
}
# Disable wp-config.txt
location = /wp-config.txt {
deny all;
access_log off;
log_not_found off;
}
location = /robots.txt {
# Some WordPress plugin gererate robots.txt file
# Refer #340 issue
try_files $uri $uri/ /index.php?$args @robots;
access_log off;
log_not_found off;
}
# webp rewrite rules for jpg and png images
# try to load alternative image.png.webp before image.png
location /wp-content/uploads {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~* \.(php|gz|log|zip|tar|rar|xz)$ {
#Prevent Direct Access Of PHP Files & Backups from Web Browsers
deny all;
}
}
# webp rewrite rules for EWWW testing image
location /wp-content/plugins/ewww-image-optimizer/images {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# enable gzip on static assets - php files are forbidden
location /wp-content/cache {
# Cache css & js files
location ~* \.(?:css(\.map)?|js(\.map)?|.html)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
access_log off;
log_not_found off;
expires 30d;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# mitigate DoS attack CVE with WordPress script concatenation
# add the following line to wp-config.php
# define( 'CONCATENATE_SCRIPTS', false );
location ~ \/wp-admin\/load-(scripts|styles).php {
deny all;
}
# Protect Easy Digital Download files from being accessed directly.
location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
rewrite / permanent;
}
##### ADDITIONAL LOCATIONS #####
# Basic locations files
location = /favicon.ico {
try_files /wp-content/uploads/fbrfg/favicon.ico $uri $uri/ /index.php?$args @empty_gif;
access_log off;
log_not_found off;
expires max;
}
# Cache static files
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|ttf|m4a|mp4|ttf|rss|atom|jpe?g|gif|cur|heic|png|tiff|ico|webm|mp3|aac|tgz|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp|json|webmanifest|cast)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires max;
}
# Cache css & js files
location ~* \.(?:css(\.map)?|js(\.map)?)$ {
more_set_headers 'Access-Control-Allow-Origin : *';
more_set_headers "Cache-Control : public, no-transform";
access_log off;
log_not_found off;
expires 30d;
}
# Security settings for better privacy
# Deny hidden files
location ~ /\.(?!well-known\/) {
deny all;
}
# letsencrypt validation
location /.well-known/acme-challenge/ {
alias /var/www/html/.well-known/acme-challenge/;
allow all;
auth_basic off;
}
# Return 403 forbidden for readme.(txt|html) or license.(txt|html) or example.(txt|html) or other common git repository files
location ~* "/(^$|readme|license|example|README|LEGALNOTICE|INSTALLATION|CHANGELOG)\.(txt|html|md)" {
deny all;
}
# Deny backup extensions & log files and return 403 forbidden
location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rdf|gz|zip|bz2|7z|pem|asc|conf|dump)$" {
deny all;
}
location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" {
deny all;
}
# block base64_encoded content
location ~* "(base64_encode)(.*)(\()" {
deny all;
}
# block javascript eval()
location ~* "(eval\()" {
deny all;
}
# Additional security settings
location ~* "(127\.0\.0\.1)" {
deny all;
}
location ~* "([a-z0-9]{2000})" {
deny all;
}
location ~* "(javascript\:)(.*)(\;)" {
deny all;
}
location ~* "(GLOBALS|REQUEST)(=|\[|%)" {
deny all;
}
location ~* "(<|%3C).*script.*(>|%3)" {
deny all;
}
location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" {
deny all;
}
location ~* "(boot\.ini|etc/passwd|self/environ)" {
deny all;
}
location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" {
deny all;
}
location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" {
deny all;
}
location ~* "(https?|ftp|php):/" {
deny all;
}
location ~* "(=\\\'|=\\%27|/\\\'/?)\." {
deny all;
}
location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" {
deny all;
}
location ~ "(~|`|<|>|:|;|%|\\|\s|\{|\}|\[|\]|\|)" {
deny all;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

37
conf/nginx.conf

@ -1,37 +0,0 @@
#--MULTISITE--if (!-e $request_filename) {
#--MULTISITE--rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/wp-.*) __PATH__$2 last;
#--MULTISITE--rewrite ^__PATH__(/[^/]+)?(/.*\.php)$ __PATH__$2 last;
#--MULTISITE--}
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
index index.php;
if (!-e $request_filename)
{
rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
}
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
client_max_body_size 30m;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

2
conf/sql/multisite.sql

@ -1 +1 @@
REPLACE INTO wp_sitemeta VALUES(NULL,1,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}');
REPLACE INTO __DB_PREFIX__sitemeta VALUES(NULL,1,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}');

2
conf/sql/single.sql

@ -1 +1 @@
REPLACE INTO wp_options VALUES(NULL,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}','yes');
REPLACE INTO __DB_PREFIX__options VALUES(NULL,'authLDAPOptions','a:22:{s:7:"Enabled";s:1:"1";s:7:"CachePW";b:0;s:3:"URI";s:44:"ldap://localhost/ou=users,dc=yunohost,dc=org";s:12:"URISeparator";s:1:" ";s:6:"Filter";s:__LENGTH__:"(&(|(objectclass=posixAccount))(uid=%s)(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";s:8:"NameAttr";s:9:"givenName";s:7:"SecName";s:2:"sn";s:7:"UidAttr";s:3:"uid";s:8:"MailAttr";s:4:"mail";s:7:"WebAttr";s:0:"";s:6:"Groups";a:5:{s:13:"administrator";s:0:"";s:6:"editor";s:0:"";s:6:"author";s:0:"";s:11:"contributor";s:0:"";s:10:"subscriber";s:0:"";}s:5:"Debug";b:0;s:9:"GroupAttr";s:0:"";s:11:"GroupFilter";s:0:"";s:11:"DefaultRole";s:10:"subscriber";s:11:"GroupEnable";b:0;s:13:"GroupOverUser";b:0;s:7:"Version";i:1;s:26:"DoNotOverwriteNonLdapUsers";b:0;s:8:"StartTLS";b:0;s:14:"GroupSeparator";s:0:"";s:9:"GroupBase";s:0:"";}','yes');

16
config_panel.toml

@ -40,11 +40,11 @@ name = "Wordpress configuration"
default = "low" default = "low"
help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option." help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option."
[main.php_fpm_config.free_footprint]
ask = "Memory footprint of the service?"
type = "number"
default = "0"
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
# [main.php_fpm_config.free_footprint]
# ask = "Memory footprint of the service?"
# type = "number"
# default = "0"
# help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
[main.php_fpm_config.usage] [main.php_fpm_config.usage]
ask = "Expected usage of the service?" ask = "Expected usage of the service?"
@ -57,3 +57,9 @@ name = "Wordpress configuration"
type = "number" type = "number"
default = "0" default = "0"
help = "Do not change this value unless you are sure about what you are doing!<br>pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint<br>You can force that value, and ignore the formula by changing the value here.<br>To reset to the default value, set to 0." help = "Do not change this value unless you are sure about what you are doing!<br>pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint<br>You can force that value, and ignore the formula by changing the value here.<br>To reset to the default value, set to 0."
[main.php_fpm_config.version]
ask = "PHP version?"
choices = ["7.0" , "7.1", "7.2", "7.3", "7.4", "8.0"]
default = "7.3"
help = "PHP version"

66
manifest.json

@ -6,7 +6,7 @@
"en": "Create a beautiful blog or website easily", "en": "Create a beautiful blog or website easily",
"fr": "Logiciel de création de blog ou de site Web" "fr": "Logiciel de création de blog ou de site Web"
}, },
"version": "5.7~ynh1",
"version": "5.7.2~ynh1",
"url": "https://wordpress.org/", "url": "https://wordpress.org/",
"license": "GPL-2.0", "license": "GPL-2.0",
"maintainer": { "maintainer": {
@ -30,12 +30,33 @@
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain",
"type": "string",
"ask": { "ask": {
"en": "Choose a domain for WordPress", "en": "Choose a domain for WordPress",
"fr": "Choisissez un domaine pour WordPress" "fr": "Choisissez un domaine pour WordPress"
}, },
"example": "domain.org"
"example": "domain.org",
"default": "s8.yntest.weblibre.ca"
},
{
"name": "domain_dev",
"type": "string",
"ask": {
"en": "Choose a DEV domain for WordPress",
"fr": "Choisissez un domaine DEV pour WordPress"
},
"example": "domain.org",
"default": "s8-dev.yntest.weblibre.ca"
},
{
"name": "domain_staging",
"type": "string",
"ask": {
"en": "Choose a STAGING domain for WordPress",
"fr": "Choisissez un domaine STAGING pour WordPress"
},
"example": "domain.org",
"default": "s8-staging.yntest.weblibre.ca"
}, },
{ {
"name": "path", "name": "path",
@ -45,7 +66,7 @@
"fr": "Choisissez un chemin pour WordPress" "fr": "Choisissez un chemin pour WordPress"
}, },
"example": "/blog", "example": "/blog",
"default": "/blog"
"default": "/"
}, },
{ {
"name": "admin", "name": "admin",
@ -87,6 +108,43 @@
"en": "A public WordPress will be publicly visible for everyone. If you're looking for a public blog, you should choose to install a public WordPress.", "en": "A public WordPress will be publicly visible for everyone. If you're looking for a public blog, you should choose to install a public WordPress.",
"fr": "Un WordPress public sera visible publiquement pour tous. Si vous recherchez un blog public, vous devriez choisir d'installer un WordPress public." "fr": "Un WordPress public sera visible publiquement pour tous. Si vous recherchez un blog public, vous devriez choisir d'installer un WordPress public."
} }
},
{
"name": "repo",
"type": "string",
"ask": {
"en": "If Git repo, enter here",
"fr": "Si dépôt Git, entrez ici"
},
"optional": true
},
{
"name": "cache",
"type": "boolean",
"ask": {
"en": "Enable cache for main website?",
"fr": "Activer la cache pour le site principal?"
},
"default": true
},
{
"name": "phpversion",
"type": "string",
"ask": {
"en": "Choose the PHP version",
"fr": "Choissisez la version de PHP"
},
"choices": ["7.0" , "7.1", "7.2", "7.3", "7.4", "8.0"],
"default": "7.3"
},
{
"name": "switch",
"type": "boolean",
"ask": {
"en": "Do not enter anything",
"fr": "Ne rien entrer ici"
},
"default": false
} }
] ]
} }

2
scripts/_common.sh

@ -4,7 +4,7 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
YNH_PHP_VERSION="7.3"
YNH_PHP_VERSION=$YNH_APP_ARG_PHPVERSION
extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap" extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap"

15
scripts/config

@ -17,6 +17,7 @@ app=$YNH_APP_INSTANCE_NAME
fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir) fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# LOAD VALUES # LOAD VALUES
@ -67,6 +68,10 @@ if [ -z "$old_php_forced_max_children" ]; then
fi fi
php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}" php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}"
# Version for php
old_phpversion="$(ynh_app_setting_get --app=$app --key=phpversion)"
YNH_PHP_VERSION="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_VERSION:-$old_phpversion}"
#================================================= #=================================================
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
#================================================= #=================================================
@ -84,6 +89,7 @@ show_config() {
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children" ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_VERSION=$YNH_PHP_VERSION"
} }
#================================================= #=================================================
@ -116,7 +122,8 @@ apply_config() {
if [ "$fpm_usage" != "$old_fpm_usage" ] || \ if [ "$fpm_usage" != "$old_fpm_usage" ] || \
[ "$fpm_footprint" != "$old_fpm_footprint" ] || \ [ "$fpm_footprint" != "$old_fpm_footprint" ] || \
[ "$free_footprint" != "$old_free_footprint" ] || \ [ "$free_footprint" != "$old_free_footprint" ] || \
[ "$php_forced_max_children" != "$old_php_forced_max_children" ]
[ "$php_forced_max_children" != "$old_php_forced_max_children" ] || \
[ "$YNH_PHP_VERSION" != "$old_phpversion" ]
then then
# If fpm_footprint is set to 'specific', use $free_footprint value. # If fpm_footprint is set to 'specific', use $free_footprint value.
if [ "$fpm_footprint" = "specific" ] if [ "$fpm_footprint" = "specific" ]
@ -138,7 +145,11 @@ apply_config() {
if [ "$fpm_footprint" != "0" ] if [ "$fpm_footprint" != "0" ]
then then
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --usage=$fpm_usage --footprint=$fpm_footprint
old_phpversion=$(sed 's/[\*\.]/\\&/g' <<<"$old_phpversion")
YNH_PHP_VERSION=$(sed 's/[\*\.]/\\&/g' <<<"$YNH_PHP_VERSION")
sed -i "s/php$old_phpversion-fpm-$app\.sock/php$YNH_PHP_VERSION-fpm-$app\.sock/g" /etc/nginx/conf.d/$domain.d/$app.conf
ynh_systemd_action --service_name=nginx --action=reload
else else
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
fi fi

134
scripts/install

@ -21,11 +21,17 @@ ynh_abort_if_errors
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
domain_dev=$YNH_APP_ARG_DOMAIN_DEV
domain_staging=$YNH_APP_ARG_DOMAIN_STAGING
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin_wordpress=$YNH_APP_ARG_ADMIN admin_wordpress=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
multisite=$YNH_APP_ARG_MULTISITE multisite=$YNH_APP_ARG_MULTISITE
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
repo=$YNH_APP_ARG_REPO
cache=$YNH_APP_ARG_CACHE
phpversion=$YNH_APP_ARG_PHPVERSION
switch=$YNH_APP_ARG_SWITCH
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -37,6 +43,16 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
set +e
webpath=$(ynh_webpath_available --domain=$domain --path_url=$path_url 2>&1)
if [[ $(echo $webpath | grep 'unknown' | wc -l) = "1" ]]; then
yunohost domain add $domain
yunohost domain cert-install --no-checks $domain
elif [[ $(echo $webpath | grep 'False' | wc -l) = "1" ]]; then
ynh_die --message="Path not available: ${domain}${path_url}"
fi
ynh_abort_if_errors
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -50,10 +66,15 @@ fi
ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=domain_dev --value=$domain_dev
ynh_app_setting_set --app=$app --key=domain_staging --value=$domain_staging
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=multisite --value=$multisite ynh_app_setting_set --app=$app --key=multisite --value=$multisite
ynh_app_setting_set --app=$app --key=repo --value=$repo
ynh_app_setting_set --app=$app --key=cache --value=$cache
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1 ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1 ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1
@ -71,21 +92,27 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
# CLONE REPO IF REQUIRED
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
if [ -n "$repo" ]
then
GIT_SSH_COMMAND='ssh -i /etc/yunohost/sshkey -o IdentitiesOnly=yes' git clone $repo $final_path
git config --file $final_path/.git/config core.sshCommand "ssh -i /etc/yunohost/sshkey"
fi
#================================================= #=================================================
# NGINX CONFIGURATION
# DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
if [ ! -d /var/www/$app/wp-admin ];
then
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -95,6 +122,41 @@ ynh_script_progression --message="Configuring system user..." --weight=3
# Create a dedicated system user # Create a dedicated system user
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
if [ ! -f /etc/nginx/conf.d/fastcgi.conf ];
then
cp ../conf/fastcgi.conf /etc/nginx/conf.d/fastcgi.conf
fi
if [ $cache -eq 1 ]
then
#=================================================
# Add fastcgi_cache settings
#=================================================
mkdir -p /var/run/nginx-cache/$app
chmod 750 /var/run/nginx-cache/$app
chgrp $app /var/run/nginx-cache/$app
echo "fastcgi_cache_path /var/run/nginx-cache/$app levels=1:2 keys_zone=$app:50m inactive=6h max_size=256M;" > /tmp/newfile
cat /etc/nginx/conf.d/$domain.conf >> /tmp/newfile
cp /tmp/newfile /etc/nginx/conf.d/$domain.conf
rm /tmp/newfile
cp ../conf/nginx-cache.conf ../conf/nginx.conf
else
cp ../conf/nginx-standard.conf ../conf/nginx.conf
fi
systemctl reload nginx
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -108,8 +170,7 @@ else
usage=high usage=high
fi fi
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$usage --footprint=medium --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --usage=$usage --footprint=medium --package="$extra_php_dependencies"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -133,6 +194,7 @@ done
#================================================= #=================================================
# SETTING UP WITH CURL # SETTING UP WITH CURL
#================================================= #=================================================
ynh_script_progression --message="Installing wordpress with cURL..." --weight=10 ynh_script_progression --message="Installing wordpress with cURL..." --weight=10
# Set right permissions for cURL install # Set right permissions for cURL install
@ -168,14 +230,24 @@ done
#================================================= #=================================================
ynh_script_progression --message="Installing WordPress plugins..." --weight=20 ynh_script_progression --message="Installing WordPress plugins..." --weight=20
ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=$final_path/wp-cli.phar
wpcli_alias="php$phpversion $final_path/wp-cli.phar --allow-root --path=$final_path"
ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=/usr/local/bin/wp
chmod +x /usr/local/bin/wp
wpcli_alias="php$YNH_PHP_VERSION /usr/local/bin/wp --allow-root --path=$final_path"
$wpcli_alias plugin install authldap $wpcli_alias plugin install authldap
$wpcli_alias plugin install http-authentication $wpcli_alias plugin install http-authentication
$wpcli_alias plugin install companion-auto-update $wpcli_alias plugin install companion-auto-update
$wpcli_alias plugin install wp-fail2ban-redux $wpcli_alias plugin install wp-fail2ban-redux
if [ $cache -eq 1 ]
then
cp -r ../conf/nginx-cache-custom $final_path/wp-content/plugins/nginx-cache-custom
ynh_replace_string --match_string="APP_NAME" --replace_string="$app" --target_file=/$final_path/wp-content/plugins/nginx-cache-custom/nginx-cache.php
echo "$app ALL=(root) NOPASSWD: /bin/rm -r /var/run/nginx-cache/$app/*" >> /etc/sudoers
fi
#================================================= #=================================================
# SET LANGUAGE # SET LANGUAGE
#================================================= #=================================================
@ -202,12 +274,16 @@ then
# Activate multisite in wordpress config # Activate multisite in wordpress config
ynh_replace_string --match_string="//--MULTISITE2--define" --replace_string="define" --target_file=$final_path/wp-config.php ynh_replace_string --match_string="//--MULTISITE2--define" --replace_string="define" --target_file=$final_path/wp-config.php
db_prefix="wp_"
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql
ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/multisite.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/multisite.sql
plugin_network="--network" plugin_network="--network"
else else
db_prefix="wp_"
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/single.sql
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql
ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql
@ -225,6 +301,12 @@ $wpcli_alias plugin activate authldap $plugin_network
$wpcli_alias plugin activate companion-auto-update $plugin_network $wpcli_alias plugin activate companion-auto-update $plugin_network
$wpcli_alias plugin activate wp-fail2ban-redux $plugin_network $wpcli_alias plugin activate wp-fail2ban-redux $plugin_network
if [ $cache -eq 1 ]
then
$wpcli_alias plugin activate nginx-cache-custom $plugin_network
fi
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
@ -237,7 +319,7 @@ ynh_store_file_checksum --file="$final_path/wp-config.php"
#================================================= #=================================================
echo "# Reach everyday wp-cron.php to trig the internal WordPress cron. echo "# Reach everyday wp-cron.php to trig the internal WordPress cron.
0 3 * * * $app php$phpversion $final_path/wp-cron.php" > /etc/cron.d/$app
0 3 * * * $app php$YNH_PHP_VERSION $final_path/wp-cron.php" > /etc/cron.d/$app
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -248,9 +330,14 @@ echo "# Reach everyday wp-cron.php to trig the internal WordPress cron.
# Set permissions to app files # Set permissions to app files
# Files have to be own by the user of wordpress. To allow upgrade from the app. # Files have to be own by the user of wordpress. To allow upgrade from the app.
chown -R $app: $final_path chown -R $app: $final_path
# Except the file config wp-config.php
chown root:$app $final_path/wp-config.php
chmod 640 $final_path/wp-config.php
setfacl -d -R -m u:tiny_file_manager:rw $final_path
setfacl -d -R -m g:tiny_file_manager.main:rw $final_path
find $final_path -type d -exec setfacl -m u:tiny_file_manager:rwx {} \;
find $final_path -type f -exec setfacl -m u:tiny_file_manager:rw {} \;
find $final_path -type d -exec setfacl -m g:tiny_file_manager.main:rwx {} \;
find $final_path -type f -exec setfacl -m g:tiny_file_manager.main:rw {} \;
chmod -R g+w $final_path
find $final_path -type d -exec chmod g+s {} \;
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
@ -283,12 +370,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=3
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# REMOVE WP-CLI.PHAR
#=================================================
ynh_secure_remove --file=$final_path/wp-cli.phar
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================
@ -311,3 +392,10 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordp
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed" --last
if [ $switch -eq 1 ]
then
yunohost app install -f /home/gcossette/wordpress_ynh -a "domain=$domain_dev&domain_dev=s8-dev.yntest.weblibre.ca&domain_staging=s8-staging.yntest.weblibre.ca&path=/&admin=gcossette&language=en_US&multisite=false&is_public=true&repo=&cache=0&switch=0"
yunohost app install -f /home/gcossette/wordpress_ynh -a "domain=$domain_staging&domain_dev=s8-dev.yntest.weblibre.ca&domain_staging=s8-staging.yntest.weblibre.ca&path=/&admin=gcossette&language=en_US&multisite=false&is_public=true&repo=&cache=0&switch=0"
fi

36
scripts/remove

@ -17,8 +17,11 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
domain_dev=$(ynh_app_setting_get --app=$app --key=domain_dev)
domain_staging=$(ynh_app_setting_get --app=$app --key=domain_staging)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
cache=$(ynh_app_setting_get --app=$app --key=cache)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -43,6 +46,12 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." ynh_script_progression --message="Removing NGINX web server configuration..."
if [ $cache -eq 1 ]
then
sed -i "/fastcgi_cache_path/d" /etc/nginx/conf.d/$domain.conf
rm -r /var/run/nginx-cache/$app
fi
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -54,6 +63,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
#=================================================
# REMOVE PLUGIN CONFIGURATION
#=================================================
sed -i "/$app ALL=(root)/d" /etc/sudoers
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
@ -82,4 +97,25 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
app_dev=$(yunohost app map -r | grep -A2 $domain_dev | grep id: | sed "s/.*id: //")
if [ ! -z "$app_dev" ]; then
if [ -d /var/www/$app_dev ]; then
yunohost app remove $app_dev
fi
fi
app_staging=$(yunohost app map -r | grep -A2 $domain_staging | grep id: | sed "s/.*id: //")
if [ ! -z "$app_staging" ]; then
if [ -d /var/www/$app_staging ]; then
yunohost app remove $app_staging
fi
fi
# TODO
rm /etc/nginx/conf.d/fastcgi.conf
systemctl reload nginx
#if [[ ! $(ls -A /etc/nginx/conf.d/fastcgi.conf-*) ]]; then
#rm /etc/nginx/conf.d/fastcgi.conf
#fi
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression --message="Removal of $app completed" --last

6
scripts/upgrade

@ -227,6 +227,9 @@ then
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/multisite.sql
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/multisite.sql
ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/multisite.sql
@ -234,6 +237,9 @@ then
plugin_network="--network" plugin_network="--network"
else else
multisite=0 multisite=0
db_prefix=$(grep '^$table_prefix' "$final_path/wp-config.php" | sed "s/.*'\(.*\)'.*/\1/" )
ynh_replace_string --match_string="__DB_PREFIX__" --replace_string="$db_prefix" --target_file=../conf/sql/single.sql
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=../conf/sql/single.sql
ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql ynh_replace_string --match_string="__LENGTH__" --replace_string="$((${#app} + 95))" --target_file=../conf/sql/single.sql

Loading…
Cancel
Save