Parcourir la source

Update to last standard

Maniack Crudelis il y a 6 ans
Parent
commit
a719095dc5
15 fichiers modifiés avec 298 ajouts et 304 suppressions
  1. 1 0
      README.md
  2. 1 0
      README_fr.md
  3. 1 12
      check_process
  4. 22 17
      conf/nginx.conf
  5. 1 1
      manifest.json
  6. 15 0
      scripts/_common.sh
  7. 1 7
      scripts/_variables
  8. 7 7
      scripts/actions/reset_default_config
  9. 27 27
      scripts/backup
  10. 11 22
      scripts/change_url
  11. 27 26
      scripts/config
  12. 60 64
      scripts/install
  13. 33 33
      scripts/remove
  14. 46 45
      scripts/restore
  15. 45 43
      scripts/upgrade

+ 1 - 0
README.md

@@ -54,6 +54,7 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
 
  * Report a bug: https://github.com/YunoHost-Apps/pihole_ynh/issues
  * Pi-hole website: https://pi-hole.net/
+ * Pi-hole repository: https://github.com/pi-hole/pi-hole/
  * YunoHost website: https://yunohost.org/
 
 ---

+ 1 - 0
README_fr.md

@@ -54,6 +54,7 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
 
  * Reporter un bug: https://github.com/YunoHost-Apps/pihole_ynh/issues
  * Site de Pi-hole: https://pi-hole.net/
+ * Dépôt de Pi-hole: https://github.com/pi-hole/pi-hole/
  * Site de YunoHost: https://yunohost.org/
 
 ---

+ 1 - 12
check_process

@@ -1,5 +1,4 @@
 ;; Test complet
-	auto_remove=1
 	; Manifest
 		domain="domain.tld"	(DOMAIN)
 		path="/path"	(PATH)
@@ -19,20 +18,10 @@
 		port_already_use=1 (4711)
 		change_url=1
 ;;; Levels
-	Level 1=auto
-	Level 2=auto
-	Level 3=auto
-# Level 4: 
-	Level 4=na
 	Level 5=auto
-	Level 6=auto
-	Level 7=auto
-	Level 8=0
-	Level 9=0
-	Level 10=0
 ;;; Options
 Email=
-Notification=down
+Notification=change
 ;;; Upgrade options
 	; commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932
 		name= Stretch fix

+ 22 - 17
conf/nginx.conf

@@ -1,22 +1,27 @@
 #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
 location __PATH__/ {
-	alias __FINALPATH__/;
 
-	if ($scheme = http) {
-		rewrite ^ https://$server_name$request_uri? permanent;
-	}
-	index index.html index.php ;
-	try_files $uri $uri/ index.php;
-	location ~ [^/]\.php(/|$) {
-		fastcgi_split_path_info ^(.+?\.php)(/.*)$;
-		fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
-		fastcgi_index index.php;
-		include fastcgi_params;
-		fastcgi_param REMOTE_USER $remote_user;
-		fastcgi_param PATH_INFO $fastcgi_path_info;
-		fastcgi_param SCRIPT_FILENAME $request_filename;
-	}
+    # Path to source
+    alias __FINALPATH__/;
 
-	# Include SSOWAT user panel.
-	include conf.d/yunohost_panel.conf.inc;
+    # Force usage of https
+    if ($scheme = http) {
+        rewrite ^ https://$server_name$request_uri? permanent;
+    }
+
+    index index.html index.php ;
+
+    try_files $uri $uri/ index.php;
+    location ~ [^/]\.php(/|$) {
+        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
+        fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param REMOTE_USER $remote_user;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+        fastcgi_param SCRIPT_FILENAME $request_filename;
+    }
+
+    # Include SSOWAT user panel.
+    include conf.d/yunohost_panel.conf.inc;
 }

+ 1 - 1
manifest.json

@@ -14,7 +14,7 @@
 		"email": "maniackc_dev@crudelis.fr"
 	},
 	"requirements": {
-		"yunohost": ">= 3.4"
+		"yunohost": ">= 3.6"
 	},
 	"multi_instance": false,
 	"services": [

+ 15 - 0
scripts/_common.sh

@@ -733,3 +733,18 @@ ynh_get_scalable_phpfpm () {
         fi
     fi
 }
+
+#=================================================
+
+# Execute a command as another user
+# usage: exec_as USER COMMAND [ARG ...]
+exec_as() {
+  local USER=$1
+  shift 1
+
+  if [[ $USER = $(whoami) ]]; then
+    eval "$@"
+  else
+    sudo -u "$USER" "$@"
+  fi
+}

+ 1 - 7
scripts/_variables

@@ -1,10 +1,4 @@
 #!/bin/bash
 
 # Dependencies
-app_depencencies="sqlite idn2"
-# dhcpcd5 has been removed because it can cause some problems with the internet connection.
-if [ "$(ynh_debian_release)" != "jessie" ]; then
-	app_depencencies="$app_depencencies php-sqlite3"
-else
-	app_depencencies="$app_depencencies php5-sqlite"
-fi
+app_depencencies="sqlite idn2 php7.0-sqlite3"

+ 7 - 7
scripts/actions/reset_default_config

@@ -12,10 +12,10 @@ source /usr/share/yunohost/helpers
 #=================================================
 # RETRIEVE ARGUMENTS
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-query_logging=$(ynh_app_setting_get $app query_logging)
+
+query_logging=$(ynh_app_setting_get --app=$app --key=query_logging)
 
 #=================================================
 # SORT OUT THE CONFIG FILE TO HANDLE
@@ -34,10 +34,10 @@ fi
 #=================================================
 # RESET THE CONFIG FILE
 #=================================================
-ynh_script_progression --message="Reset the config file $config_file" --weight=9
+ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
 
 # Verify the checksum and backup the file if it's different
-ynh_backup_if_checksum_is_different "$config_file"
+ynh_backup_if_checksum_is_different --file="$config_file"
 
 if [ "$file" = "setupVars.conf" ]
 then
@@ -46,7 +46,7 @@ then
 	main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
 	echo "PIHOLE_INTERFACE=$main_iface" > "$config_file"
 	echo "IPV4_ADDRESS=127.0.0.1" >> "$config_file"
-	echo "IPV6_ADDRESS=" >> "$config_file"
+	echo "IPV6_ADDRESS=::1" >> "$config_file"
 	echo "PIHOLE_DNS_1=" >> "$config_file"
 	echo "PIHOLE_DNS_2=" >> "$config_file"
 	if [ $query_logging -eq 1 ]; then
@@ -62,14 +62,14 @@ then
 	# Get the default file and overwrite the current config
 	cp /etc/yunohost/apps/$app/conf/pihole-FTL.conf "$config_file"
 
-	ynh_script_progression --message="Restart PiHole" --weight=2
+	ynh_script_progression --message="Restarting PiHole..." --weight=2
 
 	# Restart pihole-FTL
 	ynh_systemd_action --action=restart --service_name=pihole-FTL
 fi
 
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$config_file"
+ynh_store_file_checksum --file="$config_file"
 
 #=================================================
 # END OF SCRIPT

+ 27 - 27
scripts/backup

@@ -19,84 +19,84 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
 app=$YNH_APP_INSTANCE_NAME
 
-final_path=$(ynh_app_setting_get $app final_path)
-path_url=$(ynh_app_setting_get $app path)
-domain=$(ynh_app_setting_get $app domain)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
 
 #=================================================
 # STANDARD BACKUP STEPS
 #=================================================
 # BACKUP THE MAIN APP DIRECTORIES
 #=================================================
-ynh_script_progression --message="Backup the app main directories" --weight=5
+ynh_script_progression --message="Backing up the main app directory..." --weight=5
 
 CHECK_SIZE "$final_path"
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
 
 CHECK_SIZE "/etc/.pihole"
-ynh_backup "/etc/.pihole"
+ynh_backup --src_path="/etc/.pihole"
 
 CHECK_SIZE "/etc/pihole"
-ynh_backup "/etc/pihole"
+ynh_backup --src_path="/etc/pihole"
 
 CHECK_SIZE "/opt/pihole"
-ynh_backup "/opt/pihole"
+ynh_backup --src_path="/opt/pihole"
 
 #=================================================
 # BACKUP NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Backup nginx configuration"
+ynh_script_progression --message="Backing up nginx web server configuration..."
 
-ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 #=================================================
 # BACKUP PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Backup php-fpm configuration"
+ynh_script_progression --message="Backing up php-fpm configuration..."
 
-ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
 
 #=================================================
 # SPECIFIC BACKUP
 #=================================================
 # BACKUP CRON FILE
 #=================================================
-ynh_script_progression --message="Backup cron file"
+ynh_script_progression --message="Backing up cron file..."
 
-ynh_backup "/etc/cron.d/pihole"
+ynh_backup --src_path="/etc/cron.d/pihole"
 
 #=================================================
 # BACKUP SPECIFIC FILES
 #=================================================
-ynh_script_progression --message="Backup specific files"
+ynh_script_progression --message="Backing specific files..."
 
-ynh_backup "/usr/local/bin/pihole"
-ynh_backup "/etc/bash_completion.d/pihole"
+ynh_backup --src_path="/usr/local/bin/pihole"
+ynh_backup --src_path="/etc/bash_completion.d/pihole"
 
-ynh_backup "/etc/sudoers.d/pihole"
+ynh_backup --src_path="/etc/sudoers.d/pihole"
 
-ynh_backup "/etc/init.d/pihole-FTL"
-ynh_backup "/usr/bin/pihole-FTL"
+ynh_backup --src_path="/etc/init.d/pihole-FTL"
+ynh_backup --src_path="/usr/bin/pihole-FTL"
 
-ynh_backup "/etc/dnsmasq.d/01-pihole.conf"
+ynh_backup --src_path="/etc/dnsmasq.d/01-pihole.conf"
 if test -e "/etc/dnsmasq.d/02-pihole-dhcp.conf"; then
-	ynh_backup "/etc/dnsmasq.d/02-pihole-dhcp.conf"
+	ynh_backup --src_path="/etc/dnsmasq.d/02-pihole-dhcp.conf"
 fi
 if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
-	ynh_backup "/etc/dnsmasq.d/03-pihole-wildcard.conf"
+	ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
 fi
 if test -e "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"; then
-	ynh_backup "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
+	ynh_backup --src_path="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
 fi
 
-ynh_backup "/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
+ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Backup completed" --last
+ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

+ 11 - 22
scripts/change_url

@@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers
 #=================================================
 # RETRIEVE ARGUMENTS
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 old_domain=$YNH_APP_OLD_DOMAIN
 old_path=$YNH_APP_OLD_PATH
@@ -25,9 +24,9 @@ app=$YNH_APP_INSTANCE_NAME
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@@ -49,7 +48,7 @@ ynh_abort_if_errors
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode"
+ynh_script_progression --message="Activating maintenance mode..."
 
 path_url=$old_path
 domain=$old_domain
@@ -71,19 +70,12 @@ then
 	change_path=1
 fi
 
-#=================================================
-# MANAGE FAILURE OF THE SCRIPT
-#=================================================
-
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
 # MODIFY URL IN NGINX CONF
 #=================================================
-ynh_script_progression --message="Modify url in nginx configuration" --weight=4
+ynh_script_progression --message="Updating nginx web server configuration..." --weight=4
 
 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
 
@@ -91,15 +83,12 @@ 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"
 
-	# Store path_url setting
-	ynh_app_setting_set $app path_url "$path_url"
-
 	# Create a dedicated nginx config
 	ynh_add_nginx_config
 fi
@@ -108,11 +97,11 @@ 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
 
 #=================================================
@@ -120,14 +109,14 @@ fi
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx"
+ynh_script_progression --message="Reloading nginx web server..."
 
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=5
+ynh_script_progression --message="Disabling maintenance mode..." --weight=5
 
 path_url=$old_path
 domain=$old_domain
@@ -137,4 +126,4 @@ ynh_maintenance_mode_OFF
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Change of url completed" --last
+ynh_script_progression --message="Change of URL completed for $app" --last

+ 27 - 26
scripts/config

@@ -28,28 +28,24 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
 # Otherwise, keep the value from the app config.
 
 # Overwrite setupVars.conf file
-old_overwrite_setupvars="$(ynh_app_setting_get $app overwrite_setupvars)"
-old_overwrite_setupvars=$(bool_to_true_false $old_overwrite_setupvars)
+old_overwrite_setupvars="$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)"
 overwrite_setupvars="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS:-$old_overwrite_setupvars}"
 
 # Overwrite pihole-FTL.conf file
-old_overwrite_ftl="$(ynh_app_setting_get $app overwrite_ftl)"
-old_overwrite_ftl=$(bool_to_true_false $old_overwrite_ftl)
+old_overwrite_ftl="$(ynh_app_setting_get --app=$app --key=overwrite_ftl)"
 overwrite_ftl="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL:-$old_overwrite_ftl}"
 
 # Overwrite nginx configuration
-old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
-old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
+old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
 overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
 
 # Overwrite php-fpm configuration
-old_overwrite_phpfpm="$(ynh_app_setting_get $app overwrite_phpfpm)"
-old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
+old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)"
 overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
 
