Ver código fonte

Normalization from example_ynh

Maniack Crudelis 6 anos atrás
pai
commit
123b308441

+ 3 - 3
README.md

@@ -40,9 +40,9 @@ Not relevant.
 
 #### Supported architectures
 
-* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
-* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
-* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/archivist%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/archivist/)
+* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
+* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/archivist%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/archivist/)
 
 ## Limitations
 

+ 3 - 3
README_fr.md

@@ -40,9 +40,9 @@ Non applicable
 
 #### Architectures supportées.
 
-* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
-* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
-* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/archivist%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/archivist/)
+* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/archivist/)
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/archivist%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/archivist/)
+* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/archivist%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/archivist/)
 
 ## Limitations
 

+ 0 - 9
check_process

@@ -20,16 +20,7 @@
 		port_already_use=0
 		change_url=0
 ;;; Levels
-	Level 1=auto
-	Level 2=auto
-	Level 3=auto
-	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

+ 3 - 2
manifest.json

@@ -6,7 +6,7 @@
 		"en": "Automatic backups.",
 		"fr": "Sauvegardes automatiques."
 	},
-	"version": "0.7~ynh3",
+	"version": "0.7~ynh4",
 	"url": "https://github.com/maniackcrudelis/archivist",
 	"license": "GPL-3.0",
 	"maintainer": {
@@ -14,7 +14,7 @@
 		"email": "maniackc_dev@crudelis.fr"
 	},
 	"requirements": {
-		"yunohost": ">= 3.4"
+		"yunohost": ">= 3.5.0"
 	},
 	"multi_instance": true,
 	"services": [],
