diff --git a/check_process b/check_process index a727bb7..aad1bd6 100644 --- a/check_process +++ b/check_process @@ -8,6 +8,7 @@ multisite="No" is_public="Yes" (PUBLIC|public=Yes|private=No) ; Checks + pkg_linter=1 setup_sub_dir=1 setup_root=1 setup_nourl=0 diff --git a/manifest.json b/manifest.json index 4a0e324..67ef8ca 100644 --- a/manifest.json +++ b/manifest.json @@ -1,81 +1,84 @@ { - "name": "WordPress", - "id": "wordpress", - "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" - }, + "name": "WordPress", + "id": "wordpress", + "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" + }, "version": "4.5.2", "url": "https://wordpress.org/", - "licence": "free", - "maintainer": { - "name": "Maniack Crudelis et beudbeud", - "email": "maniackc_dev@crudelis.fr, beudbeud@beudibox.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": "john" - }, - { - "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"], - "default": "Yes" - } - ] - } + "license": "free", + "maintainer": { + "name": "Maniack Crudelis", + "email": "maniackc_dev@crudelis.fr" + }, + "multi_instance": true, + "services": [ + "nginx", + "php5-fpm", + "mysql" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for WordPress", + "fr": "Choisissez un domaine pour WordPress" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for WordPress", + "fr": "Choisissez un chemin pour WordPress" + }, + "example": "/blog", + "default": "/blog" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose the WordPress administrator (must be an existing YunoHost user)", + "fr": "Administrateur du site (doit être un utilisateur YunoHost existant)" + }, + "example": "john" + }, + { + "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"], + "default": "Yes" + } + ] + } } diff --git a/scripts/.fonctions b/scripts/.fonctions index c225234..ab08197 100755 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -1,5 +1,7 @@ #!/bin/bash +ynh_version="2.4" + YNH_VERSION () { # Renvoi le numéro de version de la moulinette Yunohost ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) } @@ -7,7 +9,7 @@ YNH_VERSION () { # Renvoi le numéro de version de la moulinette Yunohost CHECK_VAR () { # Vérifie que la variable n'est pas vide. # $1 = Variable à vérifier # $2 = Texte à afficher en cas d'erreur - test -n "$1" || (echo "$2" && false >&2) + test -n "$1" || (echo "$2" >&2 && false) } EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus. @@ -20,7 +22,7 @@ EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les # Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation. sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json - if [ $ynh_version = "2.2" ]; then + if [ "$ynh_version" = "2.2" ]; then /bin/bash $script_dir/remove # Appel le script remove. En 2.2, ce comportement n'est pas automatique. fi @@ -40,7 +42,7 @@ TRAP_OFF () { # Ignoring signal capture until TRAP_ON CHECK_USER () { # Vérifie la validité de l'user admin # $1 = Variable de l'user admin. - sudo yunohost user list --json | grep -q "\"username\": \"$1\"" || (echo "Wrong admin" && false >&2) + sudo yunohost user list --json | grep -q "\"username\": \"$1\"" || (echo "Wrong admin" >&2 && false) } CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin. @@ -81,7 +83,7 @@ SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_pa # $1 = Nom de l'archive téléchargée. wget -nv --show-progress -i ../sources/source_url -O $1 # Vérifie la somme de contrôle de la source téléchargée. - md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" && false >&2) + md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) # Décompresse la source if [ "$(echo ${1##*.})" == "gz" ]; then tar -x -f $1 diff --git a/scripts/backup b/scripts/backup index b5e5a0e..cc1e51d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,9 @@ backup_dir=$1 # The parameter $2 is theid of the app instance app=$2 +# Source app helpers +source /usr/share/yunohost/helpers + domain=$(sudo yunohost app setting $app domain) final_path=$(sudo yunohost app setting $app final_path) diff --git a/scripts/remove b/scripts/remove index 3fdddfd..2f2e447 100755 --- a/scripts/remove +++ b/scripts/remove @@ -2,11 +2,11 @@ source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script -# Récupère les infos de l'application. -app=$YNH_APP_INSTANCE_NAME - # Source app helpers source /usr/share/yunohost/helpers + +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME domain=$(sudo yunohost app setting $app domain) REMOVE_BDD $app # Suppression de la base de donnée et de l'utilisateur associé. diff --git a/scripts/restore b/scripts/restore index fd7566a..fda58a3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,6 +7,9 @@ backup_dir=$1 # The parameter $2 is the id of the app instance ex: ynhexample__2 app=$2 +# Source app helpers +source /usr/share/yunohost/helpers + # Get old parameter of the app domain=$(sudo yunohost app setting $app domain) path=$(sudo yunohost app setting $app path) @@ -24,12 +27,23 @@ 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 +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 +# Restore conf files +sudo cp -a "${backup_dir}/conf/nginx.conf" $conf + +# Reload Nginx +sudo service nginx reload + +sudo cp -a "${backup_dir}/var/www/$app" $final_path db_pwd=$(sudo yunohost app setting $app mysqlpwd) db_user=$app -sudo yunohost app initdb $db_user -p $db_pwd +ynh_mysql_create_db $db_user $db_user $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 @@ -41,20 +55,9 @@ sudo chown -R www-data: $final_path # Sauf le fichier de config wp-config.php qui appartient à root sudo chown root: $final_path/wp-config.php -# 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 -sudo cp -a $backup_dir/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini +sudo cp -a $backup_dir/conf/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf +sudo cp -a $backup_dir/conf/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini # And restart service sudo service php5-fpm reload diff --git a/scripts/upgrade b/scripts/upgrade index 59c3cb6..2aecb98 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -2,6 +2,9 @@ source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script +# Source app helpers +source /usr/share/yunohost/helpers + # Récupère les infos de l'application. app=$YNH_APP_INSTANCE_NAME domain=$(sudo yunohost app setting $app domain) @@ -13,6 +16,13 @@ multisite=$(sudo yunohost app setting $app multisite) final_path=$(sudo yunohost app setting $app final_path) CHECK_PATH # Vérifie et corrige la syntaxe du path. + +# Check if admin is not null +if [[ "$admin_wordpress" = "" || "$is_public" = "" || "$language" = "" ]]; then + echo "Unable to upgrade, please contact support" + exit 1 +fi + root_pwd=$(sudo cat /etc/yunohost/mysql) db_name=$app if [[ "$admin_wordpress" = "" ]]; @@ -35,12 +45,6 @@ then sudo yunohost app setting $app language -v $language fi -# Check if admin is not null -if [[ "$admin_wordpress" = "" || "$is_public" = "" || "$language" = "" ]]; then - echo "Unable to upgrade, please contact support" - exit 1 -fi - # Copie le fichier de config nginx sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Modifie les variables dans le fichier de configuration nginx