mirror of
https://github.com/YunoHost-Apps/wordpress_ynh.git
synced 2024-09-03 20:36:10 +02:00
trap et maj ynh 2.4
This commit is contained in:
parent
09c70b21c0
commit
9fbd47c515
7 changed files with 196 additions and 30 deletions
|
@ -2,6 +2,9 @@
|
|||
"name": "WordPress MultiSite",
|
||||
"id": "wordpressms",
|
||||
"packaging_format": 1,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4"
|
||||
},
|
||||
"description": {
|
||||
"en": "Create a beautiful blog or website easily",
|
||||
"fr": "Logiciel de création de blog ou de site Web"
|
||||
|
@ -65,7 +68,7 @@
|
|||
"default": "No"
|
||||
},
|
||||
{
|
||||
"name": "public_site",
|
||||
"name": "is_public",
|
||||
"ask": {
|
||||
"en": "Is it a public WordPress site ?",
|
||||
"fr": "Est-ce un site public ?"
|
||||
|
|
77
manifest2.2.json
Normal file
77
manifest2.2.json
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"name": "WordPress MultiSite",
|
||||
"id": "wordpressms",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Create a beautiful blog or website easily",
|
||||
"fr": "Logiciel de création de blog ou de site Web"
|
||||
},
|
||||
"version": "4.4",
|
||||
"url": "https://wordpress.org/",
|
||||
"licence": "free",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"multi_instance": "true",
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for WordPress",
|
||||
"fr": "Choisissez un domaine pour WordPress"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for WordPress",
|
||||
"fr": "Choisissez un chemin pour WordPress"
|
||||
},
|
||||
"example": "/blog",
|
||||
"default": "/blog"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"ask": {
|
||||
"en": "Choose the WordPress administrator (must be an existing YunoHost user)",
|
||||
"fr": "Administrateur du site (doit être un utilisateur YunoHost existant)"
|
||||
},
|
||||
"example": "homer"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"ask": {
|
||||
"en": "Choose the language of the WordPress site",
|
||||
"fr": "Choissisez la langue du WordPress"
|
||||
},
|
||||
"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": "is_public",
|
||||
"ask": {
|
||||
"en": "Is it a public WordPress site ?",
|
||||
"fr": "Est-ce un site public ?"
|
||||
},
|
||||
"choices": ["Yes", "No"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=wordpressms
|
||||
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)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
|
|
|
@ -1,19 +1,59 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Renseigne les variables à partir des arguments.
|
||||
domain=$1
|
||||
path=$2
|
||||
admin_wordpress=$3
|
||||
language=$4
|
||||
multisite=$5
|
||||
is_public=$6
|
||||
app=wordpressms
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
# Retrieve arguments
|
||||
if [ $ynh_version = "2.4" ]
|
||||
then
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
admin_wordpress=$YNH_APP_ARG_ADMIN
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
multisite=$YNH_APP_ARG_MULTISITE
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
else
|
||||
domain=$1
|
||||
path=$2
|
||||
admin_wordpress=$3
|
||||
language=$4
|
||||
multisite=$5
|
||||
is_public=$6
|
||||
app=wordpressms
|
||||
fi
|
||||
|
||||
|
||||
# Delete files and db if exit with an error
|
||||
EXIT_PROPERLY () {
|
||||
trap '' ERR
|
||||
echo -e "\e[91m \e[1m" # Shell in light red bold
|
||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!"
|
||||
|
||||
if [ $ynh_version = "2.2" ]; then
|
||||
/bin/bash ./remove # Appel le script remove. En 2.2, ce comportement n'est pas automatique.
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
TRAP_ON () { # Activate signal capture
|
||||
trap EXIT_PROPERLY ERR # Capturing exit signals on error
|
||||
}
|
||||
TRAP_OFF () { # Ignoring signal capture until TRAP_ON
|
||||
# Pour une raison que j'ignore, la fonction TRAP_ON fonctionne très bien.
|
||||
# Mais pas la fonction TRAP_OFF...
|
||||
# Utiliser directement `trap '' ERR` dans le code pour l'utiliser, à la place de la fonction.
|
||||
trap '' ERR # Ignoring exit signals
|
||||
}
|
||||
TRAP_ON
|
||||
|
||||
|
||||
# Vérifie la validité de l'user admin
|
||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin_wordpress\""
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo "Wrong admin"
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie la présence du / en début de path
|
||||
|
@ -24,7 +64,7 @@ fi
|
|||
# Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
|
@ -32,7 +72,7 @@ final_path=/var/www/$app
|
|||
if [ -e "$final_path" ]
|
||||
then
|
||||
echo "This path already contains a folder"
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
|
||||
|
@ -46,11 +86,15 @@ sudo yunohost app setting $app multisite -v $multisite
|
|||
|
||||
|
||||
# Génère un mot de passe aléatoire.
|
||||
db_pwd=$(cat /dev/urandom | head -n20 | tr -c -d 'A-Za-z0-9' | head -c20)
|
||||
db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
db_user=$app
|
||||
# Initialise la base de donnée et stocke le mot de passe mysql.
|
||||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
ynh_mysql_create_db $db_user $db_user $db_pwd
|
||||
else
|
||||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
fi
|
||||
sudo yunohost app setting $app mysqlpwd -v $db_pwd
|
||||
|
||||
|
||||
|
|
|
@ -1,27 +1,56 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=wordpressms
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
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
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
else
|
||||
app=wordpressms
|
||||
MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql"
|
||||
fi
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
# Suppression de la base de donnée et de l'utilisateur associé.
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
db_user=$app
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
|
||||
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
|
||||
echo "Delete db"
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
ynh_mysql_drop_db $db_user
|
||||
ynh_mysql_drop_user $db_user
|
||||
else
|
||||
mysql -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Suppression du dossier de l'application
|
||||
sudo rm -rf /var/www/$app
|
||||
if [ -e "/var/www/$app" ]; then # Delete final_path
|
||||
echo "Delete app dir"
|
||||
sudo rm -r "/var/www/$app"
|
||||
fi
|
||||
|
||||
# Suppression de la configuration nginx
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||
echo "Delete nginx config"
|
||||
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo service nginx reload
|
||||
fi
|
||||
|
||||
# Suppression de la configuration du pool php-fpm
|
||||
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
||||
sudo rm -f /etc/php5/fpm/conf.d/20-$app.ini
|
||||
|
||||
# Recharge la configuration Nginx et php5-fpm
|
||||
sudo service nginx reload
|
||||
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
|
||||
echo "Delete fpm config"
|
||||
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
|
||||
fi
|
||||
if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config
|
||||
echo "Delete php config"
|
||||
sudo rm "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
fi
|
||||
sudo service php5-fpm reload
|
||||
|
||||
# Régénère la configuration de SSOwat
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
echo -e "\e[0m" # Restore normal color
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=wordpressms
|
||||
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)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=app_name
|
||||
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
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue