1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wordpress_ynh.git synced 2024-09-03 20:36:10 +02:00

Fix auto-upgrade and upgrade script

This commit is contained in:
Maniack Crudelis 2017-07-28 18:22:00 +02:00
parent 754ca8199f
commit 931b5dc1a2
6 changed files with 104 additions and 59 deletions

View file

@ -1,3 +1 @@
INSERT INTO wp_sitemeta VALUES('',1,'sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}'); INSERT INTO wp_sitemeta VALUES('',1,'sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}');
#--PUBLIC--UPDATE wp_sitemeta SET meta_value='a:1:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins';
#--PRIVATE--UPDATE wp_sitemeta SET meta_value='a:2:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;s:43:"http-authentication/http-authentication.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins';

View file

@ -1,3 +1 @@
INSERT INTO wp_options VALUES('','sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}','yes'); INSERT INTO wp_options VALUES('','sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}','yes');
#--PRIVATE--UPDATE wp_options SET option_value='a:2:{i:0;s:43:"http-authentication/http-authentication.php";i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins';
#--PUBLIC--UPDATE wp_options SET option_value='a:1:{i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins';

View file

@ -1,14 +1,51 @@
<?php <?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
// Database // ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '__DB_USER__'); define('DB_NAME', '__DB_USER__');
/** MySQL database username */
define('DB_USER', '__DB_USER__'); define('DB_USER', '__DB_USER__');
/** MySQL database password */
define('DB_PASSWORD', '__DB_PWD__'); define('DB_PASSWORD', '__DB_PWD__');
/** MySQL hostname */
define('DB_HOST', 'localhost'); define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8'); define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', ''); define('DB_COLLATE', '');
// Keys /**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'KEY1'); define('AUTH_KEY', 'KEY1');
define('SECURE_AUTH_KEY', 'KEY2'); define('SECURE_AUTH_KEY', 'KEY2');
define('LOGGED_IN_KEY', 'KEY3'); define('LOGGED_IN_KEY', 'KEY3');
@ -18,32 +55,38 @@ define('SECURE_AUTH_SALT', 'KEY6');
define('LOGGED_IN_SALT', 'KEY7'); define('LOGGED_IN_SALT', 'KEY7');
define('NONCE_SALT', 'KEY8'); define('NONCE_SALT', 'KEY8');
// Prefix /**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_'; $table_prefix = 'wp_';
// Debug mode /**
define('WP_DEBUG', false); * For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', false);
// Multisite /* That's all, stop editing! Happy blogging. */
//--MULTISITE1--define('WP_ALLOW_MULTISITE', true);
//--MULTISITE2--define('MULTISITE', true);
//--MULTISITE2--define('SUBDOMAIN_INSTALL', false);
//--MULTISITE2--define('DOMAIN_CURRENT_SITE', '__DOMAIN__');
//--MULTISITE2--define('PATH_CURRENT_SITE', '__PATH__/');
//--MULTISITE2--define('SITE_ID_CURRENT_SITE', 1);
//--MULTISITE2--define('BLOG_ID_CURRENT_SITE', 1);
// Path /** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') ) if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/'); define('ABSPATH', dirname(__FILE__) . '/');
// WordPress settings path /** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php'); require_once(ABSPATH . 'wp-settings.php');
// Force https redirect // Force https redirect
//--PUBLIC--define('FORCE_SSL_ADMIN', true); //--PUBLIC--define('FORCE_SSL_ADMIN', true);
// Auto update
define('WP_AUTO_UPDATE_CORE', 'minor');
//add_filter( 'auto_update_plugin', '__return_true' );
//add_filter( 'auto_update_theme', '__return_true' );

View file

