mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix a bunch of inconsistency or variable not properly replaced between final_path/install_dir
This commit is contained in:
parent
6d4659a782
commit
7d9984c109
5 changed files with 39 additions and 33 deletions
|
@ -22,7 +22,7 @@ _ynh_app_config_get_one() {
|
|||
if [[ "$bind" == "settings" ]]; then
|
||||
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
||||
fi
|
||||
old[$short_setting]="$(ls "$(echo $bind | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)" 2>/dev/null || echo YNH_NULL)"
|
||||
old[$short_setting]="$(ls "$(echo $bind | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)" 2>/dev/null || echo YNH_NULL)"
|
||||
file_hash[$short_setting]="true"
|
||||
|
||||
# Get multiline text from settings or from a full file
|
||||
|
@ -32,7 +32,7 @@ _ynh_app_config_get_one() {
|
|||
elif [[ "$bind" == *":"* ]]; then
|
||||
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||
else
|
||||
old[$short_setting]="$(cat $(echo $bind | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/) 2>/dev/null || echo YNH_NULL)"
|
||||
old[$short_setting]="$(cat $(echo $bind | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/) 2>/dev/null || echo YNH_NULL)"
|
||||
fi
|
||||
|
||||
# Get value from a kind of key/value file
|
||||
|
@ -47,7 +47,7 @@ _ynh_app_config_get_one() {
|
|||
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||
fi
|
||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
old[$short_setting]="$(ynh_read_var_in_file --file="${bind_file}" --key="${bind_key_}" --after="${bind_after}")"
|
||||
|
||||
fi
|
||||
|
@ -73,7 +73,7 @@ _ynh_app_config_apply_one() {
|
|||
if [[ "$bind" == "settings" ]]; then
|
||||
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
||||
fi
|
||||
local bind_file="$(echo "$bind" | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
if [[ "${!short_setting}" == "" ]]; then
|
||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||
ynh_secure_remove --file="$bind_file"
|
||||
|
@ -98,7 +98,7 @@ _ynh_app_config_apply_one() {
|
|||
if [[ "$bind" == *":"* ]]; then
|
||||
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||
fi
|
||||
local bind_file="$(echo "$bind" | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||
echo "${!short_setting}" >"$bind_file"
|
||||
ynh_store_file_checksum --file="$bind_file" --update_only
|
||||
|
@ -113,7 +113,7 @@ _ynh_app_config_apply_one() {
|
|||
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||
fi
|
||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
||||
|
|
|
@ -474,9 +474,9 @@ YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
|
|||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
|
||||
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$install_dir] --commands="commands"
|
||||
# | arg: -v, --phpversion - PHP version to use with composer
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $install_dir or $final_path
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
#
|
||||
# Requires YunoHost version 4.2 or higher.
|
||||
|
@ -489,7 +489,7 @@ ynh_composer_exec() {
|
|||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
workdir="${workdir:-${install_dir:-$final_path}}"
|
||||
phpversion="${phpversion:-$YNH_PHP_VERSION}"
|
||||
|
||||
COMPOSER_HOME="$workdir/.composer" COMPOSER_MEMORY_LIMIT=-1 \
|
||||
|
|
|
@ -192,6 +192,9 @@ ynh_setup_source() {
|
|||
# Extract source into the app dir
|
||||
mkdir --parents "$dest_dir"
|
||||
|
||||
if [ -n "${install_dir:-}" ] && [ "$dest_dir" == "$install_dir" ]; then
|
||||
_ynh_apply_default_permissions $dest_dir
|
||||
fi
|
||||
if [ -n "${final_path:-}" ] && [ "$dest_dir" == "$final_path" ]; then
|
||||
_ynh_apply_default_permissions $dest_dir
|
||||
fi
|
||||
|
@ -330,7 +333,7 @@ ynh_local_curl() {
|
|||
# | arg: -d, --destination= - Destination of the config file
|
||||
#
|
||||
# examples:
|
||||
# ynh_add_config --template=".env" --destination="$final_path/.env" use the template file "../conf/.env"
|
||||
# ynh_add_config --template=".env" --destination="$install_dir/.env" use the template file "../conf/.env"
|
||||
# ynh_add_config --template="/etc/nginx/sites-available/default" --destination="etc/nginx/sites-available/mydomain.conf"
|
||||
#
|
||||
# The template can be by default the name of a file in the conf directory
|
||||
|
@ -444,8 +447,10 @@ ynh_replace_vars() {
|
|||
ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$file"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$file"
|
||||
fi
|
||||
# Legacy
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$file"
|
||||
ynh_replace_string --match_string="__INSTALL_DIR__" --replace_string="$final_path" --target_file="$file"
|
||||
fi
|
||||
if test -n "${YNH_PHP_VERSION:-}"; then
|
||||
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$YNH_PHP_VERSION" --target_file="$file"
|
||||
|
|
|
@ -1762,6 +1762,7 @@ ynh_app_config_run $1
|
|||
"app": app,
|
||||
"app_instance_nb": str(app_instance_nb),
|
||||
"final_path": settings.get("final_path", ""),
|
||||
"install_dir": settings.get("install_dir", ""),
|
||||
"YNH_APP_BASEDIR": os.path.join(APPS_SETTING_PATH, app),
|
||||
}
|
||||
)
|
||||
|
|
|
@ -18,51 +18,51 @@ _make_dummy_src() {
|
|||
}
|
||||
|
||||
ynhtest_setup_source_nominal() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
install_dir="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="dummy"
|
||||
|
||||
test -e "$final_path"
|
||||
test -e "$final_path/index.html"
|
||||
test -e "$install_dir"
|
||||
test -e "$install_dir/index.html"
|
||||
}
|
||||
|
||||
ynhtest_setup_source_nominal_upgrade() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
install_dir="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="dummy"
|
||||
|
||||
test "$(cat $final_path/index.html)" == "Lorem Ipsum"
|
||||
test "$(cat $install_dir/index.html)" == "Lorem Ipsum"
|
||||
|
||||
# Except index.html to get overwritten during next ynh_setup_source
|
||||
echo "IEditedYou!" > $final_path/index.html
|
||||
test "$(cat $final_path/index.html)" == "IEditedYou!"
|
||||
echo "IEditedYou!" > $install_dir/index.html
|
||||
test "$(cat $install_dir/index.html)" == "IEditedYou!"
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="dummy"
|
||||
|
||||
test "$(cat $final_path/index.html)" == "Lorem Ipsum"
|
||||
test "$(cat $install_dir/index.html)" == "Lorem Ipsum"
|
||||
}
|
||||
|
||||
|
||||
ynhtest_setup_source_with_keep() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
install_dir="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
||||
echo "IEditedYou!" > $final_path/index.html
|
||||
echo "IEditedYou!" > $final_path/test.txt
|
||||
echo "IEditedYou!" > $install_dir/index.html
|
||||
echo "IEditedYou!" > $install_dir/test.txt
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy" --keep="index.html test.txt"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="dummy" --keep="index.html test.txt"
|
||||
|
||||
test -e "$final_path"
|
||||
test -e "$final_path/index.html"
|
||||
test -e "$final_path/test.txt"
|
||||
test "$(cat $final_path/index.html)" == "IEditedYou!"
|
||||
test "$(cat $final_path/test.txt)" == "IEditedYou!"
|
||||
test -e "$install_dir"
|
||||
test -e "$install_dir/index.html"
|
||||
test -e "$install_dir/test.txt"
|
||||
test "$(cat $install_dir/index.html)" == "IEditedYou!"
|
||||
test "$(cat $install_dir/test.txt)" == "IEditedYou!"
|
||||
}
|
||||
|
||||
ynhtest_setup_source_with_patch() {
|
||||
final_path="$(mktemp -d -p $VAR_WWW)"
|
||||
install_dir="$(mktemp -d -p $VAR_WWW)"
|
||||
_make_dummy_src > ../conf/dummy.src
|
||||
|
||||
mkdir -p ../sources/patches
|
||||
|
@ -74,7 +74,7 @@ ynhtest_setup_source_with_patch() {
|
|||
+Lorem Ipsum dolor sit amet
|
||||
EOF
|
||||
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="dummy"
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="dummy"
|
||||
|
||||
test "$(cat $final_path/index.html)" == "Lorem Ipsum dolor sit amet"
|
||||
test "$(cat $install_dir/index.html)" == "Lorem Ipsum dolor sit amet"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue