From fa62ff5961b4ce44075d34f771f4173bf49221a9 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <arthur@lydra.fr>
Date: Mon, 24 Jan 2022 12:35:38 +0100
Subject: [PATCH] refactor: change default value of ynh_autoupdate.dest_script

---
 README-FR.md         | 4 ++--
 README.md            | 4 ++--
 defaults/main.yml    | 2 +-
 tasks/autoupdate.yml | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/README-FR.md b/README-FR.md
index 94a3109..db2aebe 100644
--- a/README-FR.md
+++ b/README-FR.md
@@ -140,7 +140,7 @@ ynh_autoupdate:
   special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
   apps: True
   system: True
-  dest_script: "/usr/local/bin/ynh_autoupdate.sh"
+  dest_script: "/usr/bin/"
 ```
 
 Une tâche cron peut être mise en place pour automatiser la vérification des mises à jour système et applications suivant la périodicité de votre choix. 
@@ -149,7 +149,7 @@ Une tâche cron peut être mise en place pour automatiser la vérification des m
   Pour en savoir plus sur les _special times_, cliquez [ici](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html).
   - `ynh_autoupdate.apps` : est obligatoire. Activez la mise à jour automatique des applications Yunohost en mettant la valeur à `True`.
   - `ynh_autoupdate.system` : est obligatoire. Activez la mise à jour automatique du système Yunohost en mettant la valeur à `True`.
-  - `ynh_autoupdate.dest_script` : c'est le chemin du répertoire où le script de mise à jour sera installé sur le serveur. La valeur par défaut est `/usr/local/bin`, le script s'appelle `ynh_autoupdate.sh`.
+  - `ynh_autoupdate.dest_script` : c'est le chemin du répertoire où le script de mise à jour sera installé sur le serveur. La valeur par défaut est `/usr/local/bin`. Le script s'appelle `ynh_autoupdate.sh`.
 
 Si des mises à jour sont disponibles, elles sont faites automatiquement. En cas de problème suite à la mise à jour d'une application, vous pouvez lire les logs qui sont disponibles ici `/var/log/yunohost/categories/operation`. Vous avez aussi la possibilité de revenir à la version précédente car Yunohost fait toujours une sauvegarde automatique d'une application lorsqu'elle est mise à jour. 
 
diff --git a/README.md b/README.md
index ea9f730..3576bf4 100644
--- a/README.md
+++ b/README.md
@@ -140,7 +140,7 @@ ynh_autoupdate:
   special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
   apps: True
   system: True
-  dest_script: "/usr/local/bin/ynh_autoupdate.sh"
+  dest_script: "/usr/bin/"
 ```
 
 A cron job can been set up to automate the check for system and application updates on a schedule of your choice.
@@ -148,7 +148,7 @@ A cron job can been set up to automate the check for system and application upda
   - `ynh_autoupdate.special_time`: it is mandatory. It allows you to specify when you want this task to be executed. Possible values: (`annually`,`daily`,`hourly`,`monthly`,`reboot`,`weekly`,`yearly`). To learn more about special times, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/cron_module.html).
   - `ynh_autoupdate.apps`: is mandatory. Enable automatic updating of Yunohost applications by setting the value to `True`.
   - `ynh_autoupdate.system`: is mandatory. Enable automatic updating of the Yunohost system by setting the value to `True`.
-  - `ynh_autoupdate.dest_script`: it is the path to the directory where the update script will be installed on the server. The default value is `/usr/local/bin`, the script is named `ynh_autoupdate.sh`.
+  - `ynh_autoupdate.dest_script`: it is the path to the directory where the update script will be installed on the server. The default value is `/usr/local/bin`. The script is named `ynh_autoupdate.sh`.
 
 If available, updates are done automatically. In case of problems following an application update, you can read logs located in `/var/log/yunohost/categories/operation` . You also have the possibility to rollback to the previous version since Yunohost always makes an automatic backup of an application when it is updated. 
 
diff --git a/defaults/main.yml b/defaults/main.yml
index 18adf50..d44e47f 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -69,4 +69,4 @@ ynh_autoupdate:
   # special_time: "daily" #Choices are [annually,daily,hourly,monthly,reboot,weekly,yearly]
   # apps: True
   # system: True
-  # dest_script: "/usr/local/bin/ynh_autoupdate.sh"
+  # dest_script: "/usr/local/bin/"
diff --git a/tasks/autoupdate.yml b/tasks/autoupdate.yml
index a089edf..ff923af 100644
--- a/tasks/autoupdate.yml
+++ b/tasks/autoupdate.yml
@@ -21,7 +21,7 @@
 - name: Creates Yunohost autoupdate script
   ansible.builtin.template:
     src: "templates/ynh_autoupdate.sh.j2"
-    dest: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/ynh_autoupdate.sh') }}"
+    dest: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh"
     owner: root
     group: root
     mode: '0740'
@@ -32,5 +32,5 @@
           Logs can be found in /var/log/yunohost/categories/operation"
     special_time: "{{ ynh_autoupdate.special_time }}"
     user: root
-    job: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/ynh_autoupdate.sh') }}"
+    job: "{{ ynh_autoupdate.dest_script | default('/usr/local/bin/') }}ynh_autoupdate.sh"
     cron_file: ynh_autoupdate_cron
-- 
GitLab