Browse Source

Merge pull request #130 from yunohost-bot/auto-helpers-2.1

[autopatch] Automatic patch attempt for helpers 2.1
eric_G 1 week ago
parent
commit
045db75dc2
10 changed files with 95 additions and 104 deletions
  1. 3 0
      .gitignore
  2. 4 1
      manifest.toml
  3. 9 10
      scripts/_common.sh
  4. 13 13
      scripts/backup
  5. 14 26
      scripts/config
  6. 9 9
      scripts/install
  7. 10 10
      scripts/remove
  8. 4 7
      scripts/restore
  9. 27 26
      scripts/upgrade
  10. 2 2
      tests.toml

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+*~
+*.sw[op]
+.DS_Store

+ 4 - 1
manifest.toml

@@ -16,11 +16,14 @@ license = "AGPL-3.0"
 website = "https://labriqueinter.net"
 website = "https://labriqueinter.net"
 
 
 [integration]
 [integration]
-yunohost = ">= 11.2"
+yunohost = ">= 12.0.9"
+helpers_version = "2.1"
 architectures = "all"
 architectures = "all"
 multi_instance = false
 multi_instance = false
+
 ldap = "not_relevant"
 ldap = "not_relevant"
 sso = "not_relevant"
 sso = "not_relevant"
+
 disk = "50M"
 disk = "50M"
 ram.build = "50M"
 ram.build = "50M"
 ram.runtime = "50M"
 ram.runtime = "50M"

+ 9 - 10
scripts/_common.sh

@@ -1,8 +1,7 @@
 #!/bin/bash
 #!/bin/bash
 
 
 service_name="ynh-vpnclient"
 service_name="ynh-vpnclient"
-service_checker_name=$service_name"-checker"
-
+service_checker_name="$service_name-checker"
 
 
 # Operations needed by both 'install' and 'upgrade' scripts
 # Operations needed by both 'install' and 'upgrade' scripts
 function vpnclient_deploy_files_and_services()
 function vpnclient_deploy_files_and_services()
@@ -45,11 +44,11 @@ function vpnclient_deploy_files_and_services()
   #=================================================
   #=================================================
   # SETUP SYSTEMD
   # SETUP SYSTEMD
   #=================================================
   #=================================================
