diff --git a/check_process b/check_process index a41f35b..c2fc7c2 100644 --- a/check_process +++ b/check_process @@ -46,6 +46,19 @@ setup_sub_dir=1 upgrade=1 backup_restore=1 +;; Test without PHP + ; Manifest + domain="domain.tld" + path="/path" + with_sftp=0 + password="myreallystrengthpassword" + is_public=1 + phpversion="none" + with_mysql=0 + ; Checks + setup_sub_dir=1 + upgrade=1 + backup_restore=1 ;; Test with PHP7.4 ; Manifest domain="domain.tld" diff --git a/conf/nginx_no_php.conf b/conf/nginx_no_php.conf new file mode 100644 index 0000000..5367ecf --- /dev/null +++ b/conf/nginx_no_php.conf @@ -0,0 +1,34 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __FINALPATH__/www/; + + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + # Default indexes and catch-all + index index.html index.php; + try_files $uri $uri/ __PATH__/index.php?$args; + + # Prevent useless logs + location = __PATH__/favicon.ico { + log_not_found off; + access_log off; + } + location = __PATH__/robots.txt { + allow all; + log_not_found off; + access_log off; + } + + # Deny access to hidden files and directories + location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { + deny all; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/conf/nginx.conf b/conf/nginx_with_php.conf similarity index 100% rename from conf/nginx.conf rename to conf/nginx_with_php.conf diff --git a/manifest.json b/manifest.json index fa26fe2..705847a 100644 --- a/manifest.json +++ b/manifest.json @@ -64,7 +64,7 @@ "en": "Choose a PHP version you want to use for your app", "fr": "Choisissez une version PHP que vous souhaitez utiliser pour votre application" }, - "choices" : ["7.3", "7.4", "8.0"], + "choices" : ["none", "7.3", "7.4", "8.0"], "default" : "7.3" }, { diff --git a/scripts/change_url b/scripts/change_url index 6a9ca89..39f7c11 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -80,6 +81,14 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Change the path in the NGINX config file if [ $change_path -eq 1 ] then diff --git a/scripts/install b/scripts/install index 4007581..1cddee6 100644 --- a/scripts/install +++ b/scripts/install @@ -62,9 +62,13 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 -ynh_install_app_dependencies "php${phpversion}-fpm" +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Installing dependencies..." --weight=2 + + ynh_install_app_dependencies "php${phpversion}-fpm" +fi #================================================= # CREATE A MYSQL DATABASE @@ -84,6 +88,14 @@ fi #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -146,10 +158,14 @@ chmod o-rwx "$final_path" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 -# Create a dedicatedPHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --phpversion=$phpversion +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 + + # Create a dedicatedPHP-FPM config + ynh_add_fpm_config --usage=low --footprint=low --phpversion=$phpversion +fi #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 82bd939..5f98d6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,9 +124,13 @@ ynh_maintenance_mode_ON #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 -ynh_install_app_dependencies "php${phpversion}-fpm" +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Installing dependencies..." --weight=2 + + ynh_install_app_dependencies "php${phpversion}-fpm" +fi #================================================= # NGINX CONFIGURATION @@ -134,6 +138,14 @@ ynh_install_app_dependencies "php${phpversion}-fpm" ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -165,10 +177,13 @@ usermod -g "$app" "$app" # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion + # Create a dedicated PHP-FPM config + ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion +fi #================================================= # SPECIFIC UPGRADE