diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index c93210e..b59bef8 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,5 +1,5 @@ ; Additional php.ini defines, specific to this pool of workers. -php_admin_value[upload_max_filesize] = 50M -php_admin_value[memory_limit] = 64M -php_admin_value[post_max_size] = 50M +php_admin_value[upload_max_filesize] = 1G +php_admin_value[memory_limit] = 128M +php_admin_value[post_max_size] = 1G diff --git a/manifest.json b/manifest.json index 596085d..19028b4 100644 --- a/manifest.json +++ b/manifest.json @@ -30,7 +30,7 @@ "install" : [ { "name": "domain", - "type": "domain", + "type": "string", "ask": { "en": "Choose a domain for WordPress", "fr": "Choisissez un domaine pour WordPress" @@ -38,6 +38,26 @@ "example": "domain.org", "default": "site.yntest.weblibre.ca" }, + { + "name": "domain_dev", + "type": "string", + "ask": { + "en": "Choose a DEV domain for WordPress", + "fr": "Choisissez un domaine DEV pour WordPress" + }, + "example": "domain.org", + "default": "s8-dev.yntest.weblibre.ca" + }, + { + "name": "domain_staging", + "type": "string", + "ask": { + "en": "Choose a STAGING domain for WordPress", + "fr": "Choisissez un domaine STAGING pour WordPress" + }, + "example": "domain.org", + "default": "s8-staging.yntest.weblibre.ca" + }, { "name": "path", "type": "path", @@ -95,7 +115,27 @@ "ask": { "en": "If Git repo, enter here", "fr": "Si dépôt Git, entrez ici" - } + }, + "optional": true + }, + { + "name": "switch", + "type": "boolean", + "ask": { + "en": "Do not enter anything", + "fr": "Ne rien entrer ici" + }, + "default": false + }, + { + "name": "phpversion", + "type": "string", + "ask": { + "en": "Choose the PHP version", + "fr": "Choissisez la version de PHP" + }, + "choices": ["7.0" , "7.1", "7.2", "7.3", "7.4"], + "default": "7.3" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 4404f4b..2569476 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,9 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +YNH_PHP_VERSION=$YNH_APP_ARG_PHPVERSION -extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap" +extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-ssh2 php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-ldap" #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index c40d70e..527575b 100644 --- a/scripts/install +++ b/scripts/install @@ -21,12 +21,15 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN +domain_dev=$YNH_APP_ARG_DOMAIN_DEV +domain_staging=$YNH_APP_ARG_DOMAIN_STAGING path_url=$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 repo=$YNH_APP_ARG_REPO +switch=$YNH_APP_ARG_SWITCH app=$YNH_APP_INSTANCE_NAME @@ -38,6 +41,16 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +set +e +webpath=$(ynh_webpath_available --domain=$domain --path_url=$path_url 2>&1) +if [[ $(echo $webpath | grep 'unknown' | wc -l) = "1" ]]; then + yunohost domain add $domain + yunohost domain cert-install --no-checks $domain +elif [[ $(echo $webpath | grep 'False' | wc -l) = "1" ]]; then + ynh_die --message="Path not available: ${domain}${path_url}" +fi +ynh_abort_if_errors + # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -51,6 +64,8 @@ fi ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=domain_dev --value=$domain_dev +ynh_app_setting_set --app=$app --key=domain_staging --value=$domain_staging ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress ynh_app_setting_set --app=$app --key=language --value=$language @@ -76,7 +91,7 @@ ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name # CLONE REPO IF REQUIRED #================================================= -if [ -n $repo ] +if [ -n "$repo" ] then GIT_SSH_COMMAND='ssh -i /etc/yunohost/sshkey -o IdentitiesOnly=yes' git clone $repo $final_path git config --file $final_path/.git/config core.sshCommand "ssh -i /etc/yunohost/sshkey" @@ -124,8 +139,7 @@ else usage=high fi # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$usage --footprint=medium --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --usage=$usage --footprint=medium --package="$extra_php_dependencies" #================================================= # SPECIFIC SETUP @@ -187,7 +201,7 @@ ynh_script_progression --message="Installing WordPress plugins..." --weight=20 ynh_exec_warn_less wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=/usr/local/bin/wp chmod +x /usr/local/bin/wp -wpcli_alias="php$phpversion /usr/local/bin/wp --allow-root --path=$final_path" +wpcli_alias="php$YNH_PHP_VERSION /usr/local/bin/wp --allow-root --path=$final_path" $wpcli_alias plugin install authldap $wpcli_alias plugin install http-authentication @@ -259,7 +273,7 @@ ynh_store_file_checksum --file="$final_path/wp-config.php" #================================================= echo "# Reach everyday wp-cron.php to trig the internal WordPress cron. -0 3 * * * $app php$phpversion $final_path/wp-cron.php" > /etc/cron.d/$app +0 3 * * * $app php$YNH_PHP_VERSION $final_path/wp-cron.php" > /etc/cron.d/$app #================================================= # GENERIC FINALISATION @@ -332,3 +346,10 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordp #================================================= ynh_script_progression --message="Installation of $app completed" --last + +if [ $switch -eq 1 ] +then + yunohost app install -f /home/gcossette/wordpress_ynh -a "domain=$domain_dev&domain_dev=s8-dev.yntest.weblibre.ca&domain_staging=s8-staging.yntest.weblibre.ca&path=/&admin=gcossette&language=en_US&multisite=false&is_public=true&repo=&switch=0" + + yunohost app install -f /home/gcossette/wordpress_ynh -a "domain=$domain_staging&domain_dev=s8-dev.yntest.weblibre.ca&domain_staging=s8-staging.yntest.weblibre.ca&path=/&admin=gcossette&language=en_US&multisite=false&is_public=true&repo=&switch=0" +fi \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index d48c28a..47b57cc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -15,11 +15,22 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME +app_dev=$app-dev +app_staging=$app-staging +app_initial=$app domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain_dev=$(ynh_app_setting_get --app=$app --key=domain_dev) +db_name_dev=$(ynh_app_setting_get --app=$app --key=db_name_dev) +final_path_dev=$(ynh_app_setting_get --app=$app --key=final_path_dev) + +domain_staging=$(ynh_app_setting_get --app=$app --key=domain_staging) +db_name_staging=$(ynh_app_setting_get --app=$app --key=db_name_staging) +final_path_staging=$(ynh_app_setting_get --app=$app --key=final_path_staging) + #================================================= # STANDARD REMOVE #================================================= @@ -30,6 +41,12 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db --db_user=$db_name_dev --db_name=$db_name_dev + +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db --db_user=$db_name_staging --db_name=$db_name_staging + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -38,6 +55,12 @@ ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" +# Remove the app directory securely +ynh_secure_remove --file="$final_path_dev" + +# Remove the app directory securely +ynh_secure_remove --file="$final_path_staging" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -46,6 +69,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config +app=$app_dev +# Remove the dedicated NGINX config +ynh_remove_nginx_config + +app=$app_staging +# Remove the dedicated NGINX config +ynh_remove_nginx_config + +app=$app_initial + #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= @@ -54,6 +87,16 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +app=$app_dev +# Remove the dedicated PHP-FPM config +ynh_remove_fpm_config + +app=$app_staging +# Remove the dedicated PHP-FPM config +ynh_remove_fpm_config + +app=$app_initial + #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= @@ -62,11 +105,23 @@ ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config +app=$app_dev +# Remove the dedicated Fail2Ban config +ynh_remove_fail2ban_config + +app=$app_staging +# Remove the dedicated Fail2Ban config +ynh_remove_fail2ban_config + +app=$app_initial + #================================================= # REMOVE THE CRON #================================================= ynh_secure_remove /etc/cron.d/$app +ynh_secure_remove /etc/cron.d/$app_dev +ynh_secure_remove /etc/cron.d/$app_staging #================================================= # GENERIC FINALISATION @@ -78,6 +133,12 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh # Delete dedicated system user ynh_system_user_delete --username=$app +# Delete dedicated system user +ynh_system_user_delete --username=$app_dev + +# Delete dedicated system user +ynh_system_user_delete --username=$app_staging + #================================================= # END OF SCRIPT #=================================================