From b76f9c07970a8a548cfc53d41d63c079dc7cd9eb Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Mon, 15 Mar 2021 00:27:20 +0100 Subject: [PATCH 1/6] [autopatch] Autopatch to migrate to new permission system --- scripts/install | 8 ++++---- scripts/upgrade | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 93c7f09..db3d745 100755 --- a/scripts/install +++ b/scripts/install @@ -264,14 +264,14 @@ then # Replace radicale by InfCloud into YunoHost portal ynh_app_setting_set $app path ${path_url%/}/infcloud # Protect InfCloud access - ynh_app_setting_set $app protected_uris "/" - domain_regex=$(echo "$domain" | sed 's@-@.@g') + + # Radicale is always accessible (For access to ressources) - ynh_app_setting_set $app skipped_regex "$domain_regex$path_url" + else # If only radicale is installed # Radicale is always accessible (For access to ressources) - ynh_app_setting_set $app unprotected_uris "/" + fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index acb5691..6993aab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,6 +116,16 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# Migrate legacy permissions to new system +#================================================= +if ynh_legacy_permissions_exists +then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # CHECK THE PATH #================================================= From 70ff1ba0fc49e643b77a1172a7bab885cadab50a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 26 Jul 2021 07:43:39 +0200 Subject: [PATCH 2/6] Fix --- check_process | 12 ++++---- manifest.json | 14 +-------- scripts/_common.sh | 77 ---------------------------------------------- scripts/install | 2 +- scripts/upgrade | 2 +- 5 files changed, 9 insertions(+), 98 deletions(-) diff --git a/check_process b/check_process index 33ceb3d..a3c2682 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet avec Infcloud ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" infcloud=1 language="French" ; Checks @@ -21,9 +21,9 @@ change_url=0 ;; Test sans Infcloud ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" infcloud=0 language="French" ; Checks diff --git a/manifest.json b/manifest.json index f7ae9bb..ad18fdb 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.2.0" }, "multi_instance": false, "services": [ @@ -30,29 +30,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Radicale", - "fr": "Choisissez un domaine pour Radicale" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Radicale", - "fr": "Choisissez un chemin pour Radicale" - }, "example": "/radicale", "default": "/radicale" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose the administrator (must be an existing YunoHost user)", - "fr": "Choisissez un administrateur (doit ĂȘtre un utilisateur YunoHost)" - }, "example": "john" }, { diff --git a/scripts/_common.sh b/scripts/_common.sh index 5865b83..09ff99e 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,83 +38,6 @@ bool_to_true_false () { # FUTUR OFFICIAL HELPERS #================================================= -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.2" - local checksum="806a827ba1902d6911095602a9221181" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1 - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Check if the package acl is installed. Or install it. - ynh_package_is_installed 'acl' \ - || ynh_package_install acl - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Add a directory in yunohost.multimedia -# This "directory" will be a symbolic link to a existing directory. -# -# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" -ynh_multimedia_addfolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" -} - -# Move a directory in yunohost.multimedia, and replace by a symbolic link -# -# usage: ynh_multimedia_movefolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# It will be moved to "Destination directory" -# A symbolic link will replace it. -# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia" -ynh_multimedia_movefolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir" -} - -# Allow an user to have an write authorisation in multimedia directories -# -# usage: ynh_multimedia_addaccess user_name -# -# | arg: -u, --user_name= - The name of the user which gain this access. -ynh_multimedia_addaccess () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=user_name=) - local user_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - groupadd -f multimedia - usermod -a -G multimedia $user_name -} - #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index db3d745..ccba050 100755 --- a/scripts/install +++ b/scripts/install @@ -81,7 +81,7 @@ then # Add InfCloud in NGINX config ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf fi -ynh_store_file_checksum "$finalnginxconf" +ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # CREATE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index 6993aab..3192503 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -165,7 +165,7 @@ then # Add InfCloud in NGINX config ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf fi - ynh_store_file_checksum "$finalnginxconf" + ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" fi #================================================= From 7711f0a026115f1b002e536c2d6d65af66e73008 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 26 Jul 2021 07:53:15 +0200 Subject: [PATCH 3/6] Update install --- scripts/install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index ccba050..d980224 100755 --- a/scripts/install +++ b/scripts/install @@ -264,14 +264,14 @@ then # Replace radicale by InfCloud into YunoHost portal ynh_app_setting_set $app path ${path_url%/}/infcloud # Protect InfCloud access - - + ynh_app_setting_set $app protected_uris "/" + domain_regex=$(echo "$domain" | sed 's@-@.@g') # Radicale is always accessible (For access to ressources) - + ynh_app_setting_set $app skipped_regex "$domain_regex$path_url" else # If only radicale is installed # Radicale is always accessible (For access to ressources) - + ynh_app_setting_set $app unprotected_uris "/" fi #================================================= From 33c2c7db323a6771b6df2f0fc60112d633d6bfff Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 17 Aug 2021 07:56:49 +0200 Subject: [PATCH 4/6] Update upgrade --- scripts/upgrade | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3192503..769b081 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -43,6 +43,20 @@ defaulteventduration=$(ynh_app_setting_get --app=$app --key=defaulteventduration upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backup the app before upgrading" + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -102,20 +116,6 @@ if [ -z "$overwrite_phpfpm" ]; then ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backup the app before upgrading" --weight=9 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # Migrate legacy permissions to new system #================================================= @@ -138,7 +138,7 @@ fi #================================================= # ACTIVATE MAINTENANCE MODE #================================================= -ynh_script_progression --message="Activate maintenance mode" +ynh_script_progression --message="Activate maintenance mode" --weight=1 ynh_maintenance_mode_ON @@ -147,7 +147,7 @@ ynh_maintenance_mode_ON #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrade dependencies" +ynh_script_progression --message="Upgrade dependencies" --weight=5 ynh_install_app_dependencies $pkg_dependencies @@ -171,7 +171,7 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Create a dedicated user" +ynh_script_progression --message="Create a dedicated user" --weight=2 # Create a dedicated user (if not existing) ynh_system_user_create $app From 071e8ddf8cc07c5c05e7e478c6dfa9ff80b5c4e0 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 17 Nov 2021 15:09:40 +0100 Subject: [PATCH 5/6] Fix linter warnings --- manifest.json | 6 ++---- scripts/_common.sh | 24 ------------------------ scripts/restore | 2 -- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/manifest.json b/manifest.json index ad18fdb..51bcd94 100644 --- a/manifest.json +++ b/manifest.json @@ -29,8 +29,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -40,8 +39,7 @@ }, { "name": "admin", - "type": "user", - "example": "john" + "type": "user" }, { "name": "infcloud", diff --git a/scripts/_common.sh b/scripts/_common.sh index 09ff99e..0b9a9c9 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -184,30 +184,6 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service #================================================= -ynh_debian_release () { - lsb_release --codename --short -} - -is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi -} - -is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi -} - -#================================================= - ynh_maintenance_mode_ON () { # Load value of $path_url and $domain from the config if their not set if [ -z $path_url ]; then diff --git a/scripts/restore b/scripts/restore index f5f9092..6d981e5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,8 +34,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " test ! -d "/opt/yunohost/$app" \ From 35564152d1fe185e465f5e5ae814e51f9dc9a131 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Nov 2021 14:02:35 +0100 Subject: [PATCH 6/6] 4.3 --- conf/nginx.conf | 3 --- manifest.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 51eff66..7d44650 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,4 @@ location __PATH__ { - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } try_files $uri @radicale; } diff --git a/manifest.json b/manifest.json index 51bcd94..576430a 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [