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

Merge abeudin package

This commit is contained in:
Maniack Crudelis 2016-05-22 00:10:36 +02:00
parent 9fbd47c515
commit da767c032a
7 changed files with 127 additions and 61 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "WordPress MultiSite", "name": "WordPress MultiSite",
"id": "wordpressms", "id": "wordpress",
"packaging_format": 1, "packaging_format": 1,
"requirements": { "requirements": {
"yunohost": ">= 2.4" "yunohost": ">= 2.4"
@ -13,8 +13,8 @@
"url": "https://wordpress.org/", "url": "https://wordpress.org/",
"licence": "free", "licence": "free",
"maintainer": { "maintainer": {
"name": "Maniack Crudelis", "name": "Maniack Crudelis et beudbeud",
"email": "maniackc_dev@crudelis.fr" "email": "maniackc_dev@crudelis.fr, beudbeud@beudibox.fr"
}, },
"multi_instance": "true", "multi_instance": "true",
"services": [ "services": [
@ -47,7 +47,7 @@
"en": "Choose the WordPress administrator (must be an existing YunoHost user)", "en": "Choose the WordPress administrator (must be an existing YunoHost user)",
"fr": "Administrateur du site (doit être un utilisateur YunoHost existant)" "fr": "Administrateur du site (doit être un utilisateur YunoHost existant)"
}, },
"example": "homer" "example": "john"
}, },
{ {
"name": "language", "name": "language",
@ -73,7 +73,8 @@
"en": "Is it a public WordPress site ?", "en": "Is it a public WordPress site ?",
"fr": "Est-ce un site public ?" "fr": "Est-ce un site public ?"
}, },
"choices": ["Yes", "No"] "choices": ["Yes", "No"],
"default": "Yes"
} }
] ]
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "WordPress MultiSite", "name": "WordPress MultiSite",
"id": "wordpressms", "id": "wordpress",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Create a beautiful blog or website easily", "en": "Create a beautiful blog or website easily",
@ -10,8 +10,8 @@
"url": "https://wordpress.org/", "url": "https://wordpress.org/",
"licence": "free", "licence": "free",
"maintainer": { "maintainer": {
"name": "Maniack Crudelis", "name": "Maniack Crudelis et beudbeud",
"email": "maniackc_dev@crudelis.fr" "email": "maniackc_dev@crudelis.fr, beudbeud@beudibox.fr"
}, },
"multi_instance": "true", "multi_instance": "true",
"services": [ "services": [
@ -44,7 +44,7 @@
"en": "Choose the WordPress administrator (must be an existing YunoHost user)", "en": "Choose the WordPress administrator (must be an existing YunoHost user)",
"fr": "Administrateur du site (doit être un utilisateur YunoHost existant)" "fr": "Administrateur du site (doit être un utilisateur YunoHost existant)"
}, },
"example": "homer" "example": "john"
}, },
{ {
"name": "language", "name": "language",
@ -70,7 +70,8 @@
"en": "Is it a public WordPress site ?", "en": "Is it a public WordPress site ?",
"fr": "Est-ce un site public ?" "fr": "Est-ce un site public ?"
}, },
"choices": ["Yes", "No"] "choices": ["Yes", "No"],
"default": "Yes"
} }
] ]
} }

View file

@ -1,28 +1,26 @@
#!/bin/bash #!/bin/bash
# Récupère les infos de l'application. # The parameter $1 is the backup directory location dedicated to the app
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) backup_dir=$1
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME # The parameter $2 is theid of the app instance
else app=$2
app=wordpressms
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
final_path=$(sudo yunohost app setting $app final_path)
# Copy the app files
sudo mkdir -p ${backup_dir}/var/www
sudo cp -a $final_path "${backup_dir}/var/www/$app"
# The parameter $1 is the backup directory location # Copy the conf files
# which will be compressed afterward sudo mkdir -p "${backup_dir}/conf"
backup_dir=$1/apps/$app sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
sudo mkdir -p "$backup_dir"
# Backup sources & data
sudo cp -a $final_path/. $backup_dir/sources
# Copy Nginx and YunoHost parameters to make the script "standalone"
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
# Copy dedicated php-fpm process to backup folder # Copy dedicated php-fpm process to backup folder
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $backup_dir/php-fpm.conf sudo cp -a /etc/php5/fpm/pool.d/$app.conf "${backup_dir}/conf/php-fpm.conf"
sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini $backup_dir/php-fpm.ini sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini "${backup_dir}/conf/php-fpm.ini"
# Backup db
root_pwd=$(sudo cat /etc/yunohost/mysql)
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ${backup_dir}/db.sql"

View file

@ -22,7 +22,7 @@ else
language=$4 language=$4
multisite=$5 multisite=$5
is_public=$6 is_public=$6
app=wordpressms app=wordpress
fi fi
@ -156,7 +156,7 @@ done
sudo chown -R www-data: $final_path sudo chown -R www-data: $final_path
# Donne un accès public pour curl # Donne un accès public pour curl
sudo yunohost app setting wordpressms skipped_uris -v "/" sudo yunohost app setting $app skipped_uris -v "/"
# Recharge la configuration Nginx et php5-fpm # Recharge la configuration Nginx et php5-fpm
sudo service nginx reload sudo service nginx reload
sudo service php5-fpm reload sudo service php5-fpm reload
@ -194,7 +194,7 @@ then
sudo apt-get update sudo apt-get update
sudo apt-get install php5-cli -qy sudo apt-get install php5-cli -qy
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
# Autorise le multisite wordpress # Autorise le multisite wordpress
sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php
@ -216,11 +216,11 @@ then
else else
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/single.sql sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/single.sql
else else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php 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@#--PRIVATE--@#@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql
fi fi
# Charge les commandes sql pour les plugins # Charge les commandes sql pour les plugins
@ -240,7 +240,7 @@ sudo chown -R www-data:root $final_path/wp-content
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
# Retire l'accès public # Retire l'accès public
sudo yunohost app setting wordpressms skipped_uris -d sudo yunohost app setting $app skipped_uris -d
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
fi fi