+
 # Type of admin mail configuration
-old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)"
-old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html)
+old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
 admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
 
 
@@ -79,14 +75,15 @@ fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}"
 
 show_config() {
 	# here you are supposed to read some config file/database/other then print the values
-	# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
+	# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
+
+	ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
+	ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
+	ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
+	ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
 
-	echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
-	echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
-	echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
-	echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
+	ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
 
-	echo "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
 	ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
 	ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
 	ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
@@ -97,22 +94,26 @@ show_config() {
 #=================================================
 
 apply_config() {
+
+    #=================================================
+    # MODIFY OVERWRITTING SETTINGS
+    #=================================================
+
 	# Set overwrite_setupvars
-	overwrite_setupvars=$(bool_to_01 $overwrite_setupvars)
-	ynh_app_setting_set $app overwrite_setupvars "$overwrite_setupvars"
+	ynh_app_setting_set --app=$app --key=overwrite_setupvars --value="$overwrite_setupvars"
 	# Set overwrite_ftl
-	overwrite_ftl=$(bool_to_01 $overwrite_ftl)
-	ynh_app_setting_set $app overwrite_ftl "$overwrite_ftl"
+	ynh_app_setting_set --app=$app --key=overwrite_ftl --value="$overwrite_ftl"
 	# Set overwrite_nginx
-	overwrite_nginx=$(bool_to_01 $overwrite_nginx)
-	ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
+	ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
 	# Set overwrite_phpfpm
-	overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
-	ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
+	ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
+
+    #=================================================
+    # MODIFY EMAIL SETTING
+    #=================================================
 
 	# Set admin_mail_html
-	admin_mail_html=$(bool_to_01 $admin_mail_html)
-	ynh_app_setting_set $app admin_mail_html "$admin_mail_html"
+	ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
 
     #=================================================
     # RECONFIGURE PHP-FPM

+ 60 - 64
scripts/install

@@ -22,7 +22,6 @@ ynh_abort_if_errors
 #=================================================
 # RETRIEVE ARGUMENTS FROM THE MANIFEST
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 domain=$YNH_APP_ARG_DOMAIN
 path_url=$YNH_APP_ARG_PATH
@@ -35,50 +34,47 @@ app=$YNH_APP_INSTANCE_NAME
 #=================================================
 # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
 #=================================================
-ynh_script_progression --message="Check if the app can be installed"
+ynh_script_progression --message="Validating installation parameters..." --weight=2
 
 final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
-
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
 
 # Register (book) web path
-ynh_webpath_register $app $domain $path_url
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
 
 #=================================================
 # STORE SETTINGS FROM MANIFEST
 #=================================================
-ynh_script_progression --message="Store settings from manifest" --weight=3
+ynh_script_progression --message="Storing installation settings..." --weight=3
 
-ynh_app_setting_set $app domain $domain
-ynh_app_setting_set $app path $path_url
-ynh_app_setting_set $app admin $admin
-ynh_app_setting_set $app query_logging $query_logging
-ynh_app_setting_set $app enable_dhcp $enable_dhcp
+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=admin --value=$admin
+ynh_app_setting_set --app=$app --key=query_logging --value=$query_logging
+ynh_app_setting_set --app=$app --key=enable_dhcp --value=$enable_dhcp
 
-ynh_app_setting_set $app overwrite_setupvars "1"
-ynh_app_setting_set $app overwrite_ftl "1"
-ynh_app_setting_set $app overwrite_nginx "1"
-ynh_app_setting_set $app overwrite_phpfpm "1"
-ynh_app_setting_set $app admin_mail_html "1"
+ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=1
+ynh_app_setting_set --app=$app --key=overwrite_ftl --value=1
+ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
+ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1
+ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
 
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
 # FIND AND OPEN A PORT
 #=================================================
-ynh_script_progression --message="Find and open a free port" --weight=12
+ynh_script_progression --message="Configuring firewall..." --weight=12
 
 # Find a free port
-port=$(ynh_find_port 4711)
+port=$(ynh_find_port --port=4711)
 if [ $port -gt 4720 ]
 then
-	ynh_die "The ports 4711 to 4720 are already in use. Pi-hole can't works on another port. Please try to free one of this ports."
+	ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't works on another port. Please try to free one of this ports."
 fi
 # Open this port
 ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port
-ynh_app_setting_set $app port $port
+ynh_app_setting_set --app=$app --key=port --value=$port
 
 # Disable the port 53 for upnp
 ynh_exec_fully_quiet yunohost firewall disallow Both 53 --no-reload
@@ -87,26 +83,26 @@ ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
 #=================================================
 # INSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Install dependencies" --weight=12
+ynh_script_progression --message="Installing dependencies..." --weight=12
 
 ynh_install_app_dependencies $app_depencencies
 
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
-ynh_script_progression --message="Download, check and unpack source" --weight=4
+ynh_script_progression --message="Setting up source files..." --weight=4
 
-ynh_app_setting_set $app final_path $final_path
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
 # Make a copy of local pihole repository (for Gravity)
 pihole_local_repo="/etc/.pihole"
-ynh_setup_source "$pihole_local_repo"
+ynh_setup_source --dest_dir="$pihole_local_repo"
 # Install admin dashboard
-ynh_setup_source "$final_path" admin_dashboard
+ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
 
 #=================================================
 # NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Configure nginx" --weight=2
+ynh_script_progression --message="Configuring nginx web server..." --weight=2
 
 # Create a dedicated nginx config
 ynh_add_nginx_config
@@ -114,15 +110,15 @@ ynh_add_nginx_config
 #=================================================
 # CREATE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Create a dedicated user" --weight=2
+ynh_script_progression --message="Configuring system user..." --weight=2
 
 # Create a dedicated system user
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Configure php-fpm" --weight=2
+ynh_script_progression --message="Configuring php-fpm..." --weight=2
 
 # Create a dedicated php-fpm config
 ynh_add_fpm_config --usage=low --footprint=low
@@ -132,7 +128,7 @@ ynh_add_fpm_config --usage=low --footprint=low
 #=================================================
 # CREATE DIRECTORIES AND POPULATE THEM
 #=================================================
-ynh_script_progression --message="Create and populate directories"
+ynh_script_progression --message="Creating and populating directories..."
 
 pihole_storage="/etc/pihole"
 mkdir -p "$pihole_storage"
@@ -151,7 +147,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/"
 #=================================================
 # COPY PI-HOLE MAIN SCRIPT
 #=================================================
-ynh_script_progression --message="Copy Pi-Hole main script"
+ynh_script_progression --message="Copying Pi-Hole main script..."
 
 cp -a "$pihole_local_repo/pihole" /usr/local/bin/
 cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole
@@ -185,21 +181,21 @@ sed -i "/# su #/d;" "$pihole_storage/logrotate"
 #=================================================
 # INSTALLATION OF PIHOLE-FTL
 #=================================================
-ynh_script_progression --message="Install PiHole-FTL" --weight=30
+ynh_script_progression --message="Installing PiHole-FTL..." --weight=30
 
 # Get the source of Pi-Hole-FTL
 FTL_temp_path=$(mktemp -d)
-ynh_setup_source "$FTL_temp_path" FTL
+ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
 
 # Instead of downloading a binary file, we're going to compile it
 ( cd "$FTL_temp_path"
 ynh_exec_warn_less make
 ynh_exec_warn_less make install )
-ynh_secure_remove "$FTL_temp_path"
+ynh_secure_remove --file="$FTL_temp_path"
 
 cp "../conf/pihole-FTL.conf" "$pihole_storage"
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$pihole_storage/pihole-FTL.conf"
+ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
 
 cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
 chmod +x /etc/init.d/pihole-FTL
@@ -215,7 +211,7 @@ setupVars="$pihole_storage/setupVars.conf"
 main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
 echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
 echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
-echo "IPV6_ADDRESS=" >> $setupVars
+echo "IPV6_ADDRESS=::1" >> $setupVars
 echo "PIHOLE_DNS_1=" >> $setupVars
 echo "PIHOLE_DNS_2=" >> $setupVars
 if [ $query_logging -eq 1 ]; then
@@ -227,42 +223,42 @@ echo "QUERY_LOGGING=$query_logging" >> $setupVars
 echo "INSTALL_WEB=true" >> $setupVars
 
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$setupVars"
+ynh_store_file_checksum --file="$setupVars"
 
 #=================================================
 # SET UP DNSMASQ CONFIG
 #=================================================
-ynh_script_progression --message="Set up Dnsmasq config" --weight=2
+ynh_script_progression --message="Setting up Dnsmasq config..." --weight=2
 
 ynh_systemd_action --action=stop --service_name=dnsmasq
 
 pihole_dnsmasq_config="/etc/dnsmasq.d/01-pihole.conf"
 cp "$pihole_local_repo/advanced/01-pihole.conf" $pihole_dnsmasq_config
 # Use dns from /etc/resolv.dnsmasq.conf
-ynh_replace_string "@DNS1@" "" $pihole_dnsmasq_config
-ynh_replace_string "@DNS2@" "" $pihole_dnsmasq_config
-ynh_replace_string "^no-resolv" "#no-resolv" $pihole_dnsmasq_config
+ynh_replace_string --match_string="@DNS1@" --replace_string="" --target_file=$pihole_dnsmasq_config
+ynh_replace_string --match_string="@DNS2@" --replace_string="" --target_file=$pihole_dnsmasq_config
+ynh_replace_string --match_string="^no-resolv" --replace_string="#no-resolv" --target_file=$pihole_dnsmasq_config
 
-ynh_replace_string "@INT@" "$main_iface" $pihole_dnsmasq_config
+ynh_replace_string --match_string="@INT@" --replace_string="$main_iface" --target_file=$pihole_dnsmasq_config
 if [ "$query_logging" = "true" ]; then
-	ynh_replace_string "^#log-queries" "log-queries" $pihole_dnsmasq_config
+	ynh_replace_string --match_string="^#log-queries" --replace_string="log-queries" --target_file=$pihole_dnsmasq_config
 else
-	ynh_replace_string "^log-queries" "#log-queries" $pihole_dnsmasq_config
+	ynh_replace_string --match_string="^log-queries" --replace_string="#log-queries" --target_file=$pihole_dnsmasq_config
 fi
 
 # Fix a too recent option for our dnsmasq version.
-ynh_replace_string "log-queries=extra" "log-queries" $pihole_dnsmasq_config
+ynh_replace_string --match_string="log-queries=extra" --replace_string="log-queries" --target_file=$pihole_dnsmasq_config
 
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$pihole_dnsmasq_config"
+ynh_store_file_checksum --file="$pihole_dnsmasq_config"
 
 # To prevent any conflict with the original dnsmasq config, comment cache-size in the original config.
-ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
+ynh_replace_string --match_string="^cache-size=" --replace_string="#pihole# cache-size=" --target_file=/etc/dnsmasq.conf
 
 #=================================================
 # CONFIGURE DNS FOR THE LOCAL DOMAINS
 #=================================================
-ynh_script_progression --message="Configure dns for the local domains" --weight=7
+ynh_script_progression --message="Configuring dns for the local domains..." --weight=7
 
 # Find the IP associated to the network interface
 localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
@@ -271,7 +267,7 @@ localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f
 while read perdomain
 do
 	# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
-	ynh_replace_string "^127.0.0.1.*$perdomain" "#Commented by pihole# &" /etc/hosts
+	ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
 
 	# And add a resolution on the local IP instead
 	grep -q "^$localipv4.*$perdomain" /etc/hosts || \
@@ -284,7 +280,7 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 
 if [ $enable_dhcp -eq 1 ]
 then
-	ynh_script_progression --message="Enable dhcp server"
+	ynh_script_progression --message="Enabling dhcp server..."
 	max_dhcp_range=250
 	dhcp_range=100
 	# Define the dhcp range from the current ip
@@ -305,9 +301,9 @@ then
 	cp "../conf/02-pihole-dhcp.conf" "/etc/dnsmasq.d/"
 
 	# And set the config
-	ynh_replace_string "__A_RANGE__" "$ip_beginning_part.$a_range" "/etc/dnsmasq.d/02-pihole-dhcp.conf"
-	ynh_replace_string "__B_RANGE__" "$ip_beginning_part.$b_range" "/etc/dnsmasq.d/02-pihole-dhcp.conf"
-	ynh_replace_string "__GATEWAY__" "$gateway" "/etc/dnsmasq.d/02-pihole-dhcp.conf"
+	ynh_replace_string --match_string="__A_RANGE__" --replace_string="$ip_beginning_part.$a_range" --target_file="/etc/dnsmasq.d/02-pihole-dhcp.conf"
+	ynh_replace_string --match_string="__B_RANGE__" --replace_string="$ip_beginning_part.$b_range" --target_file="/etc/dnsmasq.d/02-pihole-dhcp.conf"
+	ynh_replace_string --match_string="__GATEWAY__" --replace_string="$gateway" --target_file="/etc/dnsmasq.d/02-pihole-dhcp.conf"
 
 	# Set a static ip for the server.
 	echo "dhcp-host=$hw_adress,$localipv4" > "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
@@ -319,7 +315,7 @@ ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
 #=================================================
 # RESTART DNSMASQ
 #=================================================
-ynh_script_progression --message="Restart Dnsmasq" --time --weight=2
+ynh_script_progression --message="Restarting Dnsmasq..." --weight=2
 
 ynh_systemd_action --action=restart --service_name=dnsmasq
 
@@ -329,12 +325,12 @@ ynh_systemd_action --action=restart --service_name=dnsmasq
 
 cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
 # Remove git usage for version. Which fails because we use here a release instead of master.
-ynh_replace_string ".*updatechecker.*" "#&" /etc/cron.d/pihole
+ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
 
 #=================================================
 # BUILD THE LISTS WITH GRAVITY
 #=================================================
-ynh_script_progression --message="Build the lists with Gravity" --weight=7
+ynh_script_progression --message="Building the lists with Gravity..." --weight=7
 
 cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
 ynh_exec_warn_less /opt/pihole/gravity.sh
@@ -342,7 +338,7 @@ ynh_exec_warn_less /opt/pihole/gravity.sh
 #=================================================
 # START PIHOLE-FTL
 #=================================================
-ynh_script_progression --message="Restart PiHole-FTL" --weight=2
+ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
 
 ynh_systemd_action --action=restart --service_name=pihole-FTL
 
@@ -363,16 +359,16 @@ yunohost service add pihole-FTL --description "PiHole backend service" --log "/v
 #=================================================
 # RESTRAIN THE ACCESS TO THE ADMIN ONLY
 #=================================================
-ynh_script_progression --message="Restrain the access to the admin only" --weight=2
+ynh_script_progression --message="Restraining the access to the admin only..." --weight=2
 
 yunohost app addaccess --users=$admin $app
 
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx" --weight=4
+ynh_script_progression --message="Reloading nginx web server..." --weight=3
 
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # SEND A README FOR THE ADMIN
@@ -396,10 +392,10 @@ You can also find some specific actions for this app by using the experimental _
 
 If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/pihole_ynh__URL_TAG3__." > mail_to_send
 
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="install"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=install
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Installation completed" --last
+ynh_script_progression --message="Installation of $app completed" --last

+ 33 - 33
scripts/remove

@@ -12,12 +12,12 @@ source /usr/share/yunohost/helpers
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-port=$(ynh_app_setting_get $app port)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+port=$(ynh_app_setting_get --app=$app --key=port)
 
 #=================================================
 # STANDARD REMOVE
@@ -28,7 +28,7 @@ port=$(ynh_app_setting_get $app port)
 # Check if the service is declared in YunoHost
 if ynh_exec_fully_quiet yunohost service status pihole-FTL
 then
-	ynh_print_info "Remove pihole-FTL service" >&2
+	ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
 	yunohost service remove pihole-FTL
 fi
 
@@ -44,7 +44,7 @@ rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" "
 #=================================================
 # REMOVE DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Remove dependencies" --weight=7
+ynh_script_progression --message="Removing dependencies..." --weight=7
 
 # Remove metapackage and its dependencies
 ynh_remove_app_dependencies
@@ -52,21 +52,21 @@ ynh_remove_app_dependencies
 #=================================================
 # REMOVE THE DIRECTORIES OF THE APP
 #=================================================
-ynh_script_progression --message="Remove app main directories"
+ynh_script_progression --message="Removing app main directory..."
 
 # Remove storage directory
-ynh_secure_remove "/etc/pihole"
+ynh_secure_remove --file="/etc/pihole"
 # Remove app directory
-ynh_secure_remove "/opt/pihole"
+ynh_secure_remove --file="/opt/pihole"
 # Remove admin panel directory
-ynh_secure_remove "/var/www/pihole"
+ynh_secure_remove --file="/var/www/pihole"
 # Remove local clone of the repository
-ynh_secure_remove "/etc/.pihole"
+ynh_secure_remove --file="/etc/.pihole"
 
 #=================================================
 # REMOVE NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove nginx configuration"
+ynh_script_progression --message="Removing nginx web server configuration..."
 
 # Remove the dedicated nginx config
 ynh_remove_nginx_config
@@ -74,7 +74,7 @@ ynh_remove_nginx_config
 #=================================================
 # REMOVE PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove php-fpm configuration" --weight=2
+ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
 
 # Remove the dedicated php-fpm config
 ynh_remove_fpm_config
@@ -82,17 +82,17 @@ ynh_remove_fpm_config
 #=================================================
 # CLOSE PORTS
 #=================================================
-ynh_script_progression --message="Close ports" --weight=13
+ynh_script_progression --message="Closing port $port et 67..." --weight=13
 
 if yunohost firewall list | grep -q "\- $port$"
 then
-	ynh_print_info "Close port $port" >&2
+	ynh_print_info "Close port $port"
 	ynh_exec_quiet yunohost firewall disallow TCP $port
 fi
 
 if yunohost firewall list | grep -q "\- 67$"
 then
-	ynh_print_info "Close port 67" >&2
+	ynh_print_info "Close port 67"
 	ynh_exec_quiet yunohost firewall disallow UDP 67
 fi
 
@@ -102,35 +102,35 @@ fi
 # REMOVE CRON FILE
 #=================================================
 
-ynh_secure_remove "/etc/cron.d/pihole"
+ynh_secure_remove --file="/etc/cron.d/pihole"
 
 #=================================================
 # REMOVE OTHER FILES
 #=================================================
 
 # Remove logs
-ynh_secure_remove "/var/log/pihole.log"
-ynh_secure_remove "/var/log/pihole-FTL.log"
+ynh_secure_remove --file="/var/log/pihole.log"
+ynh_secure_remove --file="/var/log/pihole-FTL.log"
 
 # Remove main script
-ynh_secure_remove "/usr/local/bin/pihole"
-ynh_secure_remove "/etc/bash_completion.d/pihole"
+ynh_secure_remove --file="/usr/local/bin/pihole"
+ynh_secure_remove --file="/etc/bash_completion.d/pihole"
 
 # Remove sudoer file
-ynh_secure_remove "/etc/sudoers.d/pihole"
+ynh_secure_remove --file="/etc/sudoers.d/pihole"
 
 #=================================================
 # REMOVE DNSMASQ CONFIG
 #=================================================
-ynh_script_progression --message="Remove Dnsmasq config" --weight=2
+ynh_script_progression --message="Removing Dnsmasq config..." --weight=2
 
 ynh_systemd_action --action=stop --service_name=dnsmasq
-rm -f "/etc/dnsmasq.d/01-pihole.conf"
-rm -f "/etc/dnsmasq.d/02-pihole-dhcp.conf"
-rm -f "/etc/dnsmasq.d/03-pihole-wildcard.conf"
-rm -f "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
+ynh_secure_remove --file="/etc/dnsmasq.d/01-pihole.conf"
+ynh_secure_remove --file="/etc/dnsmasq.d/02-pihole-dhcp.conf"
+ynh_secure_remove --file="/etc/dnsmasq.d/03-pihole-wildcard.conf"
+ynh_secure_remove --file="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
 
-ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
+ynh_replace_string --match_string="#pihole# " --replace_string="" --target_file=/etc/dnsmasq.conf
 
 #=================================================
 # CLEAN /etc/hosts
@@ -138,7 +138,7 @@ ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
 ynh_script_progression --message="Clean /etc/hosts"
 
 # Uncomment lines in /etc/hosts
-sed -i "s/#Commented by pihole# //g" /etc/hosts
+ynh_replace_string --match_string="#Commented by pihole# " --replace_string="" --target_file=/etc/hosts
 
 # And remove extra lines, added by PiHole
 sed -i "/#Added by pihole#/d" /etc/hosts
@@ -146,7 +146,7 @@ sed -i "/#Added by pihole#/d" /etc/hosts
 #=================================================
 # RESTART DNSMASQ
 #=================================================
-ynh_script_progression --message="Restart Dnsmasq"
+ynh_script_progression --message="Restarting Dnsmasq..."
 
 ynh_systemd_action --action=restart --service_name=dnsmasq
 
@@ -154,19 +154,19 @@ ynh_systemd_action --action=restart --service_name=dnsmasq
 # REMOVE CONF_REGEN HOOK
 #=================================================
 
-ynh_secure_remove /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
+ynh_secure_remove --file=/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
 
 #=================================================
 # GENERIC FINALISATION
 #=================================================
 # REMOVE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Remove the dedicated user" --weight=2
+ynh_script_progression --message="Removing the dedicated system user..." --weight=2
 
-ynh_system_user_delete $app
+ynh_system_user_delete --username=$app
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Deletion completed" --last
+ynh_script_progression --message="Removal of $app completed" --last

+ 46 - 45
scripts/restore

@@ -21,29 +21,30 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading settings..." --weight=2
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-final_path=$(ynh_app_setting_get $app final_path)
-enable_dhcp=$(ynh_app_setting_get $app enable_dhcp)
-admin=$(ynh_app_setting_get $app admin)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+enable_dhcp=$(ynh_app_setting_get --app=$app --key=enable_dhcp)
+admin=$(ynh_app_setting_get --app=$app --key=admin)
 
 #=================================================
 # CHECK IF THE APP CAN BE RESTORED
 #=================================================
+ynh_script_progression --message="Validating restoration parameters..."
 
-ynh_webpath_available $domain $path_url \
-	|| ynh_die "Path not available: ${domain}${path_url}"
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+	|| ynh_die --message="Path not available: ${domain}${path_url}"
 test ! -d $final_path \
-	|| ynh_die "There is already a directory: $final_path "
+	|| ynh_die --message="There is already a directory: $final_path "
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode" --weight=2
+ynh_script_progression --message="Activating maintenance mode..." --weight=2
 
 ynh_maintenance_mode_ON
 
@@ -53,28 +54,28 @@ ynh_maintenance_mode_ON
 # RESTORE THE NGINX CONFIGURATION
 #=================================================
 
-ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 #=================================================
 # RESTORE THE MAIN DIRECTORIES OF THE APP
 #=================================================
-ynh_script_progression --message="Restore the app main directories"
+ynh_script_progression --message="Restoring the app main directory..."
 
-ynh_restore_file "$final_path"
+ynh_restore_file --origin_path="$final_path"
 
-ynh_restore_file "/etc/.pihole"
+ynh_restore_file --origin_path="/etc/.pihole"
 
-ynh_restore_file "/etc/pihole"
+ynh_restore_file --origin_path="/etc/pihole"
 
-ynh_restore_file "/opt/pihole"
+ynh_restore_file --origin_path="/opt/pihole"
 
 #=================================================
 # RECREATE THE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Recreate the dedicated user" --weight=2
+ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
 
 # Create the dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # RESTORE USER RIGHTS
@@ -89,14 +90,14 @@ chown root: -R "/etc/pihole/logrotate"
 # RESTORE THE PHP-FPM CONFIGURATION
 #=================================================
 
-ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
 
 #=================================================
 # SPECIFIC RESTORE
 #=================================================
 # REINSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Reinstall dependencies" --weight=12
+ynh_script_progression --message="Reinstalling dependencies..." --weight=12
 
 ynh_install_app_dependencies $app_depencencies
 
@@ -110,7 +111,7 @@ yunohost service add pihole-FTL --description "PiHole backend service" --log "/v
 # RESTORE THE CRON FILE
 #=================================================
 
-ynh_restore_file "/etc/cron.d/pihole"
+ynh_restore_file --origin_path="/etc/cron.d/pihole"
 
 #=================================================
 # RECREATE LOG FILES
@@ -124,40 +125,40 @@ chown $dnsmasq_user:root /var/log/pihole.log
 #=================================================
 # RESTORE SPECIFIC FILES
 #=================================================
-ynh_script_progression --message="Restore specific files"
+ynh_script_progression --message="Restoring specific files..."
 
-ynh_restore_file "/usr/local/bin/pihole"
-ynh_restore_file "/etc/bash_completion.d/pihole"
+ynh_restore_file --origin_path="/usr/local/bin/pihole"
+ynh_restore_file --origin_path="/etc/bash_completion.d/pihole"
 
-ynh_restore_file "/etc/sudoers.d/pihole"
+ynh_restore_file --origin_path="/etc/sudoers.d/pihole"
 
-ynh_restore_file "/etc/init.d/pihole-FTL"
-ynh_restore_file "/usr/bin/pihole-FTL"
+ynh_restore_file --origin_path="/etc/init.d/pihole-FTL"
+ynh_restore_file --origin_path="/usr/bin/pihole-FTL"
 
-ynh_restore_file "/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
+ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
 
 #=================================================
 # RESTORE DNSMASQ CONFIG
 #=================================================
-ynh_script_progression --message="Restore Dnsmasq config"
+ynh_script_progression --message="Restoring Dnsmasq config..."
 
 ynh_systemd_action --action=stop --service_name=dnsmasq
 
-ynh_restore_file "/etc/dnsmasq.d/01-pihole.conf"
+ynh_restore_file --origin_path="/etc/dnsmasq.d/01-pihole.conf"
 test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/02-pihole-dhcp.conf" && \
-	ynh_restore_file "/etc/dnsmasq.d/02-pihole-dhcp.conf"
+	ynh_restore_file --origin_path="/etc/dnsmasq.d/02-pihole-dhcp.conf"
 test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/03-pihole-wildcard.conf" && \
-	ynh_restore_file "/etc/dnsmasq.d/03-pihole-wildcard.conf"
+	ynh_restore_file --origin_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
 test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/04-pihole-static-dhcp.conf" && \
-	ynh_restore_file "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
+	ynh_restore_file --origin_path="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
 
 # To prevent any conflict with the original dnsmasq config, comment cache-size in the original config.
-ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
+ynh_replace_string --match_string="^cache-size=" --replace_string="#pihole# cache-size=" --target_file=/etc/dnsmasq.conf
 
 #=================================================
 # CONFIGURE DNS FOR THE LOCAL DOMAINS
 #=================================================
-ynh_script_progression --message="Configure dns for the local domains" --weight=2
+ynh_script_progression --message="Configuring dns for the local domains..." --weight=2
 
 # Get the default network interface
 main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
@@ -168,7 +169,7 @@ localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f
 while read perdomain
 do
 	# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
-	sed -i "s/^127.0.0.1.*$perdomain/#Commented by pihole# &/g" /etc/hosts
+	ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
 
 	# And add a resolution on the local IP instead
 	grep -q "^$localipv4.*$perdomain" /etc/hosts || \
@@ -178,7 +179,7 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 #=================================================
 # RESTART DNSMASQ
 #=================================================
-ynh_script_progression --message="Restart Dnsmasq"
+ynh_script_progression --message="Restarting Dnsmasq..."
 
 ynh_systemd_action --action=restart --service_name=dnsmasq
 
@@ -189,16 +190,16 @@ ynh_systemd_action --action=restart --service_name=dnsmasq
 setupVars="/etc/pihole/setupVars.conf"
 
 echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
-ynh_replace_string "^PIHOLE_INTERFACE=.*" "PIHOLE_INTERFACE=$main_iface" $setupVars
-ynh_replace_string "^IPV4_ADDRESS=.*" "IPV4_ADDRESS=127.0.0.1" $setupVars
+ynh_replace_string --match_string="^PIHOLE_INTERFACE=.*" --replace_string="PIHOLE_INTERFACE=$main_iface" --target_file=$setupVars
+ynh_replace_string --match_string="^IPV4_ADDRESS=.*" --replace_string="IPV4_ADDRESS=127.0.0.1" --target_file=$setupVars
 
 # Recalculate and store the checksum of the file for the next upgrade.
-ynh_store_file_checksum "$setupVars"
+ynh_store_file_checksum --file="$setupVars"
 
 #=================================================
 # START PIHOLE-FTL
 #=================================================
-ynh_script_progression --message="Restart PiHole-FTL" --weight=2
+ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
 
 ynh_exec_warn_less systemctl enable pihole-FTL
 ynh_systemd_action --action=restart --service_name=pihole-FTL
@@ -208,7 +209,7 @@ ynh_systemd_action --action=restart --service_name=pihole-FTL
 #=================================================
 # RELOAD NGINX AND PHP-FPM
 #=================================================
-ynh_script_progression --message="Reload nginx and php-fpm"
+ynh_script_progression --message="Reloading nginx web server and php-fpm..."
 
 ynh_systemd_action --action=reload --service_name=php7.0-fpm
 ynh_systemd_action --action=reload --service_name=nginx
@@ -216,7 +217,7 @@ ynh_systemd_action --action=reload --service_name=nginx
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=4
+ynh_script_progression --message="Disabling maintenance mode..." --weight=4
 
 ynh_maintenance_mode_OFF
 
@@ -242,10 +243,10 @@ You can also find some specific actions for this app by using the experimental _
 
 If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/pihole_ynh__URL_TAG3__." > mail_to_send
 
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="restore"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=restore
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Restoration completed" --last
+ynh_script_progression --message="Restoration completed for $app" --last

+ 45 - 43
scripts/upgrade

@@ -15,21 +15,22 @@ source _variables
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=3
+ynh_script_progression --message="Loading installation settings..." --weight=3
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-admin=$(ynh_app_setting_get $app admin)
-query_logging=$(ynh_app_setting_get $app query_logging)
-final_path=$(ynh_app_setting_get $app final_path)
-enable_dhcp=$(ynh_app_setting_get $app enable_dhcp)
-port=$(ynh_app_setting_get $app port)
-overwrite_setupvars=$(ynh_app_setting_get $app overwrite_setupvars)
-overwrite_ftl=$(ynh_app_setting_get $app overwrite_ftl)
-overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
-overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+admin=$(ynh_app_setting_get --app=$app --key=admin)
+query_logging=$(ynh_app_setting_get --app=$app --key=query_logging)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+enable_dhcp=$(ynh_app_setting_get --app=$app --key=enable_dhcp)
+port=$(ynh_app_setting_get --app=$app --key=port)
+
+overwrite_setupvars=$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)
+overwrite_ftl=$(ynh_app_setting_get --app=$app --key=overwrite_ftl)
+overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
+overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
 
 fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
 fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
@@ -43,30 +44,31 @@ upgrade_type=$(ynh_check_app_version_changed)
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
-ynh_script_progression --message="Ensure downward compatibility"
+ynh_script_progression --message="Ensuring downward compatibility..."
 
 # If overwrite_setupvars doesn't exist, create it
 if [ -z "$overwrite_setupvars" ]; then
 	overwrite_setupvars=1
-	ynh_app_setting_set $app overwrite_setupvars $overwrite_setupvars
+	ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=$overwrite_setupvars
 fi
 
 # If overwrite_ftl doesn't exist, create it
 if [ -z "$overwrite_ftl" ]; then
 	overwrite_ftl=1
-	ynh_app_setting_set $app overwrite_ftl $overwrite_ftl
+	ynh_app_setting_set --app=$app --key=overwrite_ftl --value=$overwrite_ftl
 fi
 
 # If overwrite_nginx doesn't exist, create it
 if [ -z "$overwrite_nginx" ]; then
 	overwrite_nginx=1
-	ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
+	ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
 fi
 
 # If overwrite_phpfpm doesn't exist, create it
 if [ -z "$overwrite_phpfpm" ]; then
 	overwrite_phpfpm=1
-	ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
+	ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
+fi
 
 # If fpm_footprint doesn't exist, create it
 if [ -z "$fpm_footprint" ]; then
@@ -83,7 +85,7 @@ fi
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 #=================================================
-ynh_script_progression --message="Backup the app before upgrading" --weight=7
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7
 
 # Backup the current version of the app
 ynh_backup_before_upgrade
@@ -99,12 +101,12 @@ ynh_abort_if_errors
 #=================================================
 
 # Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+path_url=$(ynh_normalize_url_path --path_url=$path_url)
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode"
+ynh_script_progression --message="Activating maintenance mode..."
 
 ynh_maintenance_mode_ON
 
@@ -113,7 +115,7 @@ ynh_maintenance_mode_ON
 #=================================================
 # INSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Upgrade dependencies" --weight=6
+ynh_script_progression --message="Upgrading dependencies..." --weight=6
 
 ynh_install_app_dependencies $app_depencencies
 
@@ -124,11 +126,11 @@ ynh_install_app_dependencies $app_depencencies
 pihole_local_repo="/etc/.pihole"
 if [ "$upgrade_type" == "UPGRADE_APP" ]
 then
-	ynh_script_progression --message="Download, check and unpack source" --weight=4
+	ynh_script_progression --message="Upgrading source files..." --weight=4
 	# Update the local copy pihole repository (for Gravity)
-	ynh_setup_source "$pihole_local_repo"
+	ynh_setup_source --dest_dir="$pihole_local_repo"
 	# Update admin dashboard
-	ynh_setup_source "$final_path" admin_dashboard
+	ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
 fi
 
 #=================================================
@@ -138,7 +140,7 @@ fi
 # Overwrite the nginx configuration only if it's allowed
 if [ $overwrite_nginx -eq 1 ]
 then
-	ynh_script_progression --message="Reconfigure nginx" --weight=2
+	ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
 	# Create a dedicated nginx config
 	ynh_add_nginx_config
 fi
@@ -146,10 +148,10 @@ fi
 #=================================================
 # CREATE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Create a dedicated user"
+ynh_script_progression --message="Making sure dedicated system user exists..."
 
 # Create a dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # PHP-FPM CONFIGURATION
@@ -158,7 +160,7 @@ ynh_system_user_create $app
 # Overwrite the php-fpm configuration only if it's allowed
 if [ $overwrite_phpfpm -eq 1 ]
 then
-	ynh_script_progression --message="Reconfigure php-fpm" --weight=3
+	ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=3
 	# Create a dedicated php-fpm config
 	ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
 fi
@@ -179,7 +181,7 @@ cp -a "$pihole_local_repo/advanced/Scripts/COL_TABLE" "$pihole_dir/"
 #=================================================
 # COPY PI-HOLE MAIN SCRIPT
 #=================================================
-ynh_script_progression --message="Copy Pi-Hole main script"
+ynh_script_progression --message="Copying Pi-Hole main script..."
 
 cp -a "$pihole_local_repo/pihole" /usr/local/bin/
 cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.d/pihole
@@ -205,7 +207,7 @@ sed -i "/# su #/d;" "$pihole_storage/logrotate"
 #=================================================
 # UPDATE PIHOLE-FTL
 #=================================================
-ynh_script_progression --message="Upgrade PiHole-FTL" --weight=35
+ynh_script_progression --message="Upgrading PiHole-FTL..." --weight=35
 
 ynh_systemd_action --action=stop --service_name=pihole-FTL
 
@@ -213,23 +215,23 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
 then
 	# Get the source of Pi-Hole-FTL
 	FTL_temp_path=$(mktemp -d)
-	ynh_setup_source "$FTL_temp_path" FTL
+	ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
 
 	# Instead of downloading a binary file, we're going to compile it
 	( cd "$FTL_temp_path"
 	ynh_exec_warn_less make
 	ynh_exec_warn_less make install )
-	ynh_secure_remove "$FTL_temp_path"
+	ynh_secure_remove --file="$FTL_temp_path"
 fi
 
 # Overwrite pihole-FTL config file only if it's allowed
 if [ $overwrite_ftl -eq 1 ]
 then
 	# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-	ynh_backup_if_checksum_is_different "$pihole_storage/pihole-FTL.conf"
+	ynh_backup_if_checksum_is_different --file="$pihole_storage/pihole-FTL.conf"
 	cp "../conf/pihole-FTL.conf" "$pihole_storage"
 	# Recalculate and store the checksum of the file for the next upgrade.
-	ynh_store_file_checksum "$pihole_storage/pihole-FTL.conf"
+	ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
 fi
 
 cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
@@ -246,13 +248,13 @@ setupVars="$pihole_storage/setupVars.conf"
 if [ $overwrite_setupvars -eq 1 ]
 then
 	# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-	ynh_backup_if_checksum_is_different "$setupVars"
+	ynh_backup_if_checksum_is_different --file="$setupVars"
 
 	# Get the default network interface
 	main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
 	echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
 	echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
-	echo "IPV6_ADDRESS=" >> $setupVars
+	echo "IPV6_ADDRESS=::1" >> $setupVars
 	echo "PIHOLE_DNS_1=" >> $setupVars
 	echo "PIHOLE_DNS_2=" >> $setupVars
 	if [ $query_logging -eq 1 ]; then
@@ -264,7 +266,7 @@ then
 	echo "INSTALL_WEB=true" >> $setupVars
 
 	# Recalculate and store the checksum of the file for the next upgrade.
-	ynh_store_file_checksum "$setupVars"
+	ynh_store_file_checksum --file="$setupVars"
 fi
 
 #=================================================
@@ -273,12 +275,12 @@ fi
 
 cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
 # Remove git usage for version. Which fails because we use here a release instead of master.
-ynh_replace_string ".*updatechecker.*" "#&" /etc/cron.d/pihole
+ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
 
 #=================================================
 # START PIHOLE-FTL
 #=================================================
-ynh_script_progression --message="Restart PiHole-FTL" --weight=2
+ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2
 
 ynh_systemd_action --action=restart --service_name=pihole-FTL
 
@@ -291,14 +293,14 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx"
+ynh_script_progression --message="Reloading nginx web server..."
 
 ynh_systemd_action --action=reload --service_name=nginx
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=5
+ynh_script_progression --message="Disabling maintenance mode..." --weight=5
 
 ynh_maintenance_mode_OFF
 
@@ -341,10 +343,10 @@ If you're facing an issue or want to improve this app, please open a new issue i
 Changelog since your last upgrade:
 $(cat changelog)" > mail_to_send
 
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="upgrade"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=upgrade
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Upgrade completed" --last
+ynh_script_progression --message="Upgrade of $app completed" --last