diff --git a/check_process b/check_process index 4bb1a5e..9743ecc 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet ; Manifest domain="domain.tld" - etherpad_instance="https://annuel2.framapad.org" is_public=1 + etherpad_instance="https://annuel2.framapad.org" creation_open=1 ; Checks pkg_linter=1 @@ -12,9 +12,13 @@ setup_private=1 setup_public=1 upgrade=1 + # 0.0.20180605~ynh2 upgrade=1 from_commit=f6fcb8686cec30da2a7b9e5ba12d6c5b295528d8 + # 0.0.20180605~ynh3 + upgrade=1 from_commit=ce19369d877b54a9b562444ade220d8d55639edb backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email=ljf+libreto_ynh@reflexlibre.net diff --git a/conf/nginx.conf b/conf/nginx.conf index f9e1caa..a7aeb22 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,14 +1,8 @@ - #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { # Path to source - alias __FINALPATH__/ ; - - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } + alias __FINALPATH__/; index index.php; # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index b75d7f6..24c2568 100644 --- a/manifest.json +++ b/manifest.json @@ -29,7 +29,7 @@ "php7.3-fpm" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" @@ -40,6 +40,15 @@ "example": "/libreto", "default": "/libreto" }, + { + "name": "is_public", + "type": "boolean", + "help": { + "en": "If enabled, Libreto will be accessible by people who do not have an account. This can be changed later via the webadmin.", + "fr": "Si cette case est cochée, Libreto sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + }, + "default": true + }, { "name": "etherpad_instance", "type": "string", @@ -55,15 +64,6 @@ "example": "https://annuel2.framapad.org", "default": "https://annuel2.framapad.org" }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, Libreto will be accessible by people who do not have an account. This can be changed later via the webadmin.", - "fr": "Si cette case est cochée, Libreto sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, - "default": true - }, { "name": "creation_open", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh index 26b65ae..14466d3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,4 +18,4 @@ COMMIT="76408f5e98a68156afa47996e670d110a1c6106d" #================================================= # FUTURE OFFICIAL HELPERS -#================================================= \ No newline at end of file +#================================================= diff --git a/scripts/backup b/scripts/backup index 886fc15..9b12047 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index 3bbea99..10f4ed7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,7 +30,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=3 @@ -75,7 +75,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" @@ -87,12 +87,14 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 2aa595c..99b7e75 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -26,8 +25,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -etherpad_instance=$YNH_APP_ARG_ETHERPAD_INSTANCE is_public=$YNH_APP_ARG_IS_PUBLIC +etherpad_instance=$YNH_APP_ARG_ETHERPAD_INSTANCE creation_open=$YNH_APP_ARG_CREATION_OPEN app=$YNH_APP_INSTANCE_NAME @@ -38,7 +37,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -46,12 +45,15 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=etherpad_instance --value=$etherpad_instance ynh_app_setting_set --app=$app --key=creation_open --value=$creation_open +#================================================= +# STANDARD MODIFICATIONS #================================================= # CREATE DEDICATED USER #================================================= @@ -60,8 +62,6 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -80,14 +80,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -97,11 +89,21 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Create a dedicated NGINX config +ynh_add_nginx_config ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# MODIFY A CONFIG FILE +# SPECIFIC SETUP #================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." cp "../conf/config.dist.php" "$final_path/config.php" @@ -114,13 +116,11 @@ else ynh_replace_string --match_string="__PROVIDER__" --replace_string="framapad" --target_file="$final_path/config.php" fi -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.php" +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= @@ -129,7 +129,9 @@ ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --add="visitors" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/restore b/scripts/restore index 60a1500..00c91e2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -37,17 +37,11 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die "There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -74,6 +68,13 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c69f910..336e383 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -24,22 +25,26 @@ creation_open=$(ynh_app_setting_get --app=$app --key=creation_open) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -83,6 +88,13 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +# Create a dedicated PHP-FPM config +ynh_add_fpm_config + #================================================= # NGINX CONFIGURATION #================================================= @@ -91,21 +103,19 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 -# Create a dedicated PHP-FPM config -ynh_add_fpm_config - #================================================= # SPECIFIC UPGRADE #================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." -ynh_backup_if_checksum_is_different "$final_path/config.php" +ynh_backup_if_checksum_is_different --file="$final_path/config.php" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$final_path/config.php" +ynh_store_file_checksum --file="$final_path/config.php" +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #=================================================