@ -58,8 +58,8 @@
"en": "Choose the language of the WordPress site", "en": "Choose the language of the WordPress site",
"fr": "Choissisez la langue du WordPress" "fr": "Choissisez la langue du WordPress"
}, },
"choices": ["en_EN", "fr_FR"], "choices": ["en_US", "fr_FR"],
"default": "en_EN" "default": "en_US"
}, },
{ {
"name": "multisite", "name": "multisite",

View file

@ -161,8 +161,11 @@ WARNING echo ""
#================================================= #=================================================
sudo wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar sudo wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
php $final_path/wp-cli.phar --allow-root plugin install simple-ldap-login --path=$final_path wpcli_alias="php $final_path/wp-cli.phar --allow-root --path=$final_path"
php $final_path/wp-cli.phar --allow-root plugin install http-authentication --path=$final_path
$wpcli_alias plugin install simple-ldap-login
$wpcli_alias plugin install http-authentication
$wpcli_alias plugin install companion-auto-update
#================================================= #=================================================
# LOAD SQL CONFIG # LOAD SQL CONFIG
@ -173,15 +176,14 @@ ynh_replace_string "__DOMAIN_PATH__" "$domain$path_url" ../conf/sql/*.sql
ynh_replace_string "__DATE__" "$(date +%s)" ../conf/sql/*.sql ynh_replace_string "__DATE__" "$(date +%s)" ../conf/sql/*.sql
# Charge les commandes sql communes à tous les scripts. # Charge les commandes sql communes à tous les scripts.
# mysql --debug-check -u $db_user -p$db_pwd $db_user < ../conf/sql/common.sql
ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/common.sql ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/common.sql
#================================================= #=================================================
# SET LANGUAGE # SET LANGUAGE
#================================================= #=================================================
php $final_path/wp-cli.phar --allow-root --path=$final_path core language install $language $wpcli_alias core language install $language
php $final_path/wp-cli.phar --allow-root --path=$final_path core language activate $language $wpcli_alias core language activate $language
#================================================= #=================================================
# CONFIGURE MULTISITE # CONFIGURE MULTISITE
@ -194,35 +196,23 @@ then
ynh_replace_string "//--MULTISITE1--define" "define " $final_path/wp-config.php ynh_replace_string "//--MULTISITE1--define" "define " $final_path/wp-config.php
# Active le multisite via wp-cli. # Active le multisite via wp-cli.
ALL_QUIET php $final_path/wp-cli.phar core multisite-convert --allow-root --path=$final_path --base=$path_url/ ALL_QUIET $wpcli_alias core multisite-convert --base=$path_url/
# Active le multisite wordpress # Active le multisite wordpress
ynh_replace_string "//--MULTISITE2--define" "define" $final_path/wp-config.php ynh_replace_string "//--MULTISITE2--define" "define" $final_path/wp-config.php
# Charge les commandes sql pour activer les plugins
if [ $is_public -eq 0 ]
then
ynh_replace_string "#--PRIVATE--" "" ../conf/sql/multisite.sql
else
ynh_replace_string "#--PUBLIC--" "" ../conf/sql/multisite.sql
fi
ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/multisite.sql ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/multisite.sql
else else
if [ $is_public -eq 0 ]
then
ynh_replace_string "#--PRIVATE--" "" /etc/nginx/conf.d/$domain.d/$app.conf
ynh_replace_string "#--PRIVATE--" "" ../conf/sql/single.sql
else
ynh_replace_string "//--PUBLIC--define" "define" $final_path/wp-config.php
ynh_replace_string "#--PRIVATE--" "#" /etc/nginx/conf.d/$domain.d/$app.conf
ynh_replace_string "#--PUBLIC--" "" ../conf/sql/single.sql
fi
# Charge les commandes sql pour activer les plugins
ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/single.sql ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/single.sql
fi fi
# Décommente les add_filter, qui auraient provoqué une erreur avec wp-cli #=================================================
ynh_replace_string "//add_filter" "add_filter" $final_path/wp-config.php # ACTIVATE WORDPRESS' PLUGINS
#=================================================
$wpcli_alias plugin activate simple-ldap-login
$wpcli_alias plugin activate http-authentication
$wpcli_alias plugin activate companion-auto-update
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE

View file

@ -66,6 +66,10 @@ if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set $app db_name $db_name
fi fi
if grep add_filter.*auto_update $final_path/wp-config.php; then # Si des add_filter demeurent dans le wp-config
sed --in-place '/add_filter.*auto_update/d' $final_path/wp-config.php
fi
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -115,14 +119,6 @@ ynh_add_fpm_config
# Verify the checksum and backup the file if it's different # Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/wp-config.php" ynh_backup_if_checksum_is_different "$final_path/wp-config.php"
#=================================================
# UPDATE WORDPRESS' PLUGINS
#=================================================
sudo wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
php $final_path/wp-cli.phar --allow-root plugin update simple-ldap-login --path=$final_path
php $final_path/wp-cli.phar --allow-root plugin update http-authentication --path=$final_path
#================================================= #=================================================
# CONFIGURE MULTISITE # CONFIGURE MULTISITE
#================================================= #=================================================
@ -141,6 +137,20 @@ else
fi fi
ynh_app_setting_set $app multisite $multisite ynh_app_setting_set $app multisite $multisite
#=================================================
# UPDATE WORDPRESS' PLUGINS
#=================================================
sudo wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
wpcli_alias="php $final_path/wp-cli.phar --allow-root --path=$final_path"
update_plugin () {
( $wpcli_alias plugin is-installed $1 && $wpcli_alias plugin update $1 ) || $wpcli_alias plugin install $1
}
update_plugin simple-ldap-login
update_plugin http-authentication
update_plugin companion-auto-update
$wpcli_alias plugin activate companion-auto-update
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
@ -175,3 +185,9 @@ fi
#================================================= #=================================================
sudo systemctl reload nginx sudo systemctl reload nginx
#=================================================
# REMOVE WP-CLI.PHAR
#=================================================
ynh_secure_remove $final_path/wp-cli.phar