helpers 2.1: remove unecessary --app=$app in internals ynh_app_setting_get/set calls

This commit is contained in:
Alexandre Aubin 2024-05-27 18:37:38 +02:00
parent b914ad9093
commit 6e13a4db1b
11 changed files with 46 additions and 46 deletions

View file

@ -51,7 +51,7 @@ ynh_install_apps() {
fi
done
ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies"
ynh_app_setting_set --key=apps_dependencies --value="$apps_dependencies"
}
# Remove other YunoHost apps
@ -63,8 +63,8 @@ ynh_install_apps() {
# Requires YunoHost version *.*.* or higher.
ynh_remove_apps() {
# Retrieve the apps dependencies of the app
local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
ynh_app_setting_delete --app=$app --key=apps_dependencies
local apps_dependencies=$(ynh_app_setting_get --key=apps_dependencies)
ynh_app_setting_delete --key=apps_dependencies
if [ ! -z "$apps_dependencies" ]
then
@ -153,7 +153,7 @@ ynh_spawn_app_shell() {
fi
# Make sure the app has an install_dir setting
local install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
local install_dir=$(ynh_app_setting_get --key=install_dir)
if [ -z "$install_dir" ]
then
ynh_print_err --message="$app has no install_dir setting (does it use packaging format >=2?)"
@ -161,7 +161,7 @@ ynh_spawn_app_shell() {
fi
# Load the app's service name, or default to $app
local service=$(ynh_app_setting_get --app=$app --key=service)
local service=$(ynh_app_setting_get --key=service)
[ -z "$service" ] && service=$app;
# Export HOME variable
@ -173,8 +173,8 @@ ynh_spawn_app_shell() {
# Force `php` to its intended version
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
local phpversion=$(ynh_app_setting_get --key=phpversion)
local phpflags=$(ynh_app_setting_get --key=phpflags)
if [ -n "$phpversion" ]
then
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"

View file

@ -266,11 +266,11 @@ ynh_install_app_dependencies() {
dependencies+=", php${specific_php_version}, php${specific_php_version}-fpm, php${specific_php_version}-common"
local old_phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
local old_phpversion=$(ynh_app_setting_get --key=phpversion)
# If the PHP version changed, remove the old fpm conf
if [ -n "$old_phpversion" ] && [ "$old_phpversion" != "$specific_php_version" ]; then
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
local old_php_fpm_config_dir=$(ynh_app_setting_get --key=fpm_config_dir)
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
if [[ -f "$old_php_finalphpconf" ]]
@ -280,7 +280,7 @@ ynh_install_app_dependencies() {
fi
fi
# Store phpversion into the config of this app
ynh_app_setting_set --app=$app --key=phpversion --value=$specific_php_version
ynh_app_setting_set --key=phpversion --value=$specific_php_version
# Set the default php version back as the default version for php-cli.
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
@ -288,7 +288,7 @@ ynh_install_app_dependencies() {
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
fi
elif grep --quiet 'php' <<< "$dependencies"; then
ynh_app_setting_set --app=$app --key=phpversion --value=$YNH_DEFAULT_PHP_VERSION
ynh_app_setting_set --key=phpversion --value=$YNH_DEFAULT_PHP_VERSION
fi
local psql_installed="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"

View file

@ -77,7 +77,7 @@ ynh_backup() {
not_mandatory="${not_mandatory:-0}"
BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0}
test -n "${app:-}" && do_not_backup_data=$(ynh_app_setting_get --app=$app --key=do_not_backup_data)
test -n "${app:-}" && do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
# If backing up core only (used by ynh_backup_before_upgrade),
# don't backup big data items
@ -315,14 +315,14 @@ ynh_store_file_checksum() {
# If update only, we don't save the new checksum if no old checksum exist
if [ $update_only -eq 1 ]; then
local checksum_value=$(ynh_app_setting_get --app=$app --key=$checksum_setting_name)
local checksum_value=$(ynh_app_setting_get --key=$checksum_setting_name)
if [ -z "${checksum_value}" ]; then
unset backup_file_checksum
return 0
fi
fi
ynh_app_setting_set --app=$app --key=$checksum_setting_name --value=$(md5sum "$file" | cut --delimiter=' ' --fields=1)
ynh_app_setting_set --key=$checksum_setting_name --value=$(md5sum "$file" | cut --delimiter=' ' --fields=1)
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
# Using a base64 is in fact more reversible than "replace / and space by _" ... So we can in fact obtain the original file path in an easy reliable way ...
@ -359,7 +359,7 @@ ynh_backup_if_checksum_is_different() {
ynh_handle_getopts_args "$@"
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
local checksum_value=$(ynh_app_setting_get --app=$app --key=$checksum_setting_name)
local checksum_value=$(ynh_app_setting_get --key=$checksum_setting_name)
# backup_file_checksum isn't declare as local, so it can be reuse by ynh_store_file_checksum
backup_file_checksum=""
if [ -n "$checksum_value" ]; then # Proceed only if a value was stored into the app settings
@ -398,7 +398,7 @@ ynh_delete_file_checksum() {
ynh_handle_getopts_args "$@"
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete --app=$app --key=$checksum_setting_name
ynh_app_setting_delete --key=$checksum_setting_name
}
# Checks a backup archive exists

View file

@ -90,7 +90,7 @@ _ynh_app_config_apply_one() {
# Save value in app settings
elif [[ "$bind" == "settings" ]]; then
ynh_app_setting_set --app=$app --key=$short_setting --value="${!short_setting}"
ynh_app_setting_set --key=$short_setting --value="${!short_setting}"
ynh_print_info --message="Configuration key '$short_setting' edited in app settings"
# Save multiline text in a file
@ -120,7 +120,7 @@ _ynh_app_config_apply_one() {
ynh_store_file_checksum --file="$bind_file" --update_only
# We stored the info in settings in order to be able to upgrade the app
ynh_app_setting_set --app=$app --key=$short_setting --value="${!short_setting}"
ynh_app_setting_set --key=$short_setting --value="${!short_setting}"
ynh_print_info --message="Configuration key '$bind_key_' edited into $bind_file"
fi

View file

@ -52,7 +52,7 @@ export GOENV_ROOT="$goenv_install_dir"
#
# Requires YunoHost version 3.2.2 or higher.
ynh_use_go () {
go_version=$(ynh_app_setting_get --app=$app --key=go_version)
go_version=$(ynh_app_setting_get --key=go_version)
# Get the absolute path of this version of Go
go_path="$go_version_path/$go_version/bin"
@ -166,7 +166,7 @@ ynh_install_go () {
goenv install --skip-existing $final_go_version
# Store go_version into the config of this app
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=go_version --value=$final_go_version
ynh_app_setting_set --key=go_version --value=$final_go_version
# Cleanup Go versions
ynh_cleanup_go
@ -188,7 +188,7 @@ eval \"\$(goenv init -)\"
#
# usage: ynh_remove_go
ynh_remove_go () {
local go_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=go_version)
local go_version=$(ynh_app_setting_get --key=go_version)
# Load goenv path in PATH
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
@ -197,7 +197,7 @@ ynh_remove_go () {
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Remove the line for this app
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=go_version
ynh_app_setting_delete --key=go_version
# Cleanup Go versions
ynh_cleanup_go

View file

@ -255,7 +255,7 @@ ynh_mongo_setup_db() {
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
# Store the password in the app's config
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_app_setting_set --key=db_pwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user
@ -321,7 +321,7 @@ ynh_install_mongo() {
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"
# Store mongo_version into the config of this app
ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version
ynh_app_setting_set --key=mongo_version --value=$mongo_version
}
# Remove MongoDB

View file

@ -212,7 +212,7 @@ ynh_mysql_setup_db() {
dpkg --list | grep -q "^ii mariadb-server" || { ynh_print_warn --message="Packager: you called ynh_mysql_setup_db without declaring a dependency to mariadb-server. Please add it to your apt dependencies !"; ynh_apt install mariadb-server; }
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
ynh_app_setting_set --app=$app --key=mysqlpwd --value=$db_pwd
ynh_app_setting_set --key=mysqlpwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user

View file

@ -50,7 +50,7 @@ export N_PREFIX="$n_install_dir"
#
# Requires YunoHost version 2.7.12 or higher.
ynh_use_nodejs() {
nodejs_version=$(ynh_app_setting_get --app=$app --key=nodejs_version)
nodejs_version=$(ynh_app_setting_get --key=nodejs_version)
# Get the absolute path of this version of node
nodejs_path="$node_version_path/$nodejs_version/bin"
@ -146,7 +146,7 @@ ynh_install_nodejs() {
echo "$YNH_APP_INSTANCE_NAME:$nodejs_version" | tee --append "$n_install_dir/ynh_app_version"
# Store nodejs_version into the config of this app
ynh_app_setting_set --app=$app --key=nodejs_version --value=$nodejs_version
ynh_app_setting_set --key=nodejs_version --value=$nodejs_version
# Build the update script and set the cronjob
ynh_cron_upgrade_node
@ -164,7 +164,7 @@ ynh_install_nodejs() {
#
# Requires YunoHost version 2.7.12 or higher.
ynh_remove_nodejs() {
nodejs_version=$(ynh_app_setting_get --app=$app --key=nodejs_version)
nodejs_version=$(ynh_app_setting_get --key=nodejs_version)
# Remove the line for this app
sed --in-place "/$YNH_APP_INSTANCE_NAME:$nodejs_version/d" "$n_install_dir/ynh_app_version"

View file

@ -87,19 +87,19 @@ ynh_add_fpm_config() {
autogenconf=true
# If no usage provided, default to the value existing in setting ... or to low
local fpm_usage_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_usage)
local fpm_usage_in_setting=$(ynh_app_setting_get --key=fpm_usage)
if [ -z "$usage" ]
then
usage=${fpm_usage_in_setting:-low}
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
ynh_app_setting_set --key=fpm_usage --value=$usage
fi
# If no footprint provided, default to the value existing in setting ... or to low
local fpm_footprint_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
local fpm_footprint_in_setting=$(ynh_app_setting_get --key=fpm_footprint)
if [ -z "$footprint" ]
then
footprint=${fpm_footprint_in_setting:-low}
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
ynh_app_setting_set --key=fpm_footprint --value=$footprint
fi
fi
@ -111,12 +111,12 @@ ynh_add_fpm_config() {
phpversion="${phpversion:-$_globalphpversion}"
fi
local old_phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
local old_phpversion=$(ynh_app_setting_get --key=phpversion)
# If the PHP version changed, remove the old fpm conf
# (NB: This stuff is also handled by the apt helper, which is usually triggered before this helper)
if [ -n "$old_phpversion" ] && [ "$old_phpversion" != "$phpversion" ]; then
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
local old_php_fpm_config_dir=$(ynh_app_setting_get --key=fpm_config_dir)
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
if [[ -f "$old_php_finalphpconf" ]]
@ -132,9 +132,9 @@ ynh_add_fpm_config() {
# Create the directory for FPM pools
mkdir --parents "$fpm_config_dir/pool.d"
ynh_app_setting_set --app=$app --key=fpm_config_dir --value="$fpm_config_dir"
ynh_app_setting_set --app=$app --key=fpm_service --value="$fpm_service"
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
ynh_app_setting_set --key=fpm_config_dir --value="$fpm_config_dir"
ynh_app_setting_set --key=fpm_service --value="$fpm_service"
ynh_app_setting_set --key=phpversion --value=$phpversion
if [ $autogenconf == "false" ]; then
# Usage 1, use the template in conf/php-fpm.conf
@ -204,10 +204,10 @@ pm.process_idle_timeout = 10s
#
# Requires YunoHost version 2.7.2 or higher.
ynh_remove_fpm_config() {
local fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
local fpm_service=$(ynh_app_setting_get --app=$app --key=fpm_service)
local fpm_config_dir=$(ynh_app_setting_get --key=fpm_config_dir)
local fpm_service=$(ynh_app_setting_get --key=fpm_service)
# Get the version of PHP used by this app
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
local phpversion=$(ynh_app_setting_get --key=phpversion)
# Assume default PHP-FPM version by default
phpversion="${phpversion:-$YNH_DEFAULT_PHP_VERSION}"
@ -314,7 +314,7 @@ ynh_get_scalable_phpfpm() {
fi
# Get a potential forced value for php_max_children
local php_forced_max_children=$(ynh_app_setting_get --app=$app --key=php_forced_max_children)
local php_forced_max_children=$(ynh_app_setting_get --key=php_forced_max_children)
if [ -n "$php_forced_max_children" ]; then
php_max_children=$php_forced_max_children
fi

View file

@ -249,7 +249,7 @@ ynh_psql_setup_db() {
fi
ynh_psql_create_db "$db_name" "$db_user" # Create the database
ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd # Store the password in the app's config
ynh_app_setting_set --key=psqlpwd --value=$db_pwd # Store the password in the app's config
}
# Remove a database if it exists, and the associated user

View file

@ -51,7 +51,7 @@ fi
#
# Requires YunoHost version 3.2.2 or higher.
ynh_use_ruby () {
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
ruby_version=$(ynh_app_setting_get --key=ruby_version)
# Get the absolute path of this version of Ruby
ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin"
@ -206,7 +206,7 @@ ynh_install_ruby () {
RUBY_CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1
# Store ruby_version into the config of this app
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version
ynh_app_setting_set --key=ruby_version --value=$final_ruby_version
# Remove app virtualenv
if rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME "
@ -237,7 +237,7 @@ eval \"\$(rbenv init -)\"
#
# usage: ynh_remove_ruby
ynh_remove_ruby () {
local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version)
local ruby_version=$(ynh_app_setting_get --key=ruby_version)
# Load rbenv path in PATH
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
@ -248,7 +248,7 @@ ynh_remove_ruby () {
rbenv alias $YNH_APP_INSTANCE_NAME --remove
# Remove the line for this app
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version
ynh_app_setting_delete --key=ruby_version
# Cleanup Ruby versions
ynh_cleanup_ruby