--replace -> --full_replace

This commit is contained in:
Alexandre Aubin 2022-10-06 19:38:50 +02:00
parent 37c2f941de
commit 5b3f0440be

View file

@ -63,11 +63,11 @@ ynh_abort_if_errors() {
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
# #
# usage: ynh_setup_source --dest_dir=dest_dir [--source_id=source_id] [--keep="file1 file2"] [--replace] # usage: ynh_setup_source --dest_dir=dest_dir [--source_id=source_id] [--keep="file1 file2"] [--full_replace]
# | arg: -d, --dest_dir= - Directory where to setup sources # | arg: -d, --dest_dir= - Directory where to setup sources
# | arg: -s, --source_id= - Name of the source, defaults to `app` # | arg: -s, --source_id= - Name of the source, defaults to `app`
# | arg: -k, --keep= - Space-separated list of files/folders that will be backup/restored in $dest_dir, such as a config file you don't want to overwrite. For example 'conf.json secrets.json logs/' # | arg: -k, --keep= - Space-separated list of files/folders that will be backup/restored in $dest_dir, such as a config file you don't want to overwrite. For example 'conf.json secrets.json logs/'
# | arg: -r, --replace= - Remove previous sources before installing new sources # | arg: -r, --full_replace= - Remove previous sources before installing new sources
# #
# This helper will read `conf/${source_id}.src`, download and install the sources. # This helper will read `conf/${source_id}.src`, download and install the sources.
# #
@ -103,16 +103,16 @@ ynh_abort_if_errors() {
ynh_setup_source() { ynh_setup_source() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=dsk local legacy_args=dsk
local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=replace=) local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=full_replace=)
local dest_dir local dest_dir
local source_id local source_id
local keep local keep
local replace local full_replace
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
source_id="${source_id:-app}" source_id="${source_id:-app}"
keep="${keep:-}" keep="${keep:-}"
replace="${replace:-0}" full_replace="${full_replace:-0}"
local src_file_path="$YNH_APP_BASEDIR/conf/${source_id}.src" local src_file_path="$YNH_APP_BASEDIR/conf/${source_id}.src"
@ -175,7 +175,7 @@ ynh_setup_source() {
done done
fi fi
if [ "$replace" -eq 1 ]; then if [ "$full_replace" -eq 1 ]; then
ynh_secure_remove --file="$dest_dir" ynh_secure_remove --file="$dest_dir"
fi fi