@@ -62,6 +62,7 @@
 			},
 			{
 				"name": "frequency",
+				"type": "string",
 				"ask": {
 					"en": "Choose the frequency of your backups ?",
 					"fr": "Choississez la fréquence de votre backup ?"

+ 12 - 354
scripts/_common.sh

@@ -1,5 +1,9 @@
 #!/bin/bash
 
+#=================================================
+# PERSONAL HELPERS
+#=================================================
+
 #=================================================
 # BACKUP
 #=================================================
@@ -27,7 +31,12 @@ CHECK_SIZE () {	# Vérifie avant chaque backup que l'espace est suffisant
 #=================================================
 
 IS_PACKAGE_CHECK () {
-	return $(env | grep -c container=lxc)
+	if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
+	then
+		return 0
+	else
+		return 1
+	fi
 }
 
 #=================================================
@@ -129,359 +138,6 @@ ynh_multimedia_addaccess () {
 	usermod -a -G multimedia $user_name
 }
 
-#=================================================
-
-# Create a dedicated fail2ban config (jail and filter conf files)
-#
-# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
-# | arg: -l, --logpath= - Log file to be checked by fail2ban
-# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
-# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
-# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
-ynh_add_fail2ban_config () {
-	# Declare an array to define the options of this helper.
-	declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
-	local logpath
-	local failregex
-	local max_retry
-	local ports
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-	max_retry=${max_retry:-3}
-	ports=${ports:-http,https}
-
-	test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
-	test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
-
-	finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
-	finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
-	ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
-	ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
-
-	tee $finalfail2banjailconf <<EOF
-[$app]
-enabled = true
-port = $ports
-filter = $app
-logpath = $logpath
-maxretry = $max_retry
-EOF
-
-  tee $finalfail2banfilterconf <<EOF
-[INCLUDES]
-before = common.conf
-[Definition]
-failregex = $failregex
-ignoreregex =
-EOF
-
-	ynh_store_file_checksum "$finalfail2banjailconf"
-	ynh_store_file_checksum "$finalfail2banfilterconf"
-
-	if [ "$(lsb_release --codename --short)" != "jessie" ]; then
-		systemctl reload fail2ban
-	else
-		systemctl restart fail2ban
-	fi
-	local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
-	if [ -n "$fail2ban_error" ]
-	then
-		echo "[ERR] Fail2ban failed to load the jail for $app" >&2
-		echo "WARNING${fail2ban_error#*WARNING}" >&2
-	fi
-}
-
-# Remove the dedicated fail2ban config (jail and filter conf files)
-#
-# usage: ynh_remove_fail2ban_config
-ynh_remove_fail2ban_config () {
-	ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
-	ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
-	if [ "$(lsb_release --codename --short)" != "jessie" ]; then
-		systemctl reload fail2ban
-	else
-		systemctl restart fail2ban
-	fi
-}
-
-#=================================================
-
-# Read the value of a key in a ynh manifest file
-#
-# usage: ynh_read_manifest manifest key
-# | arg: -m, --manifest= - Path of the manifest to read
-# | arg: -k, --key= - Name of the key to find
-ynh_read_manifest () {
-	# Declare an array to define the options of this helper.
-	declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
-	local manifest
-	local manifest_key
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-
-	python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])"
-}
-
-# Read the upstream version from the manifest
-# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
-# For example : 4.3-2~ynh3
-# This include the number before ~ynh
-# In the last example it return 4.3-2
-#
-# usage: ynh_app_upstream_version [-m manifest]
-# | arg: -m, --manifest= - Path of the manifest to read
-ynh_app_upstream_version () {
-	declare -Ar args_array=( [m]=manifest= )
-	local manifest
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-
-	manifest="${manifest:-../manifest.json}"
-	if [ ! -e "$manifest" ]; then
-		manifest="../settings/manifest.json"	# Into the restore script, the manifest is not at the same place
-	fi
-	version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
-	echo "${version_key/~ynh*/}"
-}
-
-# Read package version from the manifest
-# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
-# For example : 4.3-2~ynh3
-# This include the number after ~ynh
-# In the last example it return 3
-#
-# usage: ynh_app_package_version [-m manifest]
-# | arg: -m, --manifest= - Path of the manifest to read
-ynh_app_package_version () {
-	declare -Ar args_array=( [m]=manifest= )
-	local manifest
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-
-	manifest="${manifest:-../manifest.json}"
-	if [ ! -e "$manifest" ]; then
-		manifest="../settings/manifest.json"	# Into the restore script, the manifest is not at the same place
-	fi
-	version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
-	echo "${version_key/*~ynh/}"
-}
-
-# Checks the app version to upgrade with the existing app version and returns:
-# - UPGRADE_APP if the upstream app version has changed
-# - UPGRADE_PACKAGE if only the YunoHost package has changed
-#
-## It stops the current script without error if the package is up-to-date
-#
-# This helper should be used to avoid an upgrade of an app, or the upstream part
-# of it, when it's not needed
-#
-# To force an upgrade, even if the package is up to date,
-# you have to set the variable YNH_FORCE_UPGRADE before.
-# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
-#
-# usage: ynh_check_app_version_changed
-ynh_check_app_version_changed () {
-	local force_upgrade=${YNH_FORCE_UPGRADE:-0}
-	local package_check=${PACKAGE_CHECK_EXEC:-0}
-
-	# By default, upstream app version has changed
-	local return_value="UPGRADE_APP"
-
-	local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
-	local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
-	local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
-	local update_upstream_version="$(ynh_app_upstream_version)"
-
-	if [ "$current_version" == "$update_version" ] ; then
-		# Complete versions are the same
-		if [ "$force_upgrade" != "0" ]
-		then
-			echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
-			unset YNH_FORCE_UPGRADE
-		elif [ "$package_check" != "0" ]
-		then
-			echo "Upgrade forced for package check." >&2
-		else
-			ynh_die "Up-to-date, nothing to do" 0
-		fi
-	elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
-		# Upstream versions are the same, only YunoHost package versions differ
-		return_value="UPGRADE_PACKAGE"
-	fi
-	echo $return_value
-}
-
-#=================================================
-
-# Start (or other actions) a service,  print a log in case of failure and optionnaly wait until the service is completely started
-#
-# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
-# | arg: -n, --service_name= - Name of the service to reload. Default : $app
-# | arg: -a, --action=       - Action to perform with systemctl. Default: start
-# | arg: -l, --line_match=   - Line to match - The line to find in the log to attest the service have finished to boot.
-#                              If not defined it don't wait until the service is completely started.
-# | arg: -p, --log_path=     - Log file - Path to the log file. Default : /var/log/$app/$app.log
-# | arg: -t, --timeout=      - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
-# | arg: -e, --length=       - Length of the error log : Default : 20
-ynh_systemd_action() {
-	# Declare an array to define the options of this helper.
-	declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
-	local service_name
-	local action
-	local line_match
-	local length
-	local log_path
-	local timeout
-
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-
-	local service_name="${service_name:-$app}"
-	local action=${action:-start}
-	local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
-	local length=${length:-20}
-	local timeout=${timeout:-300}
-
-	# Start to read the log
-	if [[ -n "${line_match:-}" ]]
-	then
-		local templog="$(mktemp)"
-	# Following the starting of the app in its log
-	if [ "$log_path" == "systemd" ] ; then
-		# Read the systemd journal
-		journalctl -u $service_name -f --since=-45 > "$templog" &
-	else
-		# Read the specified log file
-		tail -F -n0 "$log_path" > "$templog" &
-	fi
-		# Get the PID of the tail command
-		local pid_tail=$!
-	fi
-
-	echo "${action^} the service $service_name" >&2
-	systemctl $action $service_name \
-		|| ( journalctl --lines=$length -u $service_name >&2 \
-		; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
-		; false )
-
-	# Start the timeout and try to find line_match
-	if [[ -n "${line_match:-}" ]]
-	then
-		local i=0
-		for i in $(seq 1 $timeout)
-		do
-			# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
-			if grep --quiet "$line_match" "$templog"
-			then
-				echo "The service $service_name has correctly started." >&2
-				break
-			fi
-			echo -n "." >&2
-			sleep 1
-		done
-		if [ $i -eq $timeout ]
-		then
-			echo "The service $service_name didn't fully started before the timeout." >&2
-			echo "Please find here an extract of the end of the log of the service $service_name:"
-			journalctl --lines=$length -u $service_name >&2
-			test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
-		fi
-
-		echo ""
-		ynh_clean_check_starting
-	fi
-}
-
-# Clean temporary process and file used by ynh_check_starting
-# (usually used in ynh_clean_setup scripts)
-#
-# usage: ynh_clean_check_starting
-ynh_clean_check_starting () {
-	# Stop the execution of tail.
-	kill -s 15 $pid_tail 2>&1
-	ynh_secure_remove "$templog" 2>&1
-}
-
-#=================================================
-
-# Print a message as INFO and show progression during an app script
-#
-# usage: ynh_script_progression --message=message [--weight=weight] [--time]
-# | arg: -m, --message= - The text to print
-# | arg: -w, --weight=  - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.
-# | arg: -t, --time=    - Print the execution time since the last call to this helper. Especially usefull to define weights.
-# | arg: -l, --last=    - Use for the last call of the helper, to fill te progression bar.
-increment_progression=0
-previous_weight=0
-# Define base_time when the file is sourced
-base_time=$(date +%s)
-ynh_script_progression () {
-	# Declare an array to define the options of this helper.
-	declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last )
-	local message
-	local weight
-	local time
-	local last
-	# Manage arguments with getopts
-	ynh_handle_getopts_args "$@"
-	weight=${weight:-1}
-	time=${time:-0}
-	last=${last:-0}
-
-	# Get execution time since the last $base_time
-	local exec_time=$(( $(date +%s) - $base_time ))
-	base_time=$(date +%s)
-
-	# Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented.
-	local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)"
-	# Get the number of call with a weight value
-	local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0)
-
-	# Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight
-	local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')"
-	# Get the weight of each occurrences of 'ynh_script_progression' in the script using -w
-	local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')"
-	# Each value will be on a different line.
-	# Remove each 'end of line' and replace it by a '+' to sum the values.
-	local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 ))
-
-	# max_progression is a total number of calls to this helper.
-	#    Less the number of calls with a weight value.
-	#    Plus the total of weight values
-	local max_progression=$(( $helper_calls - $weight_calls + $weight_values ))
-
-	# Increment each execution of ynh_script_progression in this script by the weight of the previous call.
-	increment_progression=$(( $increment_progression + $previous_weight ))
-	# Store the weight of the current call in $previous_weight for next call
-	previous_weight=$weight
-
-	# Set the scale of the progression bar
-	local scale=20
-	# progress_string(1,2) should have the size of the scale.
-	local progress_string1="####################"
-	local progress_string0="...................."
-
-	# Reduce $increment_progression to the size of the scale
-	if [ $last -eq 0 ]
-	then
-		local effective_progression=$(( $increment_progression * $scale / $max_progression ))
-	# If last is specified, fill immediately the progression_bar
-	else
-		local effective_progression=$scale
-	fi
-
-	# Build $progression_bar from progress_string(1,2) according to $effective_progression
-	local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}"
-
-	local print_exec_time=""
-	if [ $time -eq 1 ]
-	then
-		print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]"
-	fi
-
-	ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
-}
-
 #=================================================
 # EXPERIMENTAL HELPERS
 #=================================================
