diff --git a/README.md b/README.md index ada2d3a..2d27dd8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Service for planning an appointment or making a decision quickly and easily +Opensondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. **Shipped version:** 1.1.17~ynh1 diff --git a/README_fr.md b/README_fr.md index cf2bd4f..4ce8086 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement +Opensondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. **Version incluse :** 1.1.17~ynh1 diff --git a/check_process b/check_process index 0d613e1..cca0046 100644 --- a/check_process +++ b/check_process @@ -10,7 +10,7 @@ setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 upgrade=1 from_commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b diff --git a/conf/app.src b/conf/app.src index 5a26197..b307330 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=a9b086a7274886d0d13c1c3ed8d6caa848d798315bd6006c6883a37387c390b0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=opensondage-1-1-17.tar.gz +SOURCE_FILENAME=opensondage.tar.gz diff --git a/conf/nginx.conf b/conf/nginx.conf index 56d6c10..b102748 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - rewrite "^__PATH__/([a-zA-Z0-9-]+)$" "__PATH__/studs.php?poll=$1"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/action/([a-zA-Z_-]+)/(.+)$" "__PATH__/studs.php?poll=$1&$2=$3"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/vote/([a-zA-Z0-9]{16})$" "__PATH__/studs.php?poll=$1&vote=$2"; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..797f1f1 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..862aceb --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. \ No newline at end of file diff --git a/manifest.json b/manifest.json index c346179..90fdf69 100644 --- a/manifest.json +++ b/manifest.json @@ -26,7 +26,7 @@ "email": "ljf+opensondage_ynh@grimaud.me" }], "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 406bdfb..6b3d3fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,8 +6,8 @@ # dependencies used by the app YNH_PHP_VERSION="7.3" -YNH_COMPOSER_VERSION=2.1.1 -extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" +YNH_COMPOSER_VERSION="2.1.1" +pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 071a593..f14ca07 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ language=$YNH_APP_ARG_LANGUAGE is_public=$YNH_APP_ARG_IS_PUBLIC email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" +phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -50,6 +51,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=email --value=$email +ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -96,8 +105,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config #================================================= # SPECIFIC SETUP @@ -108,6 +116,9 @@ ynh_script_progression --message="Configuring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" +chmod 400 "$final_path/app/inc/config.php" +chown $app:$app "$final_path/app/inc/config.php" + #================================================= # SETUP HOOKS FILE #================================================= @@ -148,31 +159,17 @@ chown -R $app: "$final_path/"{tpl_c,admin/stdout.log} #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring Permissions..." - -ynh_permission_update --permission="main" --add="visitors" - -ynh_permission_create --permission="admin" --allowed="$admin" --url="/admin" - -# This is a fake permission without any URL. -# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. -# We can't use a real permission for now because the actual permision system doesn't support regex. -ynh_permission_create --permission="create poll" --allowed="visitors" +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" -else - ynh_permission_update --permission="create poll" --remove="visitors" + ynh_permission_update --permission="main" --add="visitors" fi +# Only the admin can access the admin panel of the app (if the app has an admin panel) +ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 705c54d..c68f608 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,6 +28,14 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=5 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 44d124e..262ba90 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,8 +35,7 @@ timezone="$(cat /etc/timezone)" #================================================ ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -80,7 +79,13 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --package="$extra_php_dependencies" +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 568fe74..dbfa210 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -54,58 +53,6 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -if [ -z "$is_public" ]; then - is_public=$(ynh_app_setting_get --app=$app --key=public_site) - ynh_app_setting_set --app=$app --key=is_public --value=$is_public - ynh_app_setting_delete --app=$app --key=public_site -fi - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) - -# Unused with the permission system -if [ ! -z "$skipped_uris" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris -fi - -protected_regex=$(ynh_app_setting_get --app=$app --key=protected_regex) - -# Unused with the permission system -if [ ! -z "$protected_regex" ]; then - ynh_app_setting_delete --app=$app --key=protected_regex -fi - -# Create the permission "upload images" only if it doesn't exist. -if ! ynh_permission_exists --permission="create poll" -then - # This is a fake permission without any URL. - # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. - # We can't use a real permission for now because the actual permision system doesn't support regex. - ynh_permission_create --permission="create poll" --allowed="visitors" - - # Make app public if necessary - if [ $is_public -eq 1 ] - then - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" - else - ynh_permission_update --permission="create poll" --remove="visitors" - fi -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -135,6 +82,18 @@ if [ -z "$path_url" ]; then ynh_app_setting_delete --app=$app --key=path_url fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -169,13 +128,20 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE @@ -188,8 +154,8 @@ then ynh_script_progression --message="Reconfiguring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" - chmod 400 "$final_path/app/inc/config.php" - chown $app:$app "$final_path/app/inc/config.php" + chmod 400 "$final_path/app/inc/config.php" + chown $app:$app "$final_path/app/inc/config.php" fi #=================================================