View file

@ -8,7 +8,7 @@ if [ $ynh_version = "2.4" ]; then
# Source app helpers # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
else else
app=wordpressms app=wordpress
MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql" MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql"
fi fi
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)

View file

@ -1,24 +1,53 @@
#!/bin/bash #!/bin/bash
# This restore script is adapted to Yunohost >=2.4
# Récupère les infos de l'application. # The parameter $1 is the backup directory location dedicated to the app
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) backup_dir=$1
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME # The parameter $2 is the id of the app instance ex: ynhexample__2
else app=$2
app=wordpressms
fi # Get old parameter of the app
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
is_public=$(sudo yunohost app setting $app is_public)
final_path=$(sudo yunohost app setting $app final_path)
# The parameter $1 is the uncompressed restore directory location # Check domain/path availability
backup_dir=$1/apps/$app sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
echo "There is already an app on this URL : $domain$path" | sudo tee /dev/stderr
exit 1
fi
# Restore sources & data if [ -d $final_path ]; then
sudo cp -a $backup_dir/sources/. $final_path echo "There is already a directory: $final_path " | sudo tee /dev/stderr
exit 1
fi
sudo cp -a "${backup_dir}/var/www/$app" $final_path
# Restore Nginx and YunoHost parameters
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app db_pwd=$(sudo yunohost app setting $app mysqlpwd)
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf db_user=$app
sudo yunohost app initdb $db_user -p $db_pwd
sudo su -c "mysql -u $db_user -p$db_pwd $app < ${backup_dir}/db.sql"
sudo rm -f "${backup_dir}/db.sql"
sudo sed -i -e "s/'DB_USER', *'[^']*'/'DB_USER', '$app'/g" $final_path/wp-config.php
sudo sed -i -e "s/'DB_NAME', *'[^']*'/'DB_NAME', '$app'/g" $final_path/wp-config.php
# Set permissions
sudo chown -R www-data: $final_path
# Restore conf files
conf=/etc/nginx/conf.d/$domain.d/$app.conf
if [ -f $conf ]; then
echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
exit 1
fi
sudo cp -a "${backup_dir}/conf/nginx.conf" $conf
# Reload Nginx
sudo service nginx reload
# Copy dedicated php-fpm process from backup folder to the right location # Copy dedicated php-fpm process from backup folder to the right location
sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
@ -26,5 +55,9 @@ sudo cp -a $backup_dir/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini
# And restart service # And restart service
sudo service php5-fpm reload sudo service php5-fpm reload
# Restart webserver # Set ssowat config
sudo service nginx reload if [ "$is_public" = "No" ];
then
sudo yunohost app setting $app skipped_uris -d
fi
sudo yunohost app ssowatconf

View file

@ -5,14 +5,48 @@ ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.'
if [ $ynh_version = "2.4" ]; then if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
else else
app=wordpressms app=wordpress
fi fi
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
admin_wordpress=$(sudo yunohost app setting $app admin)
language=$(sudo yunohost app setting $app language)
is_public=$(sudo yunohost app setting $app is_public) is_public=$(sudo yunohost app setting $app is_public)
multisite=$(sudo yunohost app setting $app multisite) multisite=$(sudo yunohost app setting $app multisite)
final_path=$(sudo yunohost app setting $app final_path) final_path=$(sudo yunohost app setting $app final_path)
root_pwd=$(sudo cat /etc/yunohost/mysql)
db_name=$app
if [[ "$admin_wordpress" = "" ]];
then
mysql -u root -p$root_pwd $db_name -e "select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';"
admin_wordpress=$(cat /tmp/wordpressuser)
sudo rm -f /tmp/wordpressuser
fi
if [[ "$language" = "" ]];
then
language=$(sudo grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
fi
if [[ "$is_public" = "" ]];
then
mysql -u root -p$root_pwd $db_name -e "select option_value from wp_options WHERE option_name='active_plugins' INTO OUTFILE '/tmp/wordpressispublic';"
grep -q http-authentication /tmp/wordpressispublic
if [[ $? -eq 0 ]];
then
is_public=Yes
else
is_public=No
fi
sudo rm -f /tmp/wordpressispublic
fi
# Check if admin is not null
if [[ "$admin_wordpress" = "" || "$is_public" = "" || "$language" = "" ]]; then
echo "Unable to upgrade, please contact support"
exit 1
fi
# Décompresse la source # Décompresse la source
tar -x -f ../sources/wordpress.tar.gz tar -x -f ../sources/wordpress.tar.gz
@ -43,11 +77,11 @@ sudo service php5-fpm reload
if [ "$multisite" = "Yes" ]; if [ "$multisite" = "Yes" ];
then then
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
else else
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
else else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
fi fi
@ -66,14 +100,13 @@ sudo chown -R www-data:root $final_path/wp-content
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
# Retire l'accès public # Retire l'accès public
sudo yunohost app setting wordpressms skipped_uris -d sudo yunohost app setting $app skipped_uris -d
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
fi fi
# Recharge la configuration Nginx et php5-fpm # Recharge la configuration Nginx
sudo service nginx reload sudo service nginx reload
sudo service php5-fpm reload
# Régénère la configuration de SSOwat # Régénère la configuration de SSOwat
sudo yunohost app ssowatconf sudo yunohost app ssowatconf