@@ -660,6 +316,8 @@ ynh_maintenance_mode_ON () {
 		domain=$(ynh_app_setting_get $app domain)
 	fi
 
+	mkdir -p /var/www/html/
+	
 	# Create an html to serve as maintenance notice
 	echo "<!DOCTYPE html>
 <html>

+ 4 - 5
scripts/actions/clean_backups

@@ -12,11 +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}
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # CHECK IF ARGUMENTS ARE CORRECT
@@ -31,7 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path)
 #=================================================
 # CLEAN ALL BACKUP FILES
 #=================================================
-ynh_script_progression --message="Clean all backup files" --weight=9
+ynh_script_progression --message="Cleaning all backup files..." --weight=9
 
 # Get the backup directory from the config file
 backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
@@ -40,8 +39,8 @@ while read directory <&3
 do
 	if [ -n "$directory" ]
 	then
-		ynh_print_info "Clean backup directory $directory" >&2
-		ynh_secure_remove "$directory"
+		ynh_print_info --message="Clean backup directory $directory"
+		ynh_secure_remove --file="$directory"
 	fi
 done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
 

+ 2 - 3
scripts/actions/force_backup

@@ -12,11 +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}
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # CHECK IF ARGUMENTS ARE CORRECT
@@ -31,7 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path)
 #=================================================
 # FORCE A NEW BACKUP
 #=================================================
