diff --git a/data/helpers.d/backend b/data/helpers.d/backend index c54e82754..c0cbc616c 100644 --- a/data/helpers.d/backend +++ b/data/helpers.d/backend @@ -123,6 +123,9 @@ ynh_add_nginx_config () { # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. # Substitute in a nginx config file only if the variable is not empty if test -n "${path_url:-}"; then + # path_url_slash_less if path_url or a blank value if path_url is only '/' + path_url_slash_less=${path_url%/} + ynh_replace_string "__PATH__/" "$path_url_slash_less/" "$finalnginxconf" ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" fi if test -n "${domain:-}"; then diff --git a/data/helpers.d/mysql b/data/helpers.d/mysql index 0774adbce..42c204f95 100644 --- a/data/helpers.d/mysql +++ b/data/helpers.d/mysql @@ -73,7 +73,7 @@ ynh_mysql_drop_db() { # | arg: db - the database name to dump # | ret: the mysqldump output ynh_mysql_dump_db() { - mysqldump -u "root" -p"$(sudo cat $MYSQL_ROOT_PWD_FILE)" --single-transaction "$1" + mysqldump -u "root" -p"$(sudo cat $MYSQL_ROOT_PWD_FILE)" --single-transaction --skip-dump-date "$1" } # Create a user diff --git a/data/helpers.d/string b/data/helpers.d/string index 772681fb9..b77b42ef7 100644 --- a/data/helpers.d/string +++ b/data/helpers.d/string @@ -10,12 +10,16 @@ ynh_string_random() { | sed -n 's/\(.\{'"${1:-24}"'\}\).*/\1/p' } -# Substitute/replace a string by another in a file +# Substitute/replace a string (or expression) by another in a file # # usage: ynh_replace_string match_string replace_string target_file # | arg: match_string - String to be searched and replaced in the file # | arg: replace_string - String that will replace matches # | arg: target_file - File in which the string will be replaced. +# +# As this helper is based on sed command, regular expressions and +# references to sub-expressions can be used +# (see sed manual page for more information) ynh_replace_string () { delimit=@ match_string=${1//${delimit}/"\\${delimit}"} # Escape the delimiter if it's in the string. diff --git a/locales/en.json b/locales/en.json index 80ff22655..9ef41a3f2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -55,6 +55,7 @@ "ask_main_domain": "Main domain", "ask_new_admin_password": "New administration password", "ask_password": "Password", + "ask_path": "Path", "backup_abstract_method": "This backup method hasn't yet been implemented", "backup_action_required": "You must specify something to save", "backup_app_failed": "Unable to back up the app '{app:s}'", diff --git a/locales/fr.json b/locales/fr.json index 86df7b10d..f4afdceb3 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -14,7 +14,7 @@ "app_install_files_invalid": "Fichiers d'installation incorrects", "app_location_already_used": "Une application est déjà installée à cet emplacement", "app_location_install_failed": "Impossible d'installer l'application à cet emplacement", - "app_manifest_invalid": "Manifeste d'application incorrect", + "app_manifest_invalid": "Manifeste d'application incorrect : {error}", "app_no_upgrade": "Aucune application à mettre à jour", "app_not_correctly_installed": "{app:s} semble être mal installé", "app_not_installed": "{app:s} n'est pas installé", @@ -320,7 +320,7 @@ "backup_archive_system_part_not_available": "La partie « {part:s} » du système n’est pas disponible dans cette sauvegarde", "backup_archive_mount_failed": "Le montage de l’archive de sauvegarde a échoué", "backup_archive_writing_error": "Impossible d’ajouter les fichiers à la sauvegarde dans l’archive compressée", - "backup_ask_for_copying_if_needed": "Votre système ne prend pas complètement en charge la méthode rapide d’organisation des fichiers dans l’archive, voulez-vous les organiser en copiant {size:s} Mio ?", + "backup_ask_for_copying_if_needed": "Certains fichiers n’ont pas pu être préparés pour être sauvegardée en utilisant la méthode qui évite de temporairement gaspiller de l’espace sur le système. Pour mener la sauvegarde, {size:s} Mio doivent être temporairement utilisés. Acceptez-vous ?", "backup_borg_not_implemented": "La méthode de sauvegarde Bord n’est pas encore implémentée", "backup_cant_mount_uncompress_archive": "Impossible de monter en lecture seule le dossier de l’archive décompressée", "backup_copying_to_organize_the_archive": "Copie de {size:s} Mio pour organiser l’archive", @@ -344,5 +344,24 @@ "restore_mounting_archive": "Montage de l’archive dans « {path:s} »", "restore_may_be_not_enough_disk_space": "Votre système semble ne pas avoir suffisamment d’espace disponible (libre : {free_space:d} octets, nécessaire : {needed_space:d} octets, marge de sécurité : {margin:d} octets)", "restore_not_enough_disk_space": "Espace disponible insuffisant (libre : {free_space:d} octets, nécessaire : {needed_space:d} octets, marge de sécurité : {margin:d} octets)", - "restore_system_part_failed": "Impossible de restaurer la partie « {part:s} » du système" + "restore_system_part_failed": "Impossible de restaurer la partie « {part:s} » du système", + "backup_couldnt_bind": "Impossible de lier {src:s} avec {dest:s}.", + "domain_dns_conf_is_just_a_recommendation": "Cette page montre la configuration *recommandée*. Elle ne configure *pas* le DNS pour vous. Il est de votre responsabilité que de configurer votre zone DNS chez votre registrar DNS avec cette recommandation.", + "domain_dyndns_dynette_is_unreachable": "Impossible de contacter la dynette YunoHost, soit YunoHost n’est pas correctement connecté à internet ou alors le serveur de dynette est arrêté. Erreur : {error}", + "migrations_backward": "Migration en arrière.", + "migrations_bad_value_for_target": "Nombre invalide pour le paramètre « target », les numéros de migration sont ou {}", + "migrations_cant_reach_migration_file": "Impossible d’accéder aux fichiers de migrations avec le chemin %s", + "migrations_current_target": "La cible de migration est {}", + "migrations_error_failed_to_load_migration": "ERREUR : échec du chargement de migration {number} {name}", + "migrations_forward": "Migration en avant", + "migrations_loading_migration": "Chargement de la migration {number} {name}…", + "migrations_migration_has_failed": "La migration {number} {name} a échoué avec l’exception {exception}, annulation", + "migrations_no_migrations_to_run": "Aucune migration à lancer", + "migrations_show_currently_running_migration": "Application de la migration {number} {name}…", + "migrations_show_last_migration": "La dernière migration appliquée est {}", + "migrations_skip_migration": "Omission de la migration {number} {name}…", + "server_shutdown": "Le serveur sera éteint", + "server_shutdown_confirm": "Le serveur immédiatement être éteint, le voulez-vous vraiment ? [{answers:s}]", + "server_reboot": "Le serveur va redémarrer", + "server_reboot_confirm": "Le serveur va redémarrer immédiatement, le voulez-vous vraiment ? [{answers:s}]" } diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 84092580f..fe71cfd85 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -445,8 +445,9 @@ def app_change_url(auth, app, domain, path): # Normalize path and domain format domain = domain.strip().lower() - old_path = '/' + old_path.strip("/").strip() + '/' - path = '/' + path.strip("/").strip() + '/' + + old_path = normalize_url_path(old_path) + path = normalize_url_path(path) if (domain, path) == (old_domain, old_path): raise MoulinetteError(errno.EINVAL, m18n.n("app_change_url_identical_domains", domain=domain, path=path)) @@ -2105,3 +2106,10 @@ def random_password(length=8): char_set = string.ascii_uppercase + string.digits + string.ascii_lowercase return ''.join([random.SystemRandom().choice(char_set) for x in range(length)]) + + +def normalize_url_path(url_path): + if url_path.strip("/").strip(): + return '/' + url_path.strip("/").strip() + '/' + + return "/" diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index d794a2fca..def7fb27b 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -166,11 +166,11 @@ class BackupRestoreTargetsManager(object): or (exclude and isinstance(exclude, list) and not include) if include: - return [target for target in self.targets[category] + return [target.encode("Utf-8") for target in self.targets[category] if self.results[category][target] in include] if exclude: - return [target for target in self.targets[category] + return [target.encode("Utf-8") for target in self.targets[category] if self.results[category][target] not in exclude] diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index e172fa8e5..22ac7894f 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -78,14 +78,14 @@ def tools_ldapinit(): for rdn, attr_dict in ldap_map['parents'].items(): try: auth.add(rdn, attr_dict) - except: - pass + except Exception as e: + logger.warn("Error when trying to inject '%s' -> '%s' into ldap: %s" % (rdn, attr_dict, e)) for rdn, attr_dict in ldap_map['children'].items(): try: auth.add(rdn, attr_dict) - except: - pass + except Exception as e: + logger.warn("Error when trying to inject '%s' -> '%s' into ldap: %s" % (rdn, attr_dict, e)) admin_dict = { 'cn': 'admin',