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

View file

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

View file

@ -1,28 +1,26 @@
#!/bin/bash
# Récupère les infos de l'application.
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=wordpressms
fi
final_path=$(sudo yunohost app setting $app final_path)
# The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1
# The parameter $2 is theid of the app instance
app=$2
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
# which will be compressed afterward
backup_dir=$1/apps/$app
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 the conf files
sudo mkdir -p "${backup_dir}/conf"
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
# 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/conf.d/20-$app.ini $backup_dir/php-fpm.ini
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}/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
multisite=$5
is_public=$6
app=wordpressms
app=wordpress
fi
@ -156,7 +156,7 @@ done
sudo chown -R www-data: $final_path
# 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
sudo service nginx reload
sudo service php5-fpm reload
@ -194,7 +194,7 @@ then
sudo apt-get update
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
sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php
@ -216,11 +216,11 @@ then
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" /etc/nginx/conf.d/$domain.d/$app.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@#--PRIVATE--@#@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql
fi
# 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" ];
then
# 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
fi

View file

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

View file

@ -1,24 +1,53 @@
#!/bin/bash
# This restore script is adapted to Yunohost >=2.4
# Récupère les infos de l'application.
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=wordpressms
fi
final_path=$(sudo yunohost app setting $app final_path)
# The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1
# The parameter $2 is the id of the app instance ex: ynhexample__2
app=$2
# Get old parameter of the app
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
backup_dir=$1/apps/$app
# Check domain/path availability
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
sudo cp -a $backup_dir/sources/. $final_path
if [ -d $final_path ]; then
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
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
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
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
sudo service php5-fpm reload
# Restart webserver
sudo service nginx reload
# Set ssowat config
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
app=$YNH_APP_INSTANCE_NAME
else
app=wordpressms
app=wordpress
fi
domain=$(sudo yunohost app setting $app domain)
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)
multisite=$(sudo yunohost app setting $app multisite)
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
tar -x -f ../sources/wordpress.tar.gz
@ -43,11 +77,11 @@ sudo service php5-fpm reload
if [ "$multisite" = "Yes" ];
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
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" /etc/nginx/conf.d/$domain.d/$app.conf
else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
fi
@ -66,14 +100,13 @@ sudo chown -R www-data:root $final_path/wp-content
if [ "$is_public" = "No" ];
then
# 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
fi
# Recharge la configuration Nginx et php5-fpm
# Recharge la configuration Nginx
sudo service nginx reload
sudo service php5-fpm reload
# Régénère la configuration de SSOwat
sudo yunohost app ssowatconf