-ynh_script_progression --message="Force a new backup" --weight=9
+ynh_script_progression --message="Forcing a new backup..." --weight=9
 
 ynh_exec_warn nice -n10 $final_path/archivist.sh
 

+ 13 - 14
scripts/actions/reset_default_config

@@ -12,13 +12,12 @@ source /usr/share/yunohost/helpers
 #=================================================
 # RETRIEVE ARGUMENTS
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-final_path=$(ynh_app_setting_get $app final_path)
-encrypt=$(ynh_app_setting_get $app encrypt)
-core_backup=$(ynh_app_setting_get $app core_backup)
-apps_backup=$(ynh_app_setting_get $app apps_backup)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+encrypt=$(ynh_app_setting_get --app=$app --key=encrypt)
+core_backup=$(ynh_app_setting_get --app=$app --key=core_backup)
+apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
 
 #=================================================
 # SORT OUT THE CONFIG FILE TO HANDLE
@@ -35,10 +34,10 @@ fi
 #=================================================
 # RESET THE CONFIG FILE
 #=================================================
-ynh_script_progression --message="Reset the config file $file"
+ynh_script_progression --message="Reseting the config file $file"
 
 # 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" = "Backup_list.conf" ]
 then
@@ -48,8 +47,8 @@ then
 	# Recreate the default config
 	backup_dir="/home/yunohost.app/${app}/backup"
 	enc_backup_dir="/home/yunohost.app/${app}/encrypted_backup"
-	ynh_replace_string "^backup_dir=.*" "backup_dir=$backup_dir" "$config_file"
-	ynh_replace_string "^enc_backup_dir=.*" "enc_backup_dir=$enc_backup_dir" "$config_file"
+	ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
+	ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
 
 	if [ $encrypt -eq 1 ]
 	then
@@ -59,8 +58,8 @@ then
 		encrypt=false
 		passkey=na
 	fi
-	ynh_replace_string "^encrypt=.*" "encrypt=$encrypt" "$config_file"
-	ynh_replace_string "^cryptpass=.*" "cryptpass=$passkey" "$config_file"
+	ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
+	ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
 
 	if [ $core_backup -eq 1 ]
 	then
@@ -68,20 +67,20 @@ then
 	else
 		core_backup=false
 	fi
-	ynh_replace_string "^ynh_core_backup=.*" "ynh_core_backup=$core_backup" "$config_file"
+	ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
 
 	if [ $apps_backup -eq 1 ]
 	then
 		# Add all current applications to the backup
 		while read backup_app
 		do
-			ynh_replace_string "^ynh_app_backup=$" "ynh_app_backup=$backup_app\n&" "$config_file"
+			ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
 		done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
 	fi
 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

+ 8 - 9
scripts/backup

@@ -19,39 +19,38 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings"
+ynh_script_progression --message="Loading installation settings..."
 
 app=$YNH_APP_INSTANCE_NAME
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # STANDARD BACKUP STEPS
 #=================================================
 # BACKUP THE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Backup the app main dir"
+ynh_script_progression --message="Backing up the main app directory..."
 
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
 
 #=================================================
 # SPECIFIC BACKUP
 #=================================================
 # BACKUP LOGROTATE
 #=================================================
-ynh_script_progression --message="Backup logrotate configuration"
+ynh_script_progression --message="Backing up logrotate configuration..."
 
-ynh_backup "/etc/logrotate.d/$app"
+ynh_backup --src_path="/etc/logrotate.d/$app"
 
 #=================================================
 # BACKUP THE CRON FILE
 #=================================================
-ynh_script_progression --message="Backup cron file"
 