-  ynh_print_info "Configuring a systemd service..."
+  ynh_print_info "Configuring $app's systemd service..."
 
 
-  ynh_add_systemd_config $service_name "$service_name.service"
+  ynh_config_add_systemd --service="$service_name" --template="$service_name.service"
 
 
-  ynh_add_systemd_config $service_checker_name "$service_checker_name.service"
+  ynh_config_add_systemd --service="$service_checker_name" --template="$service_checker_name.service"
 }
 }
 
 
 function read_cube() {
 function read_cube() {
@@ -79,8 +78,8 @@ function convert_cube_file()
 {
 {
   local config_file="$1"
   local config_file="$1"
   local tmp_dir=$(dirname "$config_file")
   local tmp_dir=$(dirname "$config_file")
-  
-  ynh_print_info --message="Transforming .cube into OVPN file"
+
+  ynh_print_info "Transforming .cube into OVPN file"
   server_name="$(read_cube $config_file server_name)"
   server_name="$(read_cube $config_file server_name)"
   server_port="$(read_cube $config_file server_port)"
   server_port="$(read_cube $config_file server_port)"
   server_proto="$(read_cube $config_file server_proto)"
   server_proto="$(read_cube $config_file server_proto)"
@@ -102,7 +101,7 @@ function convert_cube_file()
     dns_method="custom"
     dns_method="custom"
     nameservers="$dns0,$dns1"
     nameservers="$dns0,$dns1"
   fi
   fi
-  
+
   # Build specific OVPN template
   # Build specific OVPN template
   config_template="$tmp_dir/client.conf.tpl"
   config_template="$tmp_dir/client.conf.tpl"
   cp -f /etc/yunohost/apps/vpnclient/conf/openvpn_client.conf.tpl "$config_template"
   cp -f /etc/yunohost/apps/vpnclient/conf/openvpn_client.conf.tpl "$config_template"
@@ -130,7 +129,7 @@ function convert_cube_file()
   [ -n "$login_user" ] && login_comment="" || login_comment="#"
   [ -n "$login_user" ] && login_comment="" || login_comment="#"
 
 
   # Actually generate/hydrate the final configuration
   # Actually generate/hydrate the final configuration
-  ynh_add_config --template="$config_template" --destination="$config_file"
+  ynh_config_add --template="$config_template" --destination="$config_file"
 
 
   if [ "$server_proto" == tcp-client ]; then
   if [ "$server_proto" == tcp-client ]; then
     server_proto=tcp
     server_proto=tcp
@@ -142,7 +141,7 @@ function convert_ovpn_file()
   local config_file="$1"
   local config_file="$1"
   local tmp_dir=$(dirname "$config_file")
   local tmp_dir=$(dirname "$config_file")
 
 
-  ynh_print_info --message="Extracting TLS keys from .ovpn file"
+  ynh_print_info "Extracting TLS keys from .ovpn file"
   if grep -q '^\s*<ca>' ${config_file}
   if grep -q '^\s*<ca>' ${config_file}
   then
   then
     grep -Poz '(?<=<ca>)(.*\n)*.*(?=</ca>)' ${config_file} | sed '/^$/d'  > $tmp_dir/crt_server_ca
     grep -Poz '(?<=<ca>)(.*\n)*.*(?=</ca>)' ${config_file} | sed '/^$/d'  > $tmp_dir/crt_server_ca

+ 13 - 13
scripts/backup

@@ -8,31 +8,31 @@ source /usr/share/yunohost/helpers
 #=================================================
 #=================================================
 ynh_print_info "Backing up the main app directory..."
 ynh_print_info "Backing up the main app directory..."
 
 
-ynh_backup --src_path="/usr/local/bin/$service_name-loadcubefile.sh"
+ynh_backup "/usr/local/bin/$service_name-loadcubefile.sh"
 
 
-ynh_backup --src_path="/etc/openvpn/client.conf" --not_mandatory
-ynh_backup --src_path="/etc/openvpn/client.cube" --not_mandatory
-ynh_backup --src_path="/etc/openvpn/client.ovpn" --not_mandatory
+ynh_backup "/etc/openvpn/client.conf" || true
+ynh_backup "/etc/openvpn/client.cube" || true
+ynh_backup "/etc/openvpn/client.ovpn" || true
 
 
 for FILE in $(ls /etc/openvpn/scripts/route-up.d/*-vpnclient-* /etc/openvpn/scripts/route-down.d/*-vpnclient-*); do
 for FILE in $(ls /etc/openvpn/scripts/route-up.d/*-vpnclient-* /etc/openvpn/scripts/route-down.d/*-vpnclient-*); do
-    ynh_backup --src_path="$FILE"
+    ynh_backup "$FILE"
 done
 done
 
 
-ynh_backup --src_path="/etc/openvpn/keys/"
-ynh_backup --src_path="/etc/openvpn/scripts/run-parts.sh"
+ynh_backup "/etc/openvpn/keys/"
+ynh_backup "/etc/openvpn/scripts/run-parts.sh"
 
 
-ynh_backup --src_path="/usr/local/bin/$service_name"
-ynh_backup --src_path="/usr/local/bin/$service_checker_name.sh"
+ynh_backup "/usr/local/bin/$service_name"
+ynh_backup "/usr/local/bin/$service_checker_name.sh"
 
 
 #=================================================
 #=================================================
 # BACKUP SYSTEMD
 # BACKUP SYSTEMD
 #=================================================
 #=================================================
 ynh_print_info "Backing up systemd configuration..."
 ynh_print_info "Backing up systemd configuration..."
 
 
-ynh_backup --src_path="/etc/systemd/system/$service_name.service"
-ynh_backup --src_path="/etc/systemd/system/$service_checker_name.service"
-ynh_backup --src_path="/etc/systemd/system/$service_checker_name.timer"
-ynh_backup --src_path="/etc/systemd/system/openvpn@.service.d/override.conf"
+ynh_backup "/etc/systemd/system/$service_name.service"
+ynh_backup "/etc/systemd/system/$service_checker_name.service"
+ynh_backup "/etc/systemd/system/$service_checker_name.timer"
+ynh_backup "/etc/systemd/system/openvpn@.service.d/override.conf"
 
 
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT

+ 14 - 26
scripts/config

@@ -1,22 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
 source _common.sh
 source _common.sh
 source /usr/share/yunohost/helpers
 source /usr/share/yunohost/helpers
 
 
 #=================================================
 #=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
 # RETRIEVE ARGUMENTS
 # RETRIEVE ARGUMENTS
 #=================================================
 #=================================================
 
 
@@ -37,7 +24,7 @@ BACKTICK='`'
 TRIPLEBACKTICKS='```'
 TRIPLEBACKTICKS='```'
 
 
 get__status() {
 get__status() {
-    local service_enabled=$(ynh_app_setting_get $app service_enabled)
+    local service_enabled=$(ynh_app_setting_get --key="service_enabled")
 
 
     ipv4=$(ping -w3 -c1 ip.yunohost.org  >/dev/null 2>&1 && curl --max-time 5 https://ip.yunohost.org --silent)
     ipv4=$(ping -w3 -c1 ip.yunohost.org  >/dev/null 2>&1 && curl --max-time 5 https://ip.yunohost.org --silent)
     ipv6=$(ping -w3 -c1 ip6.yunohost.org >/dev/null 2>&1 && curl --max-time 5 https://ip6.yunohost.org --silent)
     ipv6=$(ping -w3 -c1 ip6.yunohost.org >/dev/null 2>&1 && curl --max-time 5 https://ip6.yunohost.org --silent)
@@ -235,9 +222,9 @@ ynh_app_config_validate() {
 ynh_app_config_apply() {
 ynh_app_config_apply() {
 
 
     # Stop vpn client
     # Stop vpn client
-    ynh_print_info --message="Stopping vpnclient in order to edit files"
-    ynh_systemd_action --service_name="ynh-vpnclient-checker.timer" --action="stop"
-    ynh_systemd_action --service_name="ynh-vpnclient" --action="stop"
+    ynh_print_info "Stopping vpnclient in order to edit files"
+    ynh_systemctl --service="ynh-vpnclient-checker.timer" --action="stop"
+    ynh_systemctl --service="ynh-vpnclient" --action="stop"
 
 
     chown $app:$app /etc/openvpn/keys
     chown $app:$app /etc/openvpn/keys
     chmod go=--- /etc/openvpn/keys
     chmod go=--- /etc/openvpn/keys
@@ -245,20 +232,21 @@ ynh_app_config_apply() {
     _ynh_app_config_apply
     _ynh_app_config_apply
 
 
     # If we are uploading a cube file, then the file would be in a temporary folder
     # If we are uploading a cube file, then the file would be in a temporary folder
-    # Otherwise, we aren't uploading a cube file, then the path is either empty 
+    # Otherwise, we aren't uploading a cube file, then the path is either empty
+
     # or takes the value of the previous upload, that is, the target path for the cube file.
     # or takes the value of the previous upload, that is, the target path for the cube file.
     if [[ -n "${cube_file:-}" && "$cube_file" != "/etc/openvpn/client.cube" ]]; then
     if [[ -n "${cube_file:-}" && "$cube_file" != "/etc/openvpn/client.cube" ]]; then
-      ynh_app_setting_set $app ip6_addr "$ip6_addr"
-      ynh_app_setting_set $app ip6_net "$ip6_net"
-      ynh_app_setting_set $app ip6_send_over_tun_enabled "$ip6_send_over_tun_enabled"
+      ynh_app_setting_set --key="ip6_addr" --value="$ip6_addr"
+      ynh_app_setting_set --key="ip6_net" --value="$ip6_net"
+      ynh_app_setting_set --key="ip6_send_over_tun_enabled" --value"$ip6_send_over_tun_enabled"
     fi
     fi
 
 
     if [[ ${ip6_send_over_tun_enabled} -eq 1 ]]; then
     if [[ ${ip6_send_over_tun_enabled} -eq 1 ]]; then
         install -b -o root -g root -m 0755 ../conf/optional-scripts/route-up.d/50-vpnclient-set-ipv6-send-over-tun /etc/openvpn/scripts/route-up.d/
         install -b -o root -g root -m 0755 ../conf/optional-scripts/route-up.d/50-vpnclient-set-ipv6-send-over-tun /etc/openvpn/scripts/route-up.d/
         install -b -o root -g root -m 0755 ../conf/optional-scripts/route-down.d/50-vpnclient-unset-ipv6-send-over-tun /etc/openvpn/scripts/route-down.d/
         install -b -o root -g root -m 0755 ../conf/optional-scripts/route-down.d/50-vpnclient-unset-ipv6-send-over-tun /etc/openvpn/scripts/route-down.d/
     else
     else
-        ynh_secure_remove /etc/openvpn/scripts/route-up.d/50-vpnclient-set-ipv6-send-over-tun
-        ynh_secure_remove /etc/openvpn/scripts/route-down.d/50-vpnclient-unset-ipv6-send-over-tun
+        ynh_safe_rm /etc/openvpn/scripts/route-up.d/50-vpnclient-set-ipv6-send-over-tun
+        ynh_safe_rm /etc/openvpn/scripts/route-down.d/50-vpnclient-unset-ipv6-send-over-tun
     fi
     fi
 
 
     set_permissions /etc/openvpn/client.conf
     set_permissions /etc/openvpn/client.conf
@@ -272,9 +260,9 @@ ynh_app_config_apply() {
     [[ -n "${ovpn_file:-}" && "$ovpn_file" == "/etc/openvpn/client.ovpn" ]] && rm -f "$ovpn_file"
     [[ -n "${ovpn_file:-}" && "$ovpn_file" == "/etc/openvpn/client.ovpn" ]] && rm -f "$ovpn_file"
 
 
     # Start vpn client
     # Start vpn client
-    ynh_print_info --message="Starting vpnclient service if needed"
-    ynh_systemd_action --service_name="ynh-vpnclient" --action="start"
-    ynh_systemd_action --service_name="ynh-vpnclient-checker.timer" --action="start"
+    ynh_print_info "Starting vpnclient service if needed"
+    ynh_systemctl --service="ynh-vpnclient" --action="start"
+    ynh_systemctl --service="ynh-vpnclient-checker.timer" --action="start"
 }
 }
 
 
 ynh_app_config_run $1
 ynh_app_config_run $1

+ 9 - 9
scripts/install

@@ -4,12 +4,12 @@ source _common.sh
 source /usr/share/yunohost/helpers
 source /usr/share/yunohost/helpers
 
 
 # Default values for config panel
 # Default values for config panel
-ynh_app_setting_set "$app" service_enabled 0
-ynh_app_setting_set "$app" dns_method "yunohost"
-ynh_app_setting_set "$app" nameservers ""
-ynh_app_setting_set "$app" ip6_addr ""
-ynh_app_setting_set "$app" ip6_net ""
-ynh_app_setting_set "$app" ip6_send_over_tun_enabled 0
+ynh_app_setting_set --key="service_enabled" --value="0"
+ynh_app_setting_set --key="dns_method" --value="yunohost"
+ynh_app_setting_set --key="nameservers" --value=""
+ynh_app_setting_set --key="ip6_addr" --value=""
+ynh_app_setting_set --key="ip6_net" --value=""
+ynh_app_setting_set --key="ip6_send_over_tun_enabled" --value="0"
 
 
 #=================================================
 #=================================================
 # DEPLOY FILES FROM PACKAGE
 # DEPLOY FILES FROM PACKAGE
@@ -34,8 +34,8 @@ systemctl stop openvpn
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 yunohost service enable $service_name
 yunohost service enable $service_name
 
 
-ynh_use_logrotate --logfile="/var/log/ynh-vpnclient.log"
-ynh_use_logrotate --logfile="/var/log/openvpn-client.log"
+ynh_config_add_logrotate "/var/log/ynh-vpnclient.log"
+ynh_config_add_logrotate "/var/log/openvpn-client.log"
 
 
 # checker service
 # checker service
 
 
@@ -48,4 +48,4 @@ systemctl enable $service_checker_name.timer --quiet
 # END OF SCRIPT
 # END OF SCRIPT
 #=================================================
 #=================================================
 
 
-ynh_script_progression --message="Installation of $app completed" --last
+ynh_script_progression "Installation of $app completed"

+ 10 - 10
scripts/remove

@@ -13,13 +13,13 @@ systemctl disable $service_checker_name.timer --quiet
 systemctl stop $service_checker_name
 systemctl stop $service_checker_name
 systemctl disable $service_checker_name --quiet
 systemctl disable $service_checker_name --quiet
 
 
-if ynh_exec_warn_less yunohost service status $service_name >/dev/null; then
+if ynh_hide_warnings yunohost service status $service_name >/dev/null; then
     yunohost service remove $service_name
     yunohost service remove $service_name
 fi
 fi
-ynh_remove_logrotate
+ynh_config_remove_logrotate
 
 
 for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*); do
 for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*); do
-    ynh_secure_remove "$FILE"
+    ynh_safe_rm "$FILE"
 done
 done
 
 
 #=================================================
 #=================================================
@@ -28,22 +28,22 @@ done
 ynh_print_info "Removing openvpn configuration"
 ynh_print_info "Removing openvpn configuration"
 
 
 # Remove openvpn configurations
 # Remove openvpn configurations
-ynh_secure_remove /etc/openvpn/client.conf
-ynh_secure_remove /etc/openvpn/client.cube
-ynh_secure_remove /etc/openvpn/client.ovpn
+ynh_safe_rm /etc/openvpn/client.conf
+ynh_safe_rm /etc/openvpn/client.cube
+ynh_safe_rm /etc/openvpn/client.ovpn
 
 
 # Remove openvpn script
 # Remove openvpn script
-ynh_secure_remove /etc/openvpn/scripts/run-parts.sh
+ynh_safe_rm /etc/openvpn/scripts/run-parts.sh
 
 
 for FILE in $(ls /etc/openvpn/scripts/route-up.d/*-vpnclient-* /etc/openvpn/scripts/route-down.d/*-vpnclient-*); do
 for FILE in $(ls /etc/openvpn/scripts/route-up.d/*-vpnclient-* /etc/openvpn/scripts/route-down.d/*-vpnclient-*); do
-    ynh_secure_remove "$FILE"
+    ynh_safe_rm "$FILE"
 done
 done
 
 
 # Remove openvpn service
 # Remove openvpn service
-ynh_secure_remove /etc/systemd/system/openvpn@.service.d/override.conf
+ynh_safe_rm /etc/systemd/system/openvpn@.service.d/override.conf
 
 
 # Remove openvpn certificates
 # Remove openvpn certificates
-ynh_secure_remove /etc/openvpn/keys
+ynh_safe_rm /etc/openvpn/keys
 
 
 # Reload systemd configuration
 # Reload systemd configuration
 systemctl daemon-reload
 systemctl daemon-reload

+ 4 - 7
scripts/restore

@@ -8,12 +8,11 @@ source /usr/share/yunohost/helpers
 #=================================================
 #=================================================
 ynh_print_info "Restoring the app files..."
 ynh_print_info "Restoring the app files..."
 
 
-ynh_restore
-
+ynh_restore_everything
 #=================================================
 #=================================================
 # RESTORE SYSTEMD
 # RESTORE SYSTEMD
 #=================================================
 #=================================================
-ynh_print_info "Restoring the systemd configuration..."
+ynh_print_info "Restoring $app's systemd service..."
 
 
 systemctl daemon-reload
 systemctl daemon-reload
 
 
@@ -28,8 +27,8 @@ systemctl stop openvpn
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 yunohost service enable "$service_name"
 yunohost service enable "$service_name"
 
 
-ynh_use_logrotate --logfile="/var/log/ynh-vpnclient.log"
-ynh_use_logrotate --logfile="/var/log/openvpn-client.log"
+ynh_config_add_logrotate "/var/log/ynh-vpnclient.log"
+ynh_config_add_logrotate "/var/log/openvpn-client.log"
 
 
 # checker service
 # checker service
 
 
@@ -38,12 +37,10 @@ systemctl enable "$service_checker_name" --quiet
 systemctl start "$service_checker_name.timer"
 systemctl start "$service_checker_name.timer"
 systemctl enable "$service_checker_name.timer" --quiet
 systemctl enable "$service_checker_name.timer" --quiet
 
 
-
 #=================================================
 #=================================================
 # ADVERTISE SERVICE IN ADMIN PANEL
 # ADVERTISE SERVICE IN ADMIN PANEL
 #=================================================
 #=================================================
 
 
-
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT
 #=================================================
 #=================================================

+ 27 - 26
scripts/upgrade

@@ -9,61 +9,62 @@ source /usr/share/yunohost/helpers
 
 
 # Removing configuration files with naming that occured in versions < 1.2.0 ("vpnadmin" instead off "$app")
 # Removing configuration files with naming that occured in versions < 1.2.0 ("vpnadmin" instead off "$app")
 if [ -d /var/www/vpnadmin ]; then
 if [ -d /var/www/vpnadmin ]; then
-  ynh_secure_remove /var/www/vpnadmin
+  ynh_safe_rm /var/www/vpnadmin
 fi
 fi
 
 
 # Old stuff
 # Old stuff
 
 
 if [ -f /etc/nginx/conf.d/*.d/$app.conf ]; then
 if [ -f /etc/nginx/conf.d/*.d/$app.conf ]; then
-	ynh_secure_remove /etc/nginx/conf.d/*.d/$app.conf
-    ynh_systemd_action --service_name=nginx --action=reload
+	ynh_safe_rm /etc/nginx/conf.d/*.d/$app.conf
+  ynh_systemctl --service="nginx" --action="reload"
 fi
 fi
 
 
 for php_path in $(ls /etc/php/*/fpm/pool.d/$app.conf 2> /dev/null); do
 for php_path in $(ls /etc/php/*/fpm/pool.d/$app.conf 2> /dev/null); do
-	ynh_secure_remove $php_path
+	ynh_safe_rm "$php_path"
 done
 done
 
 
 if [ -d /var/www/$app ]; then
 if [ -d /var/www/$app ]; then
-	ynh_secure_remove /var/www/$app
+	ynh_safe_rm "/var/www/$app"
 fi
 fi
 
 
-[ -z "${domain:-}" ] || ynh_app_setting_delete $app domain
-[ -z "${path:-}" ] || ynh_app_setting_delete $app path
-[ -z "${is_public:-}" ] || ynh_app_setting_delete $app is_public
-[ -z "${install_dir:-}" ] || ynh_app_setting_delete $app install_dir
+[ -z "${domain:-}" ] || ynh_app_setting_delete domain
+[ -z "${path:-}" ] || ynh_app_setting_delete path
+[ -z "${is_public:-}" ] || ynh_app_setting_delete is_public
+[ -z "${install_dir:-}" ] || ynh_app_setting_delete install_dir
 
 
 if [ -e "/etc/sudoers.d/${app}_ynh" ]; then
 if [ -e "/etc/sudoers.d/${app}_ynh" ]; then
-  ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
+  ynh_safe_rm "/etc/sudoers.d/${app}_ynh"
 fi
 fi
 
 
 if [ -e "/etc/yunohost/hooks.d/90-vpnclient.tpl" ]; then
 if [ -e "/etc/yunohost/hooks.d/90-vpnclient.tpl" ]; then
-  ynh_secure_remove "/etc/yunohost/hooks.d/90-vpnclient.tpl"
+  ynh_safe_rm "/etc/yunohost/hooks.d/90-vpnclient.tpl"
 fi
 fi
 
 
 if [ -e "/etc/openvpn/client.conf.tpl" ]; then
 if [ -e "/etc/openvpn/client.conf.tpl" ]; then
-  ynh_secure_remove "/etc/openvpn/client.conf.tpl"
+  ynh_safe_rm "/etc/openvpn/client.conf.tpl"
 fi
 fi
 
 
 # New stuff
 # New stuff
 
 
 if [ -z "${dns_method:-}" ]; then
 if [ -z "${dns_method:-}" ]; then
-    ynh_app_setting_set --app=$app --key=dns_method --value=custom
+    ynh_app_setting_set --key="dns_method" --value="custom"
 fi
 fi
+# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=nameservers --value="$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq | paste -s -d, -)"
 if [ -z "${nameservers:-}" ]; then
 if [ -z "${nameservers:-}" ]; then
     nameservers="$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq | paste -s -d, -)"
     nameservers="$(grep -o -P '\s*nameserver\s+\K[abcdefabcdef\d.:]+' /etc/resolv.dnsmasq.conf | sort | uniq | paste -s -d, -)"
-    ynh_app_setting_set --app=$app --key=nameservers --value="$nameservers"
+    ynh_app_setting_set --key="nameservers" --value="$nameservers"
 fi
 fi
 if [ -z "${service_enabled:-}" ]; then
 if [ -z "${service_enabled:-}" ]; then
-    ynh_app_setting_set --app=$app --key=service_enabled --value=0
+    ynh_app_setting_set --key="service_enabled" --value="0"
 fi
 fi
 if [ -z "${ip6_addr:-}" ]; then
 if [ -z "${ip6_addr:-}" ]; then
-    ynh_app_setting_set --app=$app --key=ip6_addr --value=""
+    ynh_app_setting_set --key="ip6_addr" --value=""
 fi
 fi
 if [ -z "${ip6_net:-}" ]; then
 if [ -z "${ip6_net:-}" ]; then
-    ynh_app_setting_set --app=$app --key=ip6_net --value=""
+    ynh_app_setting_set --key="ip6_net" --value=""
 fi
 fi
 if [ -z "${ip6_send_over_tun_enabled:-}" ]; then
 if [ -z "${ip6_send_over_tun_enabled:-}" ]; then
-    ynh_app_setting_set --app=$app --key=ip6_send_over_tun_enabled --value=0
+    ynh_app_setting_set --key="ip6_send_over_tun_enabled" --value="0"
 fi
 fi
 
 
 #=================================================
 #=================================================
@@ -71,16 +72,16 @@ fi
 #=================================================
 #=================================================
 
 
 if [ -e "/etc/systemd/system/openvpn@.service" ]; then
 if [ -e "/etc/systemd/system/openvpn@.service" ]; then
-  ynh_secure_remove "/etc/systemd/system/openvpn@.service"
+  ynh_safe_rm "/etc/systemd/system/openvpn@.service"
 fi
 fi
 
 
 #=================================================
 #=================================================
 # DEPLOY FILES FROM PACKAGE
 # DEPLOY FILES FROM PACKAGE
 #=================================================
 #=================================================
 
 
-ynh_print_info --message="Stopping VPN client to apply config changes..."
+ynh_print_info "Stopping VPN client to apply config changes..."
 
 
-ynh_systemd_action --action="stop" --service_name="$service_checker_name.timer"
+ynh_systemctl --action="stop" --service="$service_checker_name.timer"
 yunohost service stop $service_name
 yunohost service stop $service_name
 
 
 # Keep a copy of existing config files before overwriting them
 # Keep a copy of existing config files before overwriting them
@@ -116,7 +117,7 @@ for config_file in ${tmp_dir}/client.{conf,cube,ovpn}; do
     cp "${config_file}" /etc/openvpn/
     cp "${config_file}" /etc/openvpn/
   fi
   fi
 done
 done
-ynh_secure_remove ${tmp_dir}
+ynh_safe_rm "${tmp_dir}"
 
 
 #=================================================
 #=================================================
 # SERVICE INTEGRATION IN YUNOHOST
 # SERVICE INTEGRATION IN YUNOHOST
@@ -128,11 +129,11 @@ ynh_print_info "Configuring VPN client services..."
 # main service
 # main service
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
 
 
-ynh_use_logrotate --logfile="/var/log/ynh-vpnclient.log"
-ynh_use_logrotate --logfile="/var/log/openvpn-client.log"
+ynh_config_add_logrotate "/var/log/ynh-vpnclient.log"
+ynh_config_add_logrotate "/var/log/openvpn-client.log"
 
 
 # checker service (this service was previously integrated in yunohost but we do not do this anymore)
 # checker service (this service was previously integrated in yunohost but we do not do this anymore)
-if ynh_exec_warn_less yunohost service status $service_checker_name >/dev/null
+if ynh_hide_warnings yunohost service status $service_checker_name >/dev/null
 then
 then
     yunohost service remove $service_checker_name
     yunohost service remove $service_checker_name
 fi
 fi
@@ -144,7 +145,7 @@ ynh_print_info "Restart services..."
 
 
 # this is meant to propagate the new files and configs
 # this is meant to propagate the new files and configs
 yunohost service start $service_name
 yunohost service start $service_name
-ynh_systemd_action --action="start" --service_name="$service_checker_name.timer"
+ynh_systemctl --action="start" --service="$service_checker_name.timer"
 
 
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT

+ 2 - 2
tests.toml

@@ -4,6 +4,6 @@ test_format = 1.0
 
 
 [default]
 [default]
 
 
-    [default.test_upgrade_from.0d2a6b1d]
-    name = "v1 era"
+    [default.test_upgrade_from.179f9fa]
+    name = "v2.2"
     args.domain = "domain.tld"
     args.domain = "domain.tld"