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

Multisite fonctionnel

This commit is contained in:
Maniack Crudelis 2014-12-08 23:42:55 +01:00
parent 5159f3fe2d
commit 0736014586
1198 changed files with 1496 additions and 967 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.swp
*~
Notes

View file

@ -1,13 +1,19 @@
#--MULTISITE--if (!-e $request_filename) {
#--MULTISITE--rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#--MULTISITE--rewrite ^PATHTOCHANGE(/[^/]+)?(/wp-.*) PATHTOCHANGE$2 last;
#--MULTISITE--rewrite ^PATHTOCHANGE(/[^/]+)?(/.*\.php)$ PATHTOCHANGE$2 last;
#--MULTISITE--}
location PATHTOCHANGE {
alias ALIASTOCHANGE;
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
index index.php;
if (!-e $request_filename)
{
rewrite ^(.+)$ PATHTOCHANGE/index.php?q=$1 last;
}
#--PRIVATE--if ($scheme = http) {
#--PRIVATE-- rewrite ^ https://$server_name$request_uri? permanent;
#--PRIVATE--}
client_max_body_size 30m;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
@ -18,6 +24,6 @@ location PATHTOCHANGE {
fastcgi_param PATH_INFO $fastcgi_path_info;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
#--PRIVATE--# Include SSOWAT user panel.
#--PRIVATE--include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,17 +0,0 @@
location PATHTOCHANGE {
alias ALIASTOCHANGE;
index index.php;
if (!-e $request_filename)
{
rewrite ^(.+)$ PATHTOCHANGE/index.php?q=$1 last;
}
client_max_body_size 30m;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

View file

@ -1,4 +0,0 @@
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('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://URLWORDPRESS/wp-login.php";s:10:"logout_uri";s:28:"https://URLWORDPRESS/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:1;}','yes');
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';
INSERT INTO wp_options (option_id,option_name,option_value,autoload) VALUES('','WPLANG','I18NTOCHANGE','yes') ON DUPLICATE KEY UPDATE option_value=VALUES(option_value);

View file

@ -1,4 +1,2 @@
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('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://URLWORDPRESS/wp-login.php";s:10:"logout_uri";s:28:"https://URLWORDPRESS/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:0;}','yes');
UPDATE wp_options SET option_value='a:1:{i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins';
INSERT INTO wp_options (option_id,option_name,option_value,autoload) VALUES('','WPLANG','I18NTOCHANGE','yes') ON DUPLICATE KEY UPDATE option_value=VALUES(option_value);

3
conf/sql/multisite.sql Normal file
View file

@ -0,0 +1,3 @@
INSERT INTO wp_options VALUES('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://URLWORDPRESS/wp-login.php";s:10:"logout_uri";s:28:"https://URLWORDPRESS/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:0;}','yes');
#--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';

3
conf/sql/single.sql Normal file
View file

@ -0,0 +1,3 @@
INSERT INTO wp_options VALUES('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://URLWORDPRESS/wp-login.php";s:10:"logout_uri";s:28:"https://URLWORDPRESS/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:1;}','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

@ -24,6 +24,15 @@ $table_prefix = 'wp_';
// Debug mode
define('WP_DEBUG', false);
// Multisite
//--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
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
@ -32,4 +41,4 @@ if ( !defined('ABSPATH') )
require_once(ABSPATH . 'wp-settings.php');
// Force https redirect
//define('FORCE_SSL_ADMIN', true);
//--PUBLIC--define('FORCE_SSL_ADMIN', true);

View file

@ -1,6 +1,6 @@
{
"name": "WordPress",
"id": "wordpress",
"name": "WordPress MultiSite",
"id": "wordpressms",
"description": {
"en": "Create a beautiful blog or website easily",
"fr": "Logiciel de création de blog ou de site Web"
@ -48,6 +48,15 @@
"choices": ["en_EN", "fr_FR"],
"default": "en_EN"
},
{
"name": "multisite",
"ask": {
"en": "Enable multisite option ?",
"fr": "Activer l'option multisite ?"
},
"choices": ["Yes", "No"],
"default": "No"
},
{
"name": "public_site",
"ask": {
@ -55,7 +64,6 @@
"fr": "Est-ce un site public ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}

100
scripts/install Executable file → Normal file
View file

@ -5,7 +5,8 @@ domain=$1
path=$2
admin_wordpress=$3
language=$4
is_public=$5
multisite=$5
is_public=$6
# Check if admin exists
sudo yunohost user list --json | grep -q "\"username\": \"$admin_wordpress\""
@ -13,12 +14,14 @@ if [[ ! $? -eq 0 ]]; then
echo "Wrong admin"
exit 1
fi
sudo yunohost app setting wordpress admin -v $admin_wordpress
sudo yunohost app setting wordpress language -v $language
sudo yunohost app setting wordpress is_public -v $is_public
# Add settings to YunoHost
sudo yunohost app setting wordpressms admin -v $admin_wordpress
sudo yunohost app setting wordpressms language -v $language
sudo yunohost app setting wordpressms is_public -v $is_public
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a wordpress
sudo yunohost app checkurl $domain$path -a wordpressms
if [[ ! $? -eq 0 ]]; then
exit 1
fi
@ -26,23 +29,29 @@ fi
# Generate random password
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
# Use 'wordpress' as database name and user
db_user=wordpress
# Use 'wordpressms' as database name and user
db_user=wordpressms
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd
sudo yunohost app setting wordpress mysqlpwd -v $db_pwd
sudo yunohost app setting wordpressms mysqlpwd -v $db_pwd
# Copy files to the right place
final_path=/var/www/wordpress
final_path=/var/www/wordpressms
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
sudo cp -a ../sources/wordpress/* $final_path
sudo cp -a ../sources/ajouts/* $final_path
sudo cp ../conf/wp-config.php $final_path/wp-config.php
# Change variables in Wordpress configuration
sudo sed -i "s/yunouser/$db_user/g" $final_path/wp-config.php
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/wp-config.php
sudo sed -i "s/yunobase/$db_user/g" $final_path/wp-config.php
sudo sed -i "s/__DOMAIN__/$domain/g" $final_path/wp-config.php
sudo sed -i "s@__PATH__@$path@g" $final_path/wp-config.php
for i in 1 2 3 4 5 6 7 8
do
j=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{40\}\).*/\1/p')
@ -55,20 +64,18 @@ do
sudo sed -i "s/KEY$i/$j/g" $final_path/wp-config.php
done
sudo sed -i "s@URLWORDPRESS@$domain$path@g" ../conf/*.sql
sudo sed -i "s/I18NTOCHANGE/$language/g" ../conf/*.sql
# Set permissions to wordpress directory
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/wordpress.conf
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/wordpressms.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting wordpress skipped_uris -v "/"
# Donne un accès public pour curl
sudo yunohost app setting wordpressms skipped_uris -v "/"
sudo yunohost app ssowatconf
# Wordpress installation
@ -85,14 +92,59 @@ do
let loop_number++
done
# Replace variables in sql scripts
sudo sed -i "s@URLWORDPRESS@$domain$path@g" ../conf/sql/*.sql
sudo sed -i "s/I18NTOCHANGE/$language/g" ../conf/sql/*.sql
sudo sed -i "s/__DATE__/$(date +%s)/g" ../conf/sql/*.sql
# Charge les commandes sql communes à tous les scripts.
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/common.sql
if [ "$multisite" = "Yes" ];
then
# Installation de php5-cli pour wp-cli
sudo apt-get install php5-cli -qy
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf
# Autorise le multisite wordpress
sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php
# Active le multisite via wp-cli.
php $final_path/wp-cli.phar core multisite-convert --path=$final_path --base=$path/
echo "The 2 warnings of php about \"Permission denied\" on wp-config.php are normal. The install script writing into this file, not wp-cli!"
# Active le multisite wordpress
sudo sed -i "s@//--MULTISITE2--define@define@g" $final_path/wp-config.php
# Charge les commandes sql pour les plugins
if [ "$is_public" = "No" ];
then
sudo yunohost app setting wordpress skipped_uris -d
sudo yunohost app ssowatconf
mysql -u $db_user -p$db_pwd $db_user < ../conf/private.sql
sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/multisite.sql
else
mysql -u $db_user -p$db_pwd $db_user < ../conf/public.sql
sudo cp ../conf/nginx.conf-public /etc/nginx/conf.d/$domain.d/wordpress.conf
sudo service nginx reload
sudo sed -i "s@//define('FORCE_SSL_ADMIN@define('FORCE_SSL_ADMIN@g" $final_path/wp-config.php
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/multisite.sql
fi
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/multisite.sql
else
if [ "$is_public" = "No" ];
then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf
sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/single.sql
else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
sudo sed -i "s@#--PRIVATE--@#@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql
fi
# Charge les commandes sql pour les plugins
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/single.sql
fi
if [ "$is_public" = "No" ];
then
# Retire l'accès public
sudo yunohost app setting wordpressms skipped_uris -d
sudo yunohost app ssowatconf
fi
sudo service nginx reload
# wp-cli me semble un peu trop permissif... Il a terminer son travail...
sudo rm $final_path/wp-cli.phar

BIN
sources/ajouts/wp-cli.phar Normal file

Binary file not shown.

View file

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 196 KiB

View file

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View file

@ -41,6 +41,14 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
</a>
</h2>
<div class="changelog point-releases">
<h3><?php echo _n( 'Maintenance and Security Release', 'Maintenance and Security Releases', 1 ); ?></h3>
<p><?php printf( _n( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.', 23 ), '4.0.1', number_format_i18n( 23 ) ); ?>
<?php printf( __( 'For more information, see <a href="%s">the release notes</a>.' ), 'http://codex.wordpress.org/Version_4.0.1' ); ?>
</p>
</div>
<div class="changelog">
<div class="about-overview">
<?php if ( ( $locale = get_locale() ) && 'en_' === substr( $locale, 0, 3 ) ) : ?>

Some files were not shown because too many files have changed in this diff Show more