-ynh_backup "/etc/cron.d/$app"
+ynh_backup --src_path="/etc/cron.d/$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

+ 12 - 12
scripts/config

@@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
 
 app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # SPECIFIC CODE
@@ -106,20 +106,20 @@ apply_config() {
 	# Change the password if needed
 	if [ "$encrypt" = "true" ]; then
 		ynh_print_OFF
-		test -n "$encrypt_password" || ynh_die "The password for encryption can't be empty if you choose to enable encryption."
+		test -n "$encrypt_password" || ynh_die --message="The password for encryption can't be empty if you choose to enable encryption."
 		ynh_print_ON
 		# Replace the password by the previous one
 		passkey="$final_path/passkey"
 		ynh_print_OFF; echo "$encrypt_password" > "$passkey"; ynh_print_ON
 		chmod 400 "$passkey"
-		ynh_replace_string "^cryptpass=.*" "cryptpass=$passkey" "$config_file"
+		ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
 	fi
 
 	# Change encrypt in the config file
-	ynh_replace_string "^encrypt=.*" "encrypt=$encrypt" "$config_file"
+	ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
 
 	# Change ynh_core_backup in the config file
-	ynh_replace_string "^ynh_core_backup=.*" "ynh_core_backup=$ynh_core_backup" "$config_file"
+	ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$ynh_core_backup" --target_file="$config_file"
 
 	# Change ynh_app_backup in the config file
 	if [ "$ynh_app_backup" = "true" ] && [ "$old_ynh_app_backup" = "false" ]
@@ -128,8 +128,8 @@ apply_config() {
 		# Add all current applications to the backup
 		while read backup_app
 		do
-			ynh_print_info "Add a backup for the app $backup_app." >&2
-			ynh_replace_string "^ynh_app_backup=$" "ynh_app_backup=$backup_app\n&" "$config_file"
+			ynh_print_info --message="Add a backup for the app $backup_app."
+			ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
 		done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
 	elif [ "$ynh_app_backup" = "false" ] && [ "$old_ynh_app_backup" = "true" ]
 	then
@@ -139,7 +139,7 @@ apply_config() {
 	fi
 
 	# Change frequency in the cron file and store the value into the settings
-	ynh_app_setting_set $app frequency "$frequency"
+	ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
 	if [ "$frequency" = "Daily" ]; then
 		cron_freq="0 2 * * *"
 		run_freq="every day"
@@ -156,18 +156,18 @@ apply_config() {
 		cron_freq="0 2 1 * *"
 		run_freq="once a month on the first sunday"
 	fi
-	ynh_replace_string ".* root" "$cron_freq root" /etc/cron.d/$app
+	ynh_replace_string --match_string=".* root" --replace_string="$cron_freq root" --target_file=/etc/cron.d/$app
 
 	# Change max_size in the config file
-	ynh_replace_string "^max_size=.*" "max_size=$max_size" "$config_file"
+	ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$config_file"
 
 	# Set overwrite_cron
 	overwrite_cron=$(bool_to_01 $overwrite_cron)
-	ynh_app_setting_set $app overwrite_cron "$overwrite_cron"
+	ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
 
 	# 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"
 }
 
 #=================================================

+ 35 - 37
scripts/install

@@ -21,7 +21,6 @@ ynh_abort_if_errors
 #=================================================
 # RETRIEVE ARGUMENTS FROM THE MANIFEST
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 encrypt=$YNH_APP_ARG_ENCRYPT
 ynh_print_OFF; encryption_pwd=$YNH_APP_ARG_ENCRYPTION_PWD; ynh_print_ON
@@ -34,36 +33,36 @@ app=$YNH_APP_INSTANCE_NAME
 #=================================================
 # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
 #=================================================
-ynh_script_progression --message="Check if the app can be installed"
+ynh_script_progression --message="Validating installation parameters..."
 
 final_path=/opt/yunohost/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
 
 if [ $encrypt -eq 1 ]; then
 	ynh_print_OFF
-	test -n "$encryption_pwd" || ynh_die "encryption_pwd can't be empty if you choose to enable encryption."
+	test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
 	ynh_print_ON
 fi
 
 #=================================================
 # 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 frequency "$frequency"
-ynh_app_setting_set $app encrypt "$encrypt"
-ynh_app_setting_set $app core_backup "$core_backup"
-ynh_app_setting_set $app apps_backup "$apps_backup"
+ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
+ynh_app_setting_set --app=$app --key=encrypt --value="$encrypt"
+ynh_app_setting_set --app=$app --key=core_backup --value="$core_backup"
+ynh_app_setting_set --app=$app --key=apps_backup --value="$apps_backup"
 
-ynh_app_setting_set $app overwrite_cron "1"
-ynh_app_setting_set $app admin_mail_html "1"
+ynh_app_setting_set --app=$app --key=overwrite_cron --value=1
+ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
 
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
 # INSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Install dependencies" --weight=15
+ynh_script_progression --message="Installing dependencies..." --weight=15
 
 # Valid the fucking debconf message
 # To find this, install the package, install also debconf-utils
@@ -74,11 +73,11 @@ ynh_install_app_dependencies $app_depencencies
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
-ynh_script_progression --message="Download, check and unpack source" --weight=3
+ynh_script_progression --message="Setting up source files..." --weight=3
 
-ynh_app_setting_set $app final_path $final_path
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
 # Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+ynh_setup_source --dest_dir="$final_path"
 
 #=================================================
 # SPECIFIC SETUP
@@ -93,13 +92,13 @@ mkdir -p "$backup_dir"
 #=================================================
 # CONFIGURE ARCHIVIST
 #=================================================
-ynh_script_progression --message="Configure Archivist" --weight=2
+ynh_script_progression --message="Configuring Archivist..." --weight=2
 
 config_file="$final_path/Backup_list.conf"
 cp "$final_path/Backup_list.conf.default" "$config_file"
 
-ynh_replace_string "^backup_dir=.*" "backup_dir=$backup_dir" "$config_file"
-ynh_replace_string "^enc_backup_dir=.*" "enc_backup_dir=$enc_backup_dir" "$config_file"
+ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
+ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
 
 if [ $encrypt -eq 1 ]
 then
@@ -112,8 +111,8 @@ else
 	encrypt=false
 	passkey=na
 fi
-ynh_replace_string "^encrypt=.*" "encrypt=$encrypt" "$config_file"
-ynh_replace_string "^cryptpass=.*" "cryptpass=$passkey" "$config_file"
+ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
+ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
 
 if [ $core_backup -eq 1 ]
 then
@@ -121,19 +120,19 @@ then
 else
 	core_backup=false
 fi
-ynh_replace_string "^ynh_core_backup=.*" "ynh_core_backup=$core_backup" "$config_file"
+ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
 
 if [ $apps_backup -eq 1 ]
 then
 	# Add all current applications to the backup
 	while read backup_app
 	do
-		ynh_replace_string "^ynh_app_backup=$" "ynh_app_backup=$backup_app\n&" "$config_file"
+		ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
 	done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
 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"
 
 #=================================================
 # STRETCH COMPATIBILITY
@@ -141,18 +140,18 @@ ynh_store_file_checksum "$config_file"
 
 if is_stretch
 then
-	ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
-	ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-apps" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-system" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
 fi
 
 #=================================================
 # SET THE CRON FILE
 #=================================================
-ynh_script_progression --message="Set the cron file"
+ynh_script_progression --message="Configuring the cron file..."
 
 cp ../conf/cron /etc/cron.d/$app
-ynh_replace_string "__FINALPATH__" "$final_path" /etc/cron.d/$app
-ynh_replace_string "__APP__" "$app" /etc/cron.d/$app
+ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
+ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
 if [ "$frequency" = "Daily" ]; then
 	cron_freq="0 2 * * *"
 	run_freq="every day"
@@ -169,10 +168,10 @@ else	# Monthly
 	cron_freq="0 2 1 * *"
 	run_freq="once a month on the first sunday"
 fi
-ynh_replace_string "__FREQUENCY__" "$cron_freq" /etc/cron.d/$app
+ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
 
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "/etc/cron.d/$app"
+ynh_store_file_checksum --file="/etc/cron.d/$app"
 
 #=================================================
 # GENERIC FINALIZATION
@@ -186,7 +185,7 @@ chown -R root: $final_path
 #=================================================
 # SETUP LOGROTATE
 #=================================================
-ynh_script_progression --message="Configure logrotate"
+ynh_script_progression --message="Configuring log rotation..."
 
 mkdir -p /var/log/$app
 # Use logrotate to manage application logfile(s)
@@ -196,10 +195,10 @@ ynh_use_logrotate
 # PRINT INFORMATION
 #=================================================
 
-Informations="To add recipients or to modify the files or apps to backup,
+Informations="
+To add recipients or to modify the files or apps to backup,
 please have a look to the config file $config_file"
-ynh_print_info "
-$Informations" >&2
+ynh_print_info --message="$Informations"
 
 #=================================================
 # SEND A README FOR THE ADMIN
@@ -222,7 +221,6 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
 ynh_print_OFF
 echo "${encrypt_message}Archivist is going to run $run_freq.
 If you want to change the frequency, have a look to the file /etc/cron.d/$app.
-
 $Informations
 Please read the __URL_TAG1__documentation__URL_TAG2__https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md__URL_TAG3__ about the configuration of archivist for more information.
 
@@ -232,10 +230,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/archivist_ynh__URL_TAG3__." > mail_to_send
 ynh_print_ON
 
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="install"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Installation completed" --last
+ynh_script_progression --message="Installation of $app completed" --last

+ 10 - 10
scripts/remove

@@ -12,18 +12,18 @@ 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
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # STANDARD REMOVE
 #=================================================
 # 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
@@ -31,15 +31,15 @@ ynh_remove_app_dependencies
 #=================================================
 # REMOVE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Remove app main directory"
+ynh_script_progression --message="Removing app main directory..."
 
 # Remove the app directory securely
-ynh_secure_remove "$final_path"
+ynh_secure_remove --file="$final_path"
 
 #=================================================
 # REMOVE LOGROTATE CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove logrotate configuration"
+ynh_script_progression --message="Removing logrotate configuration..."
 
 # Remove the app-specific logrotate config
 ynh_remove_logrotate
@@ -51,15 +51,15 @@ ynh_remove_logrotate
 #=================================================
 
 # Remove a cron file
-ynh_secure_remove "/etc/cron.d/$app"
+ynh_secure_remove --file="/etc/cron.d/$app"
 
-ynh_script_progression --message="Remove backup directory" --weight=5
+ynh_script_progression --message="Removing backup directory..." --weight=5
 
 # Remove the backup directory
-ynh_secure_remove "/home/yunohost.app/${app}/backup"
+ynh_secure_remove --file="/home/yunohost.app/$app/backup"
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Deletion completed" --last
+ynh_script_progression --message="Removal of $app completed" --last

+ 13 - 12
scripts/restore

@@ -21,27 +21,28 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings"
+ynh_script_progression --message="Loading settings..."
 
 app=$YNH_APP_INSTANCE_NAME
 
-final_path=$(ynh_app_setting_get $app final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # CHECK IF THE APP CAN BE RESTORED
 #=================================================
+ynh_script_progression --message="Validating restoration parameters..."
 
 test ! -d $final_path \
-	|| ynh_die "There is already a directory: $final_path "
+	|| ynh_die --message="There is already a directory: $final_path "
 
 #=================================================
 # STANDARD RESTORATION STEPS
 #=================================================
 # RESTORE THE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Restore the app main directory"
+ynh_script_progression --message="Restoring the app main directory..."
 
-ynh_restore_file "$final_path"
+ynh_restore_file --origin_path="$final_path"
 
 #=================================================
 # STRETCH COMPATIBILITY
@@ -49,8 +50,8 @@ ynh_restore_file "$final_path"
 
 if is_stretch
 then
-	ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
-	ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-apps" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-system" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
 fi
 
 #=================================================
@@ -58,7 +59,7 @@ fi
 #=================================================
 # REINSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Reinstall dependencies" --weight=17
+ynh_script_progression --message="Reinstalling dependencies..." --weight=17
 
 # Valid the fucking debconf message
 # To find this, install the package, install also debconf-utils
@@ -71,13 +72,13 @@ ynh_install_app_dependencies $app_depencencies
 #=================================================
 
 mkdir -p /var/log/$app
-ynh_restore_file "/etc/logrotate.d/$app"
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
 
 #=================================================
 # RESTORE THE CRON FILE
 #=================================================
 
-ynh_restore_file "/etc/cron.d/$app"
+ynh_restore_file --origin_path="/etc/cron.d/$app"
 
 #=================================================
 # RECREATE DIRECTORIES
@@ -102,10 +103,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/archivist_ynh__URL_TAG3__." > mail_to_send
 
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Restoration completed" --last
+ynh_script_progression --message="Restoration completed for $app" --last

+ 29 - 29
scripts/upgrade

@@ -14,16 +14,16 @@ 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
 
-final_path=$(ynh_app_setting_get $app final_path)
-frequency="$(ynh_app_setting_get $app frequency)"
-encrypt=$(ynh_app_setting_get $app encrypt)
-core_backup=$(ynh_app_setting_get $app core_backup)
-apps_backup=$(ynh_app_setting_get $app apps_backup)
-overwrite_cron=$(ynh_app_setting_get $app overwrite_cron)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+frequency="$(ynh_app_setting_get --app=$app --key=frequency)"
+encrypt=$(ynh_app_setting_get --app=$app --key=encrypt)
+core_backup=$(ynh_app_setting_get --app=$app --key=core_backup)
+apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
+overwrite_cron=$(ynh_app_setting_get --app=$app --key=overwrite_cron)
 
 #=================================================
 # CHECK VERSION
@@ -34,7 +34,7 @@ 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 encrypt doesn't exist, create it
 if [ -z "$encrypt" ]; then
@@ -44,38 +44,38 @@ if [ -z "$encrypt" ]; then
 	else
 		encrypt=0
 	fi
-	ynh_app_setting_set $app encrypt $encrypt
+	ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
 fi
 
 # If core_backup doesn't exist, create it
 if [ -z "$core_backup" ]; then
 	core_backup="$(grep "^ynh_core_backup=" "$final_path/Backup_list.conf" | cut -d= -f2)"
-	ynh_app_setting_set $app core_backup $core_backup
+	ynh_app_setting_set --app=$app --key=core_backup --value=$core_backup
 fi
 
 # If apps_backup doesn't exist, create it
 if [ -z "$apps_backup" ]; then
 	apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$final_path/Backup_list.conf")"
-	ynh_app_setting_set $app apps_backup $apps_backup
+	ynh_app_setting_set --app=$app --key=apps_backup --value=$apps_backup
 fi
 
 # If overwrite_cron doesn't exist, create it
 if [ -z "$overwrite_cron" ]; then
 	overwrite_cron=1
-	ynh_app_setting_set $app overwrite_cron $overwrite_cron
+	ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
 fi
 
-admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
+admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
 # If admin_mail_html doesn't exist, create it
 if [ -z "$admin_mail_html" ]; then
 	admin_mail_html=1
-	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
 fi
 
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 #=================================================
-ynh_script_progression --message="Backup the app before upgrading" --weight=2
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
 
 # Backup the current version of the app
 ynh_backup_before_upgrade
@@ -94,15 +94,15 @@ ynh_abort_if_errors
 
 if [ "$upgrade_type" == "UPGRADE_APP" ]
 then
-	ynh_script_progression --message="Download, check and unpack source" --weight=2
+	ynh_script_progression --message="Upgrading source files..." --weight=2
 	# Download, check integrity, uncompress and patch the source from app.src
-	ynh_setup_source "$final_path"
+	ynh_setup_source --dest_dir="$final_path"
 fi
 
 #=================================================
 # UPGRADE DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Upgrade dependencies" --weight=8
+ynh_script_progression --message="Upgrading dependencies..." --weight=8
 
 ynh_install_app_dependencies $app_depencencies
 
@@ -114,24 +114,24 @@ ynh_install_app_dependencies $app_depencencies
 
 if is_stretch
 then
-	ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
-	ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-apps" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
+	ynh_replace_string --match_string="yunohost backup create --ignore-system" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
 fi
 
 #=================================================
 # UPDATE THE CRON FILE
 #=================================================
-ynh_script_progression --message="Update the cron file"
+ynh_script_progression --message="Updating the cron file..."
 
 # Overwrite the cron file only if it's allowed
 if [ $overwrite_cron -eq 1 ]
 then
 	# Verify the checksum and backup the file if it's different
-	ynh_backup_if_checksum_is_different "/etc/cron.d/$app"
+	ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
 
 	cp ../conf/cron /etc/cron.d/$app
-	ynh_replace_string "__FINALPATH__" "$final_path" /etc/cron.d/$app
-	ynh_replace_string "__APP__" "$app" /etc/cron.d/$app
+	ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
+	ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
 	if [ "$frequency" = "Daily" ]; then
 		cron_freq="0 2 * * *"
 		run_freq="every day"
@@ -148,16 +148,16 @@ then
 		cron_freq="0 2 1 * *"
 		run_freq="once a month on the first sunday"
 	fi
-	ynh_replace_string "__FREQUENCY__" "$cron_freq" /etc/cron.d/$app
+	ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
 
 	# Recalculate and store the config file checksum into the app settings
-	ynh_store_file_checksum "/etc/cron.d/$app"
+	ynh_store_file_checksum --file="/etc/cron.d/$app"
 fi
 
 #=================================================
 # SETUP LOGROTATE
 #=================================================
-ynh_script_progression --message="Reconfigure logrotate"
+ynh_script_progression --message="Upgrading logrotate configuration..."
 
 # Use logrotate to manage app-specific logfile(s)
 ynh_use_logrotate --non-append
@@ -196,10 +196,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="root" --type="upgrade"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Upgrade completed" --last
+ynh_script_progression --message="Upgrade of $app completed" --last