mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Apply shfmt everywhere
This commit is contained in:
parent
68f35831e7
commit
8a5f2808a1
63 changed files with 739 additions and 925 deletions
|
@ -21,6 +21,7 @@ case "$YNH_HELPERS_VERSION" in
|
||||||
*)
|
*)
|
||||||
echo "Helpers are not available in version '$YNH_HELPERS_VERSION'." >&2
|
echo "Helpers are not available in version '$YNH_HELPERS_VERSION'." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
eval "$XTRACE_ENABLE"
|
eval "$XTRACE_ENABLE"
|
||||||
|
|
|
@ -19,8 +19,7 @@ ynh_install_apps() {
|
||||||
local apps_dependencies=""
|
local apps_dependencies=""
|
||||||
|
|
||||||
# For each app
|
# For each app
|
||||||
for one_app_and_its_args in "${apps_list[@]}"
|
for one_app_and_its_args in "${apps_list[@]}"; do
|
||||||
do
|
|
||||||
# Retrieve the name of the app (part before ?)
|
# Retrieve the name of the app (part before ?)
|
||||||
local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args")
|
local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args")
|
||||||
[ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install"
|
[ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install"
|
||||||
|
@ -28,8 +27,7 @@ ynh_install_apps() {
|
||||||
yunohost tools update apps
|
yunohost tools update apps
|
||||||
|
|
||||||
# Installing or upgrading the app depending if it's installed or not
|
# Installing or upgrading the app depending if it's installed or not
|
||||||
if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' >/dev/null
|
if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' > /dev/null; then
|
||||||
then
|
|
||||||
# Retrieve the arguments of the app (part after ?)
|
# Retrieve the arguments of the app (part after ?)
|
||||||
local one_argument=""
|
local one_argument=""
|
||||||
if [[ "$one_app_and_its_args" == *"?"* ]]; then
|
if [[ "$one_app_and_its_args" == *"?"* ]]; then
|
||||||
|
@ -44,8 +42,7 @@ ynh_install_apps() {
|
||||||
yunohost app upgrade $one_app
|
yunohost app upgrade $one_app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$apps_dependencies" ]
|
if [ ! -z "$apps_dependencies" ]; then
|
||||||
then
|
|
||||||
apps_dependencies="$apps_dependencies, $one_app"
|
apps_dependencies="$apps_dependencies, $one_app"
|
||||||
else
|
else
|
||||||
apps_dependencies="$one_app"
|
apps_dependencies="$one_app"
|
||||||
|
@ -67,31 +64,26 @@ ynh_remove_apps() {
|
||||||
local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
|
local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
|
||||||
ynh_app_setting_delete --app=$app --key=apps_dependencies
|
ynh_app_setting_delete --app=$app --key=apps_dependencies
|
||||||
|
|
||||||
if [ ! -z "$apps_dependencies" ]
|
if [ ! -z "$apps_dependencies" ]; then
|
||||||
then
|
|
||||||
# Split the list of apps dependencies in an array
|
# Split the list of apps dependencies in an array
|
||||||
local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n"))
|
local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n"))
|
||||||
|
|
||||||
# For each apps dependencies
|
# For each apps dependencies
|
||||||
for one_app in "${apps_dependencies_list[@]}"
|
for one_app in "${apps_dependencies_list[@]}"; do
|
||||||
do
|
|
||||||
# Retrieve the list of installed apps
|
# Retrieve the list of installed apps
|
||||||
local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
local required_by=""
|
local required_by=""
|
||||||
local installed_app_required_by=""
|
local installed_app_required_by=""
|
||||||
|
|
||||||
# For each other installed app
|
# For each other installed app
|
||||||
for one_installed_app in $installed_apps_list
|
for one_installed_app in $installed_apps_list; do
|
||||||
do
|
|
||||||
# Retrieve the other apps dependencies
|
# Retrieve the other apps dependencies
|
||||||
one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies)
|
one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies)
|
||||||
if [ ! -z "$one_installed_apps_dependencies" ]
|
if [ ! -z "$one_installed_apps_dependencies" ]; then
|
||||||
then
|
|
||||||
one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n"))
|
one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n"))
|
||||||
|
|
||||||
# For each dependency of the other apps
|
# For each dependency of the other apps
|
||||||
for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}"
|
for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}"; do
|
||||||
do
|
|
||||||
if [[ $one_installed_app_dependency == $one_app ]]; then
|
if [[ $one_installed_app_dependency == $one_app ]]; then
|
||||||
required_by="$required_by $one_installed_app"
|
required_by="$required_by $one_installed_app"
|
||||||
fi
|
fi
|
||||||
|
@ -100,8 +92,7 @@ ynh_remove_apps() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# If $one_app is no more required
|
# If $one_app is no more required
|
||||||
if [[ -z "$required_by" ]]
|
if [[ -z "$required_by" ]]; then
|
||||||
then
|
|
||||||
# Remove $one_app
|
# Remove $one_app
|
||||||
ynh_print_info --message="Removing of $one_app"
|
ynh_print_info --message="Removing of $one_app"
|
||||||
yunohost app remove $one_app --purge
|
yunohost app remove $one_app --purge
|
||||||
|
@ -134,16 +125,14 @@ ynh_spawn_app_shell() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Force Bash to be used to run this helper
|
# Force Bash to be used to run this helper
|
||||||
if [[ ! $0 =~ \/?bash$ ]]
|
if [[ ! $0 =~ \/?bash$ ]]; then
|
||||||
then
|
|
||||||
ynh_print_err --message="Please use Bash as shell"
|
ynh_print_err --message="Please use Bash as shell"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the app is installed
|
# Make sure the app is installed
|
||||||
local installed_apps_list=($(yunohost app list --output-as json --quiet | jq -r .apps[].id))
|
local installed_apps_list=($(yunohost app list --output-as json --quiet | jq -r .apps[].id))
|
||||||
if [[ " ${installed_apps_list[*]} " != *" ${app} "* ]]
|
if [[ " ${installed_apps_list[*]} " != *" ${app} "* ]]; then
|
||||||
then
|
|
||||||
ynh_print_err --message="$app is not in the apps list"
|
ynh_print_err --message="$app is not in the apps list"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -156,49 +145,44 @@ ynh_spawn_app_shell() {
|
||||||
|
|
||||||
# Make sure the app has an install_dir setting
|
# 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 --app=$app --key=install_dir)
|
||||||
if [ -z "$install_dir" ]
|
if [ -z "$install_dir" ]; then
|
||||||
then
|
|
||||||
ynh_print_err --message="$app has no install_dir setting (does it use packaging format >=2?)"
|
ynh_print_err --message="$app has no install_dir setting (does it use packaging format >=2?)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load the app's service name, or default to $app
|
# 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 --app=$app --key=service)
|
||||||
[ -z "$service" ] && service=$app;
|
[ -z "$service" ] && service=$app
|
||||||
|
|
||||||
# Export HOME variable
|
# Export HOME variable
|
||||||
export HOME=$install_dir;
|
export HOME=$install_dir
|
||||||
|
|
||||||
# Load the Environment variables from the app's service
|
# Load the Environment variables from the app's service
|
||||||
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
||||||
[ -n "$env_var" ] && export $env_var;
|
[ -n "$env_var" ] && export $env_var
|
||||||
|
|
||||||
# Force `php` to its intended version
|
# Force `php` to its intended version
|
||||||
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
# 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 phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
||||||
if [ -n "$phpversion" ]
|
if [ -n "$phpversion" ]; then
|
||||||
then
|
|
||||||
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
||||||
export -f php
|
export -f php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source the EnvironmentFiles from the app's service
|
# Source the EnvironmentFiles from the app's service
|
||||||
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
||||||
if [ ${#env_files[*]} -gt 0 ]
|
if [ ${#env_files[*]} -gt 0 ]; then
|
||||||
then
|
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
set -a
|
set -a
|
||||||
for file in ${env_files[*]}
|
for file in ${env_files[*]}; do
|
||||||
do
|
|
||||||
[[ $file = /* ]] && source $file
|
[[ $file = /* ]] && source $file
|
||||||
done
|
done
|
||||||
set +a
|
set +a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Activate the Python environment, if it exists
|
# Activate the Python environment, if it exists
|
||||||
if [ -f $install_dir/venv/bin/activate ]
|
if [ -f $install_dir/venv/bin/activate ]; then
|
||||||
then
|
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
set -a
|
set -a
|
||||||
source $install_dir/venv/bin/activate
|
source $install_dir/venv/bin/activate
|
||||||
|
@ -207,7 +191,7 @@ ynh_spawn_app_shell() {
|
||||||
|
|
||||||
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
||||||
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
||||||
[ -z $env_dir ] && env_dir=$install_dir;
|
[ -z $env_dir ] && env_dir=$install_dir
|
||||||
cd $env_dir
|
cd $env_dir
|
||||||
|
|
||||||
# Spawn the app shell
|
# Spawn the app shell
|
||||||
|
|
|
@ -266,8 +266,7 @@ ynh_install_app_dependencies() {
|
||||||
# The (?<=php) syntax corresponds to lookbehind ;)
|
# The (?<=php) syntax corresponds to lookbehind ;)
|
||||||
local specific_php_version=$(echo $dependencies | grep -oP '(?<=php)[0-9.]+(?=-|\>|)' | sort -u)
|
local specific_php_version=$(echo $dependencies | grep -oP '(?<=php)[0-9.]+(?=-|\>|)' | sort -u)
|
||||||
|
|
||||||
if [[ -n "$specific_php_version" ]]
|
if [[ -n "$specific_php_version" ]]; then
|
||||||
then
|
|
||||||
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
||||||
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
||||||
|| ynh_die --message="Inconsistent php versions in dependencies ... found : $specific_php_version"
|
|| ynh_die --message="Inconsistent php versions in dependencies ... found : $specific_php_version"
|
||||||
|
@ -281,8 +280,7 @@ ynh_install_app_dependencies() {
|
||||||
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 --app=$app --key=fpm_config_dir)
|
||||||
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
||||||
|
|
||||||
if [[ -f "$old_php_finalphpconf" ]]
|
if [[ -f "$old_php_finalphpconf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
fi
|
fi
|
||||||
|
@ -291,8 +289,7 @@ ynh_install_app_dependencies() {
|
||||||
ynh_app_setting_set --app=$app --key=phpversion --value=$specific_php_version
|
ynh_app_setting_set --app=$app --key=phpversion --value=$specific_php_version
|
||||||
|
|
||||||
# Set the default php version back as the default version for php-cli.
|
# Set the default php version back as the default version for php-cli.
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
elif grep --quiet 'php' <<< "$dependencies"; then
|
elif grep --quiet 'php' <<< "$dependencies"; then
|
||||||
|
@ -306,13 +303,11 @@ ynh_install_app_dependencies() {
|
||||||
# upgrade script where ynh_install_app_dependencies is called with this
|
# upgrade script where ynh_install_app_dependencies is called with this
|
||||||
# expected effect) Otherwise, any subsequent call will add dependencies
|
# expected effect) Otherwise, any subsequent call will add dependencies
|
||||||
# to those already present in the equivs control file.
|
# to those already present in the equivs control file.
|
||||||
if [[ $YNH_INSTALL_APP_DEPENDENCIES_REPLACE == "true" ]]
|
if [[ $YNH_INSTALL_APP_DEPENDENCIES_REPLACE == "true" ]]; then
|
||||||
then
|
|
||||||
YNH_INSTALL_APP_DEPENDENCIES_REPLACE="false"
|
YNH_INSTALL_APP_DEPENDENCIES_REPLACE="false"
|
||||||
else
|
else
|
||||||
local current_dependencies=""
|
local current_dependencies=""
|
||||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
if ynh_package_is_installed --package="${dep_app}-ynh-deps"; then
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||||
current_dependencies=${current_dependencies// | /|}
|
current_dependencies=${current_dependencies// | /|}
|
||||||
fi
|
fi
|
||||||
|
@ -337,8 +332,7 @@ EOF
|
||||||
|
|
||||||
# Trigger postgresql regenconf if we may have just installed postgresql
|
# Trigger postgresql regenconf if we may have just installed postgresql
|
||||||
local psql_installed2="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
local psql_installed2="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
||||||
if [[ "$psql_installed" != "$psql_installed2" ]]
|
if [[ "$psql_installed" != "$psql_installed2" ]]; then
|
||||||
then
|
|
||||||
yunohost tools regen-conf postgresql
|
yunohost tools regen-conf postgresql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -382,16 +376,14 @@ ynh_remove_app_dependencies() {
|
||||||
|
|
||||||
# Edge case where the app dep may be on hold,
|
# Edge case where the app dep may be on hold,
|
||||||
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
||||||
if apt-mark showhold | grep -q -w ${dep_app}-ynh-deps
|
if apt-mark showhold | grep -q -w ${dep_app}-ynh-deps; then
|
||||||
then
|
|
||||||
apt-mark unhold ${dep_app}-ynh-deps
|
apt-mark unhold ${dep_app}-ynh-deps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the fake package and its dependencies if they not still used.
|
# Remove the fake package and its dependencies if they not still used.
|
||||||
# (except if dpkg doesn't know anything about the package,
|
# (except if dpkg doesn't know anything about the package,
|
||||||
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
||||||
if dpkg-query --show ${dep_app}-ynh-deps &>/dev/null
|
if dpkg-query --show ${dep_app}-ynh-deps &> /dev/null; then
|
||||||
then
|
|
||||||
ynh_package_autopurge ${dep_app}-ynh-deps
|
ynh_package_autopurge ${dep_app}-ynh-deps
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -487,8 +479,10 @@ ynh_install_extra_repo() {
|
||||||
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
||||||
index=1
|
index=1
|
||||||
fi
|
fi
|
||||||
uri="${repo_parts[$index]}" ; index=$((index+1))
|
uri="${repo_parts[$index]}"
|
||||||
suite="${repo_parts[$index]}" ; index=$((index+1))
|
index=$((index + 1))
|
||||||
|
suite="${repo_parts[$index]}"
|
||||||
|
index=$((index + 1))
|
||||||
|
|
||||||
# Get the components
|
# Get the components
|
||||||
if (("${#repo_parts[@]}" > 0)); then
|
if (("${#repo_parts[@]}" > 0)); then
|
||||||
|
|
|
@ -289,8 +289,7 @@ ynh_restore_file() {
|
||||||
# Boring hack for nginx conf file mapped to php7.3
|
# Boring hack for nginx conf file mapped to php7.3
|
||||||
# Note that there's no need to patch the fpm config because most php apps
|
# Note that there's no need to patch the fpm config because most php apps
|
||||||
# will call "ynh_add_fpm_config" during restore, effectively recreating the file from scratch
|
# will call "ynh_add_fpm_config" during restore, effectively recreating the file from scratch
|
||||||
if [[ "${dest_path}" == "/etc/nginx/conf.d/"* ]] && grep 'php7.3.*sock' "${dest_path}"
|
if [[ "${dest_path}" == "/etc/nginx/conf.d/"* ]] && grep 'php7.3.*sock' "${dest_path}"; then
|
||||||
then
|
|
||||||
sed -i 's/php7.3/php7.4/g' "${dest_path}"
|
sed -i 's/php7.3/php7.4/g' "${dest_path}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -376,8 +375,7 @@ ynh_backup_if_checksum_is_different() {
|
||||||
echo "$backup_file_checksum" # Return the name of the backup file
|
echo "$backup_file_checksum" # Return the name of the backup file
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
local file_path_base64=$(echo "$file" | base64 -w0)
|
local file_path_base64=$(echo "$file" | base64 -w0)
|
||||||
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}
|
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}; then
|
||||||
then
|
|
||||||
ynh_print_warn "Diff with the original file:"
|
ynh_print_warn "Diff with the original file:"
|
||||||
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
||||||
fi
|
fi
|
||||||
|
@ -494,8 +492,7 @@ ynh_restore_upgradebackup() {
|
||||||
yunohost app remove $app
|
yunohost app remove $app
|
||||||
# Restore the backup
|
# Restore the backup
|
||||||
yunohost backup restore $app_bck-pre-upgrade$backup_number --apps $app --force --debug
|
yunohost backup restore $app_bck-pre-upgrade$backup_number --apps $app --force --debug
|
||||||
if [[ -d /etc/yunohost/apps/$app ]]
|
if [[ -d /etc/yunohost/apps/$app ]]; then
|
||||||
then
|
|
||||||
ynh_die --message="The app was restored to the way it was before the failed upgrade."
|
ynh_die --message="The app was restored to the way it was before the failed upgrade."
|
||||||
else
|
else
|
||||||
ynh_die --message="Uhoh ... Yunohost failed to restore the app to the way it was before the failed upgrade :|"
|
ynh_die --message="Uhoh ... Yunohost failed to restore the app to the way it was before the failed upgrade :|"
|
||||||
|
|
|
@ -298,5 +298,6 @@ ynh_app_config_run() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ynh_app_action_run $1
|
ynh_app_action_run $1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,29 +210,24 @@ ynh_cleanup_go () {
|
||||||
# List required Go versions
|
# List required Go versions
|
||||||
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
local required_go_versions=""
|
local required_go_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
||||||
if [[ $installed_app_go_version ]]
|
if [[ $installed_app_go_version ]]; then
|
||||||
then
|
|
||||||
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Go versions
|
# Remove no more needed Go versions
|
||||||
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_go_version in $installed_go_versions
|
for installed_go_version in $installed_go_versions; do
|
||||||
do
|
if ! $(echo ${required_go_versions} | grep "${installed_go_version}" 1> /dev/null 2>&1); then
|
||||||
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
|
||||||
then
|
|
||||||
ynh_print_info --message="Removing of Go-$installed_go_version"
|
ynh_print_info --message="Removing of Go-$installed_go_version"
|
||||||
$goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
|
$goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Go version is required
|
# If none Go version is required
|
||||||
if [[ ! $required_go_versions ]]
|
if [[ ! $required_go_versions ]]; then
|
||||||
then
|
|
||||||
# Remove goenv environment configuration
|
# Remove goenv environment configuration
|
||||||
ynh_print_info --message="Removing of goenv"
|
ynh_print_info --message="Removing of goenv"
|
||||||
ynh_secure_remove --file="$goenv_install_dir"
|
ynh_secure_remove --file="$goenv_install_dir"
|
||||||
|
|
|
@ -93,8 +93,7 @@ ynh_exec_err() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
ynh_print_err --message="$(eval $@)"
|
ynh_print_err --message="$(eval $@)"
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -114,8 +113,7 @@ ynh_exec_warn() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
ynh_print_warn --message="$(eval $@)"
|
ynh_print_warn --message="$(eval $@)"
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -135,8 +133,7 @@ ynh_exec_warn_less() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ 2>&1
|
eval $@ 2>&1
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -156,8 +153,7 @@ ynh_exec_quiet() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ > /dev/null
|
eval $@ > /dev/null
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -177,8 +173,7 @@ ynh_exec_fully_quiet() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ > /dev/null 2>&1
|
eval $@ > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
|
|
@ -17,10 +17,8 @@ ynh_use_logrotate() {
|
||||||
# Stupid patch to ignore legacy --non-append and --nonappend
|
# Stupid patch to ignore legacy --non-append and --nonappend
|
||||||
# which was never properly understood and improperly used and kind of bullshit
|
# which was never properly understood and improperly used and kind of bullshit
|
||||||
local all_args=(${@})
|
local all_args=(${@})
|
||||||
for I in $(seq 0 $(($# - 1)))
|
for I in $(seq 0 $(($# - 1))); do
|
||||||
do
|
if [[ "${all_args[$I]}" == "--non-append" ]] || [[ "${all_args[$I]}" == "--nonappend" ]]; then
|
||||||
if [[ "${all_args[$I]}" == "--non-append" ]] || [[ "${all_args[$I]}" == "--nonappend" ]]
|
|
||||||
then
|
|
||||||
unset all_args[$I]
|
unset all_args[$I]
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -43,8 +41,7 @@ ynh_use_logrotate() {
|
||||||
fi
|
fi
|
||||||
set +o noglob
|
set +o noglob
|
||||||
|
|
||||||
for stuff in $logfile
|
for stuff in $logfile; do
|
||||||
do
|
|
||||||
mkdir --parents $(dirname "$stuff")
|
mkdir --parents $(dirname "$stuff")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -76,8 +73,7 @@ $logfile {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]
|
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]; then
|
||||||
then
|
|
||||||
cat $tempconf > /etc/logrotate.d/$app
|
cat $tempconf > /etc/logrotate.d/$app
|
||||||
else
|
else
|
||||||
cat $tempconf >> /etc/logrotate.d/$app
|
cat $tempconf >> /etc/logrotate.d/$app
|
||||||
|
|
|
@ -39,19 +39,16 @@ ynh_mongo_exec() {
|
||||||
eval=${eval:-0}
|
eval=${eval:-0}
|
||||||
|
|
||||||
# If user is provided
|
# If user is provided
|
||||||
if [ -n "$user" ]
|
if [ -n "$user" ]; then
|
||||||
then
|
|
||||||
user="--username=$user"
|
user="--username=$user"
|
||||||
|
|
||||||
# If password is provided
|
# If password is provided
|
||||||
if [ -n "$password" ]
|
if [ -n "$password" ]; then
|
||||||
then
|
|
||||||
password="--password=$password"
|
password="--password=$password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If authenticationdatabase is provided
|
# If authenticationdatabase is provided
|
||||||
if [ -n "$authenticationdatabase" ]
|
if [ -n "$authenticationdatabase" ]; then
|
||||||
then
|
|
||||||
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
|
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
|
||||||
else
|
else
|
||||||
authenticationdatabase="--authenticationDatabase=admin"
|
authenticationdatabase="--authenticationDatabase=admin"
|
||||||
|
@ -62,23 +59,19 @@ ynh_mongo_exec() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If host is provided
|
# If host is provided
|
||||||
if [ -n "$host" ]
|
if [ -n "$host" ]; then
|
||||||
then
|
|
||||||
host="--host=$host"
|
host="--host=$host"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If port is provided
|
# If port is provided
|
||||||
if [ -n "$port" ]
|
if [ -n "$port" ]; then
|
||||||
then
|
|
||||||
port="--port=$port"
|
port="--port=$port"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If eval is not provided
|
# If eval is not provided
|
||||||
if [ $eval -eq 0 ]
|
if [ $eval -eq 0 ]; then
|
||||||
then
|
|
||||||
# If database is provided
|
# If database is provided
|
||||||
if [ -n "$database" ]
|
if [ -n "$database" ]; then
|
||||||
then
|
|
||||||
database="use $database"
|
database="use $database"
|
||||||
else
|
else
|
||||||
database=""
|
database=""
|
||||||
|
@ -91,8 +84,7 @@ quit()
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
# If database is provided
|
# If database is provided
|
||||||
if [ -n "$database" ]
|
if [ -n "$database" ]; then
|
||||||
then
|
|
||||||
database="$database"
|
database="$database"
|
||||||
else
|
else
|
||||||
database=""
|
database=""
|
||||||
|
@ -186,8 +178,7 @@ ynh_mongo_database_exists() {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
|
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]; then
|
||||||
then
|
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
@ -343,8 +334,7 @@ ynh_install_mongo() {
|
||||||
#
|
#
|
||||||
ynh_remove_mongo() {
|
ynh_remove_mongo() {
|
||||||
# Only remove the mongodb service if it is not installed.
|
# Only remove the mongodb service if it is not installed.
|
||||||
if ! ynh_package_is_installed --package="mongodb*"
|
if ! ynh_package_is_installed --package="mongodb*"; then
|
||||||
then
|
|
||||||
ynh_print_info --message="Removing MongoDB service..."
|
ynh_print_info --message="Removing MongoDB service..."
|
||||||
mongodb_servicename=mongod
|
mongodb_servicename=mongod
|
||||||
# Remove the mongodb service
|
# Remove the mongodb service
|
||||||
|
|
|
@ -43,7 +43,6 @@ ynh_remove_nginx_config() {
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Regen the nginx config in a change url context
|
# Regen the nginx config in a change url context
|
||||||
#
|
#
|
||||||
# usage: ynh_change_url_nginx_config
|
# usage: ynh_change_url_nginx_config
|
||||||
|
|
|
@ -92,16 +92,14 @@ ynh_add_fpm_config() {
|
||||||
|
|
||||||
# If no usage provided, default to the value existing in setting ... or to low
|
# 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 --app=$app --key=fpm_usage)
|
||||||
if [ -z "$usage" ]
|
if [ -z "$usage" ]; then
|
||||||
then
|
|
||||||
usage=${fpm_usage_in_setting:-low}
|
usage=${fpm_usage_in_setting:-low}
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no footprint provided, default to the value existing in setting ... or to low
|
# 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 --app=$app --key=fpm_footprint)
|
||||||
if [ -z "$footprint" ]
|
if [ -z "$footprint" ]; then
|
||||||
then
|
|
||||||
footprint=${fpm_footprint_in_setting:-low}
|
footprint=${fpm_footprint_in_setting:-low}
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
|
||||||
fi
|
fi
|
||||||
|
@ -125,8 +123,7 @@ ynh_add_fpm_config() {
|
||||||
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 --app=$app --key=fpm_config_dir)
|
||||||
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
||||||
|
|
||||||
if [[ -f "$old_php_finalphpconf" ]]
|
if [[ -f "$old_php_finalphpconf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -199,8 +199,7 @@ ynh_psql_database_exists() {
|
||||||
|
|
||||||
# if psql is not there, we cannot check the db
|
# if psql is not there, we cannot check the db
|
||||||
# though it could exists.
|
# though it could exists.
|
||||||
if ! command -v psql
|
if ! command -v psql; then
|
||||||
then
|
|
||||||
ynh_print_err -m "PostgreSQL is not installed, impossible to check for db existence."
|
ynh_print_err -m "PostgreSQL is not installed, impossible to check for db existence."
|
||||||
return 1
|
return 1
|
||||||
elif ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT datname FROM pg_database WHERE datname='$database';" | grep --quiet "$database"; then
|
elif ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT datname FROM pg_database WHERE datname='$database';" | grep --quiet "$database"; then
|
||||||
|
|
|
@ -13,10 +13,8 @@ ynh_redis_get_free_db() {
|
||||||
|
|
||||||
db=0
|
db=0
|
||||||
# default Debian setting is 15 databases
|
# default Debian setting is 15 databases
|
||||||
for i in $(seq 0 "$max")
|
for i in $(seq 0 "$max"); do
|
||||||
do
|
if ! echo "$result" | grep -q "db$i"; then
|
||||||
if ! echo "$result" | grep -q "db$i"
|
|
||||||
then
|
|
||||||
db=$i
|
db=$i
|
||||||
break 1
|
break 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -210,8 +210,7 @@ ynh_install_ruby () {
|
||||||
ynh_app_setting_set --app=$app --key=ruby_version --value=$final_ruby_version
|
ynh_app_setting_set --app=$app --key=ruby_version --value=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if rbenv alias --list | grep --quiet "$app "
|
if rbenv alias --list | grep --quiet "$app "; then
|
||||||
then
|
|
||||||
rbenv alias $app --remove
|
rbenv alias $app --remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -267,29 +266,24 @@ ynh_cleanup_ruby () {
|
||||||
# List required Ruby versions
|
# List required Ruby versions
|
||||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
local required_ruby_versions=""
|
local required_ruby_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||||
if [[ -n "$installed_app_ruby_version" ]]
|
if [[ -n "$installed_app_ruby_version" ]]; then
|
||||||
then
|
|
||||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Ruby versions
|
# Remove no more needed Ruby versions
|
||||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_ruby_version in $installed_ruby_versions
|
for installed_ruby_version in $installed_ruby_versions; do
|
||||||
do
|
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"; then
|
||||||
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
|
||||||
then
|
|
||||||
ynh_print_info --message="Removing Ruby-$installed_ruby_version"
|
ynh_print_info --message="Removing Ruby-$installed_ruby_version"
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Ruby version is required
|
# If none Ruby version is required
|
||||||
if [[ -z "$required_ruby_versions" ]]
|
if [[ -z "$required_ruby_versions" ]]; then
|
||||||
then
|
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
ynh_print_info --message="Removing rbenv"
|
ynh_print_info --message="Removing rbenv"
|
||||||
ynh_secure_remove --file="$rbenv_install_dir"
|
ynh_secure_remove --file="$rbenv_install_dir"
|
||||||
|
|
|
@ -77,12 +77,10 @@ ynh_setup_source() {
|
||||||
keep="${keep:-}"
|
keep="${keep:-}"
|
||||||
full_replace="${full_replace:-0}"
|
full_replace="${full_replace:-0}"
|
||||||
|
|
||||||
if test -e $YNH_APP_BASEDIR/manifest.toml && cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -e '.resources.sources' >/dev/null
|
if test -e $YNH_APP_BASEDIR/manifest.toml && cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -e '.resources.sources' > /dev/null; then
|
||||||
then
|
|
||||||
source_id="${source_id:-main}"
|
source_id="${source_id:-main}"
|
||||||
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
||||||
if jq -re ".url" <<< "$sources_json"
|
if jq -re ".url" <<< "$sources_json"; then
|
||||||
then
|
|
||||||
local arch_prefix=""
|
local arch_prefix=""
|
||||||
else
|
else
|
||||||
local arch_prefix=".$YNH_ARCH"
|
local arch_prefix=".$YNH_ARCH"
|
||||||
|
@ -100,22 +98,16 @@ ynh_setup_source() {
|
||||||
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
||||||
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
||||||
|
|
||||||
if [[ -z "$src_format" ]]
|
if [[ -z "$src_format" ]]; then
|
||||||
then
|
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]; then
|
||||||
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]
|
|
||||||
then
|
|
||||||
src_format="zip"
|
src_format="zip"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.gz"
|
src_format="tar.gz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.xz"
|
src_format="tar.xz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.bz2"
|
src_format="tar.bz2"
|
||||||
elif [[ -z "$src_extract" ]]
|
elif [[ -z "$src_extract" ]]; then
|
||||||
then
|
|
||||||
src_extract="false"
|
src_extract="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -142,12 +134,10 @@ ynh_setup_source() {
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
|
|
||||||
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]
|
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]; then
|
||||||
then
|
|
||||||
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# (Unused?) mecanism where one can have the file in a special local cache to not have to download it...
|
# (Unused?) mecanism where one can have the file in a special local cache to not have to download it...
|
||||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${source_id}"
|
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${source_id}"
|
||||||
|
|
||||||
|
@ -165,14 +155,12 @@ ynh_setup_source() {
|
||||||
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
||||||
|
|
||||||
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
||||||
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status
|
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status; then
|
||||||
then
|
|
||||||
rm -f "$src_filename"
|
rm -f "$src_filename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only redownload the file if it wasnt prefetched
|
# Only redownload the file if it wasnt prefetched
|
||||||
if [ ! -e "$src_filename" ]
|
if [ ! -e "$src_filename" ]; then
|
||||||
then
|
|
||||||
# NB. we have to declare the var as local first,
|
# NB. we have to declare the var as local first,
|
||||||
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
||||||
# because local always return 0 ...
|
# because local always return 0 ...
|
||||||
|
@ -183,8 +171,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
if ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status
|
if ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status; then
|
||||||
then
|
|
||||||
local actual_sum="$(${src_sumprg} ${src_filename} | cut --delimiter=' ' --fields=1)"
|
local actual_sum="$(${src_sumprg} ${src_filename} | cut --delimiter=' ' --fields=1)"
|
||||||
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
||||||
rm -f ${src_filename}
|
rm -f ${src_filename}
|
||||||
|
@ -222,8 +209,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$src_extract" == "false" ]]; then
|
if [[ "$src_extract" == "false" ]]; then
|
||||||
if [[ -z "$src_rename" ]]
|
if [[ -z "$src_rename" ]]; then
|
||||||
then
|
|
||||||
mv $src_filename $dest_dir
|
mv $src_filename $dest_dir
|
||||||
else
|
else
|
||||||
mv $src_filename $dest_dir/$src_rename
|
mv $src_filename $dest_dir/$src_rename
|
||||||
|
|
|
@ -149,8 +149,7 @@ ynh_systemd_action() {
|
||||||
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
||||||
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
||||||
# instead of 5 min ...
|
# instead of 5 min ...
|
||||||
if [[ "$(( $(date +%s) - $starttime))" -gt "$timeout" ]]
|
if [[ "$(($(date +%s) - $starttime))" -gt "$timeout" ]]; then
|
||||||
then
|
|
||||||
i=$timeout
|
i=$timeout
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -83,8 +83,7 @@ ynh_add_config() {
|
||||||
chmod 640 $destination
|
chmod 640 $destination
|
||||||
_ynh_apply_default_permissions $destination
|
_ynh_apply_default_permissions $destination
|
||||||
|
|
||||||
if [[ "$jinja" == 1 ]]
|
if [[ "$jinja" == 1 ]]; then
|
||||||
then
|
|
||||||
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
||||||
(
|
(
|
||||||
export $(compgen -v)
|
export $(compgen -v)
|
||||||
|
|
|
@ -22,8 +22,7 @@ YNH_APP_BASEDIR=${YNH_APP_BASEDIR:-$(realpath ..)}
|
||||||
ynh_exit_properly() {
|
ynh_exit_properly() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
|
|
||||||
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]
|
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]; then
|
||||||
then
|
|
||||||
rm -rf "/var/cache/yunohost/download/"
|
rm -rf "/var/cache/yunohost/download/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -67,8 +66,7 @@ ynh_abort_if_errors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# When running an app script with packaging format >= 2, auto-enable ynh_abort_if_errors except for remove script
|
# When running an app script with packaging format >= 2, auto-enable ynh_abort_if_errors except for remove script
|
||||||
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} ge 2 && [[ ${YNH_APP_ACTION} != "remove" ]]
|
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} ge 2 && [[ ${YNH_APP_ACTION} != "remove" ]]; then
|
||||||
then
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -149,8 +147,7 @@ _acceptable_path_to_delete() {
|
||||||
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
||||||
|
|
||||||
# Legacy : A couple apps still have data in /home/$app ...
|
# Legacy : A couple apps still have data in /home/$app ...
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -215,19 +212,16 @@ ynh_read_manifest() {
|
||||||
|
|
||||||
if [ ! -e "${manifest:-}" ]; then
|
if [ ! -e "${manifest:-}" ]; then
|
||||||
# If the manifest isn't found, try the common place for backup and restore script.
|
# If the manifest isn't found, try the common place for backup and restore script.
|
||||||
if [ -e "$YNH_APP_BASEDIR/manifest.json" ]
|
if [ -e "$YNH_APP_BASEDIR/manifest.json" ]; then
|
||||||
then
|
|
||||||
manifest="$YNH_APP_BASEDIR/manifest.json"
|
manifest="$YNH_APP_BASEDIR/manifest.json"
|
||||||
elif [ -e "$YNH_APP_BASEDIR/manifest.toml" ]
|
elif [ -e "$YNH_APP_BASEDIR/manifest.toml" ]; then
|
||||||
then
|
|
||||||
manifest="$YNH_APP_BASEDIR/manifest.toml"
|
manifest="$YNH_APP_BASEDIR/manifest.toml"
|
||||||
else
|
else
|
||||||
ynh_die --message "No manifest found !?"
|
ynh_die --message "No manifest found !?"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$manifest" | grep -q '\.json$'
|
if echo "$manifest" | grep -q '\.json$'; then
|
||||||
then
|
|
||||||
jq ".$manifest_key" "$manifest" --raw-output
|
jq ".$manifest_key" "$manifest" --raw-output
|
||||||
else
|
else
|
||||||
cat "$manifest" | python3 -c 'import json, toml, sys; print(json.dumps(toml.load(sys.stdin)))' | jq ".$manifest_key" --raw-output
|
cat "$manifest" | python3 -c 'import json, toml, sys; print(json.dumps(toml.load(sys.stdin)))' | jq ".$manifest_key" --raw-output
|
||||||
|
@ -387,8 +381,7 @@ _ynh_apply_default_permissions() {
|
||||||
# Crons should be owned by root
|
# Crons should be owned by root
|
||||||
# Also we don't want systemd conf, nginx conf or others stuff to be owned by the app,
|
# Also we don't want systemd conf, nginx conf or others stuff to be owned by the app,
|
||||||
# otherwise they could self-edit their own systemd conf and escalate privilege
|
# otherwise they could self-edit their own systemd conf and escalate privilege
|
||||||
if grep -qE '^(/etc/cron|/etc/php|/etc/nginx/conf.d|/etc/fail2ban|/etc/systemd/system)' <<< "$target"
|
if grep -qE '^(/etc/cron|/etc/php|/etc/nginx/conf.d|/etc/fail2ban|/etc/systemd/system)' <<< "$target"; then
|
||||||
then
|
|
||||||
chmod 400 $target
|
chmod 400 $target
|
||||||
chown root:root $target
|
chown root:root $target
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -39,8 +39,7 @@ ynh_apt_install_dependencies() {
|
||||||
# The (?<=php) syntax corresponds to lookbehind ;)
|
# The (?<=php) syntax corresponds to lookbehind ;)
|
||||||
local specific_php_version=$(grep -oP '(?<=php)[0-9.]+(?=-|\>|)' <<< "$dependencies" | sort -u)
|
local specific_php_version=$(grep -oP '(?<=php)[0-9.]+(?=-|\>|)' <<< "$dependencies" | sort -u)
|
||||||
|
|
||||||
if [[ -n "$specific_php_version" ]]
|
if [[ -n "$specific_php_version" ]]; then
|
||||||
then
|
|
||||||
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
||||||
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
||||||
|| ynh_die "Inconsistent php versions in dependencies ... found : $specific_php_version"
|
|| ynh_die "Inconsistent php versions in dependencies ... found : $specific_php_version"
|
||||||
|
@ -51,8 +50,7 @@ ynh_apt_install_dependencies() {
|
||||||
|
|
||||||
# If the PHP version changed, remove the old fpm conf
|
# If the PHP version changed, remove the old fpm conf
|
||||||
if [ -n "$old_php_version" ] && [ "$old_php_version" != "$specific_php_version" ]; then
|
if [ -n "$old_php_version" ] && [ "$old_php_version" != "$specific_php_version" ]; then
|
||||||
if [[ -f "/etc/php/$php_version/fpm/pool.d/$app.conf" ]]
|
if [[ -f "/etc/php/$php_version/fpm/pool.d/$app.conf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
ynh_backup_if_checksum_is_different "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
ynh_config_remove_phpfpm
|
ynh_config_remove_phpfpm
|
||||||
fi
|
fi
|
||||||
|
@ -61,8 +59,7 @@ ynh_apt_install_dependencies() {
|
||||||
ynh_app_setting_set --key=php_version --value=$specific_php_version
|
ynh_app_setting_set --key=php_version --value=$specific_php_version
|
||||||
|
|
||||||
# Set the default php version back as the default version for php-cli.
|
# Set the default php version back as the default version for php-cli.
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
elif grep --quiet 'php' <<< "$dependencies"; then
|
elif grep --quiet 'php' <<< "$dependencies"; then
|
||||||
|
@ -77,13 +74,11 @@ ynh_apt_install_dependencies() {
|
||||||
# upgrade script where ynh_apt_install_dependencies is called with this
|
# upgrade script where ynh_apt_install_dependencies is called with this
|
||||||
# expected effect) Otherwise, any subsequent call will add dependencies
|
# expected effect) Otherwise, any subsequent call will add dependencies
|
||||||
# to those already present in the equivs control file.
|
# to those already present in the equivs control file.
|
||||||
if [[ $YNH_APT_INSTALL_DEPENDENCIES_REPLACE == "true" ]]
|
if [[ $YNH_APT_INSTALL_DEPENDENCIES_REPLACE == "true" ]]; then
|
||||||
then
|
|
||||||
YNH_APT_INSTALL_DEPENDENCIES_REPLACE="false"
|
YNH_APT_INSTALL_DEPENDENCIES_REPLACE="false"
|
||||||
else
|
else
|
||||||
local current_dependencies=""
|
local current_dependencies=""
|
||||||
if _ynh_apt_package_is_installed "${app_ynh_deps}"
|
if _ynh_apt_package_is_installed "${app_ynh_deps}"; then
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${app_ynh_deps}) "
|
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${app_ynh_deps}) "
|
||||||
current_dependencies=${current_dependencies// | /|}
|
current_dependencies=${current_dependencies// | /|}
|
||||||
fi
|
fi
|
||||||
|
@ -145,8 +140,7 @@ EOF
|
||||||
# Specific tweak related to Postgresql
|
# Specific tweak related to Postgresql
|
||||||
# -> trigger postgresql regenconf if we may have just installed postgresql
|
# -> trigger postgresql regenconf if we may have just installed postgresql
|
||||||
local psql_installed2="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
local psql_installed2="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
||||||
if [[ "$psql_installed" != "$psql_installed2" ]]
|
if [[ "$psql_installed" != "$psql_installed2" ]]; then
|
||||||
then
|
|
||||||
yunohost tools regen-conf postgresql
|
yunohost tools regen-conf postgresql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -168,16 +162,14 @@ ynh_apt_remove_dependencies() {
|
||||||
|
|
||||||
# Edge case where the app dep may be on hold,
|
# Edge case where the app dep may be on hold,
|
||||||
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
||||||
if apt-mark showhold | grep -q -w ${app_ynh_deps}
|
if apt-mark showhold | grep -q -w ${app_ynh_deps}; then
|
||||||
then
|
|
||||||
apt-mark unhold ${app_ynh_deps}
|
apt-mark unhold ${app_ynh_deps}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the fake package and its dependencies if they not still used.
|
# Remove the fake package and its dependencies if they not still used.
|
||||||
# (except if dpkg doesn't know anything about the package,
|
# (except if dpkg doesn't know anything about the package,
|
||||||
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
||||||
if dpkg-query --show ${app_ynh_deps} &>/dev/null
|
if dpkg-query --show ${app_ynh_deps} &> /dev/null; then
|
||||||
then
|
|
||||||
_ynh_apt autoremove --purge ${app_ynh_deps}
|
_ynh_apt autoremove --purge ${app_ynh_deps}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -206,8 +198,10 @@ ynh_apt_install_dependencies_from_extra_repository() {
|
||||||
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
||||||
index=1
|
index=1
|
||||||
fi
|
fi
|
||||||
uri="${repo_parts[$index]}" ; index=$((index+1))
|
uri="${repo_parts[$index]}"
|
||||||
suite="${repo_parts[$index]}" ; index=$((index+1))
|
index=$((index + 1))
|
||||||
|
suite="${repo_parts[$index]}"
|
||||||
|
index=$((index + 1))
|
||||||
|
|
||||||
# Get the components
|
# Get the components
|
||||||
if (("${#repo_parts[@]}" > 0)); then
|
if (("${#repo_parts[@]}" > 0)); then
|
||||||
|
|
|
@ -27,13 +27,11 @@ ynh_backup() {
|
||||||
local is_data=false
|
local is_data=false
|
||||||
|
|
||||||
# If the path starts with /var/log/$app or $data_dir
|
# If the path starts with /var/log/$app or $data_dir
|
||||||
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]])
|
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]]); then
|
||||||
then
|
|
||||||
is_data=true
|
is_data=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
local do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
local do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -135,15 +133,13 @@ ynh_restore() {
|
||||||
|
|
||||||
# If the path starts with /var/log/$app or $data_dir
|
# If the path starts with /var/log/$app or $data_dir
|
||||||
local is_data=false
|
local is_data=false
|
||||||
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]])
|
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]]); then
|
||||||
then
|
|
||||||
is_data=true
|
is_data=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If archive_path doesn't exist, search for a corresponding path in CSV
|
# If archive_path doesn't exist, search for a corresponding path in CSV
|
||||||
if [ ! -d "$archive_path" ] && [ ! -f "$archive_path" ] && [ ! -L "$archive_path" ]; then
|
if [ ! -d "$archive_path" ] && [ ! -f "$archive_path" ] && [ ! -L "$archive_path" ]; then
|
||||||
if [[ "$is_data" == true ]]
|
if [[ "$is_data" == true ]]; then
|
||||||
then
|
|
||||||
ynh_print_info "Skipping $target which doesn't exists in the archive, probably because restoring from a safety-backup-before-upgrade"
|
ynh_print_info "Skipping $target which doesn't exists in the archive, probably because restoring from a safety-backup-before-upgrade"
|
||||||
# Assume it's not a big deal, we may be restoring a safety-backup-before-upgrade which doesnt contain those
|
# Assume it's not a big deal, we may be restoring a safety-backup-before-upgrade which doesnt contain those
|
||||||
return 0
|
return 0
|
||||||
|
@ -256,8 +252,7 @@ ynh_backup_if_checksum_is_different() {
|
||||||
echo "$backup_file_checksum" # Return the name of the backup file
|
echo "$backup_file_checksum" # Return the name of the backup file
|
||||||
if ynh_in_ci_tests; then
|
if ynh_in_ci_tests; then
|
||||||
local file_path_base64=$(echo "$file" | base64 -w0)
|
local file_path_base64=$(echo "$file" | base64 -w0)
|
||||||
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}
|
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}; then
|
||||||
then
|
|
||||||
ynh_print_warn "Diff with the original file:"
|
ynh_print_warn "Diff with the original file:"
|
||||||
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -84,8 +84,7 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "${!short_setting}" != "$bind_file" ]]; then
|
if [[ "${!short_setting}" != "$bind_file" ]]; then
|
||||||
cp "${!short_setting}" "$bind_file"
|
cp "${!short_setting}" "$bind_file"
|
||||||
fi
|
fi
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
ynh_print_info "File '$bind_file' overwritten with ${!short_setting}"
|
ynh_print_info "File '$bind_file' overwritten with ${!short_setting}"
|
||||||
|
@ -104,8 +103,7 @@ _ynh_app_config_apply_one() {
|
||||||
local bind_file="$bind"
|
local bind_file="$bind"
|
||||||
ynh_backup_if_checksum_is_different "$bind_file"
|
ynh_backup_if_checksum_is_different "$bind_file"
|
||||||
echo "${!short_setting}" > "$bind_file"
|
echo "${!short_setting}" > "$bind_file"
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
ynh_print_info "File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
ynh_print_info "File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
||||||
|
@ -123,8 +121,7 @@ _ynh_app_config_apply_one() {
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$bind_file"
|
ynh_backup_if_checksum_is_different "$bind_file"
|
||||||
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -307,5 +304,6 @@ ynh_app_config_run() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ynh_app_action_run $1
|
ynh_app_action_run $1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,7 @@ ynh_handle_getopts_args() {
|
||||||
eval "$xtrace_enable"
|
eval "$xtrace_enable"
|
||||||
return
|
return
|
||||||
# Validate that the first char is - because it should be something like --option=value or -o ...
|
# Validate that the first char is - because it should be something like --option=value or -o ...
|
||||||
elif [[ "${1:0:1}" != "-" ]]
|
elif [[ "${1:0:1}" != "-" ]]; then
|
||||||
then
|
|
||||||
ynh_die "It looks like you called the helper using positional arguments instead of keyword arguments ?"
|
ynh_die "It looks like you called the helper using positional arguments instead of keyword arguments ?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -156,29 +156,24 @@ _ynh_go_cleanup () {
|
||||||
# List required Go versions
|
# List required Go versions
|
||||||
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
local required_go_versions=""
|
local required_go_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
||||||
if [[ $installed_app_go_version ]]
|
if [[ $installed_app_go_version ]]; then
|
||||||
then
|
|
||||||
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Go versions
|
# Remove no more needed Go versions
|
||||||
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_go_version in $installed_go_versions
|
for installed_go_version in $installed_go_versions; do
|
||||||
do
|
if ! $(echo ${required_go_versions} | grep "${installed_go_version}" 1> /dev/null 2>&1); then
|
||||||
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
|
||||||
then
|
|
||||||
ynh_print_info "Removing of Go-$installed_go_version"
|
ynh_print_info "Removing of Go-$installed_go_version"
|
||||||
$GOENV_INSTALL_DIR/bin/goenv uninstall --force "$installed_go_version"
|
$GOENV_INSTALL_DIR/bin/goenv uninstall --force "$installed_go_version"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Go version is required
|
# If none Go version is required
|
||||||
if [[ ! $required_go_versions ]]
|
if [[ ! $required_go_versions ]]; then
|
||||||
then
|
|
||||||
# Remove goenv environment configuration
|
# Remove goenv environment configuration
|
||||||
ynh_print_info "Removing of goenv"
|
ynh_print_info "Removing of goenv"
|
||||||
ynh_safe_rm "$GOENV_INSTALL_DIR"
|
ynh_safe_rm "$GOENV_INSTALL_DIR"
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
# usage: ynh_die "Some message"
|
# usage: ynh_die "Some message"
|
||||||
ynh_die() {
|
ynh_die() {
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
if [[ -n "${1:-}" ]]
|
if [[ -n "${1:-}" ]]; then
|
||||||
then
|
if [[ -n "${YNH_STDRETURN:-}" ]]; then
|
||||||
if [[ -n "${YNH_STDRETURN:-}" ]]
|
|
||||||
then
|
|
||||||
python3 -c 'import yaml, sys; print(yaml.dump({"error": sys.stdin.read()}))' <<< "${1:-}" >> "$YNH_STDRETURN"
|
python3 -c 'import yaml, sys; print(yaml.dump({"error": sys.stdin.read()}))' <<< "${1:-}" >> "$YNH_STDRETURN"
|
||||||
fi
|
fi
|
||||||
echo "${1:-}" 1>&2
|
echo "${1:-}" 1>&2
|
||||||
|
@ -105,8 +103,7 @@ ynh_script_progression() {
|
||||||
local expected_progression="$((($increment_progression + 1) * $progress_scale / $max_progression - $effective_progression))"
|
local expected_progression="$((($increment_progression + 1) * $progress_scale / $max_progression - $effective_progression))"
|
||||||
|
|
||||||
# Hack for the "--last" message
|
# Hack for the "--last" message
|
||||||
if grep -qw 'completed' <<< "$1";
|
if grep -qw 'completed' <<< "$1"; then
|
||||||
then
|
|
||||||
effective_progression=$progress_scale
|
effective_progression=$progress_scale
|
||||||
expected_progression=0
|
expected_progression=0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -22,8 +22,7 @@ ynh_config_add_logrotate() {
|
||||||
fi
|
fi
|
||||||
set +o noglob
|
set +o noglob
|
||||||
|
|
||||||
for stuff in $logfile
|
for stuff in $logfile; do
|
||||||
do
|
|
||||||
# Make sure the permissions of the parent dir are correct (otherwise the config file could be ignored and the corresponding logs never rotated)
|
# Make sure the permissions of the parent dir are correct (otherwise the config file could be ignored and the corresponding logs never rotated)
|
||||||
local dir=$(dirname "$stuff")
|
local dir=$(dirname "$stuff")
|
||||||
mkdir --parents $dir
|
mkdir --parents $dir
|
||||||
|
@ -53,8 +52,7 @@ $logfile {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]
|
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]; then
|
||||||
then
|
|
||||||
cat $tempconf > /etc/logrotate.d/$app
|
cat $tempconf > /etc/logrotate.d/$app
|
||||||
else
|
else
|
||||||
cat $tempconf >> /etc/logrotate.d/$app
|
cat $tempconf >> /etc/logrotate.d/$app
|
||||||
|
|
|
@ -19,8 +19,7 @@ ynh_mongo_exec() {
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]
|
if [ -n "$database" ]; then
|
||||||
then
|
|
||||||
mongosh --quiet << EOF
|
mongosh --quiet << EOF
|
||||||
use $database
|
use $database
|
||||||
${command}
|
${command}
|
||||||
|
@ -111,8 +110,7 @@ ynh_mongo_database_exists() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")') -lt 0 ]
|
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")') -lt 0 ]; then
|
||||||
then
|
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
@ -262,8 +260,7 @@ ynh_install_mongo() {
|
||||||
#
|
#
|
||||||
ynh_remove_mongo() {
|
ynh_remove_mongo() {
|
||||||
# Only remove the mongodb service if it is not installed.
|
# Only remove the mongodb service if it is not installed.
|
||||||
if ! _ynh_apt_package_is_installed "mongodb*"
|
if ! _ynh_apt_package_is_installed "mongodb*"; then
|
||||||
then
|
|
||||||
ynh_print_info "Removing MongoDB service..."
|
ynh_print_info "Removing MongoDB service..."
|
||||||
mongodb_servicename=mongod
|
mongodb_servicename=mongod
|
||||||
# Remove the mongodb service
|
# Remove the mongodb service
|
||||||
|
|
|
@ -39,7 +39,6 @@ ynh_config_remove_nginx() {
|
||||||
ynh_systemctl --service=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Regen the nginx config in a change url context
|
# Regen the nginx config in a change url context
|
||||||
#
|
#
|
||||||
# usage: ynh_config_change_url_nginx
|
# usage: ynh_config_change_url_nginx
|
||||||
|
|
|
@ -13,10 +13,8 @@ ynh_redis_get_free_db() {
|
||||||
|
|
||||||
db=0
|
db=0
|
||||||
# default Debian setting is 15 databases
|
# default Debian setting is 15 databases
|
||||||
for i in $(seq 0 "$max")
|
for i in $(seq 0 "$max"); do
|
||||||
do
|
if ! echo "$result" | grep -q "db$i"; then
|
||||||
if ! echo "$result" | grep -q "db$i"
|
|
||||||
then
|
|
||||||
db=$i
|
db=$i
|
||||||
break 1
|
break 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -153,8 +153,7 @@ ynh_ruby_install () {
|
||||||
ruby_version=$final_ruby_version
|
ruby_version=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if rbenv alias --list | grep --quiet "$app "
|
if rbenv alias --list | grep --quiet "$app "; then
|
||||||
then
|
|
||||||
rbenv alias $app --remove
|
rbenv alias $app --remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -213,29 +212,24 @@ _ynh_ruby_cleanup () {
|
||||||
# List required Ruby versions
|
# List required Ruby versions
|
||||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
local required_ruby_versions=""
|
local required_ruby_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||||
if [[ -n "$installed_app_ruby_version" ]]
|
if [[ -n "$installed_app_ruby_version" ]]; then
|
||||||
then
|
|
||||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Ruby versions
|
# Remove no more needed Ruby versions
|
||||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_ruby_version in $installed_ruby_versions
|
for installed_ruby_version in $installed_ruby_versions; do
|
||||||
do
|
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"; then
|
||||||
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
|
||||||
then
|
|
||||||
echo "Removing Ruby-$installed_ruby_version"
|
echo "Removing Ruby-$installed_ruby_version"
|
||||||
$RBENV_INSTALL_DIR/bin/rbenv uninstall --force $installed_ruby_version
|
$RBENV_INSTALL_DIR/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Ruby version is required
|
# If none Ruby version is required
|
||||||
if [[ -z "$required_ruby_versions" ]]
|
if [[ -z "$required_ruby_versions" ]]; then
|
||||||
then
|
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
echo "Removing rbenv"
|
echo "Removing rbenv"
|
||||||
ynh_safe_rm "$RBENV_INSTALL_DIR"
|
ynh_safe_rm "$RBENV_INSTALL_DIR"
|
||||||
|
|
|
@ -125,15 +125,11 @@ EOF
|
||||||
|
|
||||||
# Legacy: auto-convert phpversion to php_version (for consistency with nodejs_version, ruby_version, ...)
|
# Legacy: auto-convert phpversion to php_version (for consistency with nodejs_version, ruby_version, ...)
|
||||||
# This has to be here and not in the "php" code file because ynh_app_setting_set/delete need to be defined @_@
|
# This has to be here and not in the "php" code file because ynh_app_setting_set/delete need to be defined @_@
|
||||||
if [[ -n "${app:-}" ]] && [[ -n "${phpversion:-}" ]]
|
if [[ -n "${app:-}" ]] && [[ -n "${phpversion:-}" ]]; then
|
||||||
then
|
if [[ -z "${php_version:-}" ]]; then
|
||||||
if [[ -z "${php_version:-}" ]]
|
|
||||||
then
|
|
||||||
php_version=$phpversion
|
php_version=$phpversion
|
||||||
ynh_app_setting_set --key=php_version --value=$php_version
|
ynh_app_setting_set --key=php_version --value=$php_version
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_delete --key=phpversion
|
ynh_app_setting_delete --key=phpversion
|
||||||
unset phpversion
|
unset phpversion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,7 @@ ynh_setup_source() {
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
local sources_json=$(ynh_read_manifest "resources.sources[\"$source_id\"]")
|
local sources_json=$(ynh_read_manifest "resources.sources[\"$source_id\"]")
|
||||||
if jq -re ".url" <<< "$sources_json"
|
if jq -re ".url" <<< "$sources_json"; then
|
||||||
then
|
|
||||||
local arch_prefix=""
|
local arch_prefix=""
|
||||||
else
|
else
|
||||||
local arch_prefix=".$YNH_ARCH"
|
local arch_prefix=".$YNH_ARCH"
|
||||||
|
@ -93,25 +92,18 @@ ynh_setup_source() {
|
||||||
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
||||||
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
||||||
|
|
||||||
if [[ -z "$src_format" ]]
|
if [[ -z "$src_format" ]]; then
|
||||||
then
|
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]; then
|
||||||
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]
|
|
||||||
then
|
|
||||||
src_format="zip"
|
src_format="zip"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.gz"
|
src_format="tar.gz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.xz"
|
src_format="tar.xz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.bz2"
|
src_format="tar.bz2"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar"
|
src_format="tar"
|
||||||
elif [[ -z "$src_extract" ]]
|
elif [[ -z "$src_extract" ]]; then
|
||||||
then
|
|
||||||
src_extract="false"
|
src_extract="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -120,8 +112,7 @@ ynh_setup_source() {
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
|
|
||||||
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]
|
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]; then
|
||||||
then
|
|
||||||
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -135,14 +126,12 @@ ynh_setup_source() {
|
||||||
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
||||||
|
|
||||||
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
||||||
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | sha256sum --check --status
|
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | sha256sum --check --status; then
|
||||||
then
|
|
||||||
rm -f "$src_filename"
|
rm -f "$src_filename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only redownload the file if it wasnt prefetched
|
# Only redownload the file if it wasnt prefetched
|
||||||
if [ ! -e "$src_filename" ]
|
if [ ! -e "$src_filename" ]; then
|
||||||
then
|
|
||||||
# NB. we have to declare the var as local first,
|
# NB. we have to declare the var as local first,
|
||||||
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
||||||
# because local always return 0 ...
|
# because local always return 0 ...
|
||||||
|
@ -153,8 +142,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
if ! echo "${src_sum} ${src_filename}" | sha256sum --check --status
|
if ! echo "${src_sum} ${src_filename}" | sha256sum --check --status; then
|
||||||
then
|
|
||||||
local actual_sum="$(sha256sum ${src_filename} | cut --delimiter=' ' --fields=1)"
|
local actual_sum="$(sha256sum ${src_filename} | cut --delimiter=' ' --fields=1)"
|
||||||
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
||||||
rm -f ${src_filename}
|
rm -f ${src_filename}
|
||||||
|
@ -185,8 +173,7 @@ ynh_setup_source() {
|
||||||
mkdir --parents "$dest_dir"
|
mkdir --parents "$dest_dir"
|
||||||
|
|
||||||
if [[ "$src_extract" == "false" ]]; then
|
if [[ "$src_extract" == "false" ]]; then
|
||||||
if [[ -z "$src_rename" ]]
|
if [[ -z "$src_rename" ]]; then
|
||||||
then
|
|
||||||
mv $src_filename $dest_dir
|
mv $src_filename $dest_dir
|
||||||
else
|
else
|
||||||
mv $src_filename $dest_dir/$src_rename
|
mv $src_filename $dest_dir/$src_rename
|
||||||
|
|
|
@ -68,8 +68,7 @@ ynh_systemctl() {
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
# On CI, use length=100 because it's sometime hell to debug otherwise for super-long output
|
# On CI, use length=100 because it's sometime hell to debug otherwise for super-long output
|
||||||
if ynh_in_ci_tests && [ $length -le 20 ]
|
if ynh_in_ci_tests && [ $length -le 20 ]; then
|
||||||
then
|
|
||||||
length=100
|
length=100
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -139,8 +138,7 @@ ynh_systemctl() {
|
||||||
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
||||||
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
||||||
# instead of 5 min ...
|
# instead of 5 min ...
|
||||||
if [[ "$(( $(date +%s) - $starttime))" -gt "$timeout" ]]
|
if [[ "$(($(date +%s) - $starttime))" -gt "$timeout" ]]; then
|
||||||
then
|
|
||||||
i=$timeout
|
i=$timeout
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -160,8 +158,7 @@ ynh_systemctl() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we tried to reload/start/restart the service but systemctl consider it to be still inactive/broken, then handle it as a failure
|
# If we tried to reload/start/restart the service but systemctl consider it to be still inactive/broken, then handle it as a failure
|
||||||
if ([ "$action" == "reload" ] || [ "$action" == "start" ] || [ "$action" == "restart" ]) && ! systemctl --quiet is-active $service
|
if ([ "$action" == "reload" ] || [ "$action" == "start" ] || [ "$action" == "restart" ]) && ! systemctl --quiet is-active $service; then
|
||||||
then
|
|
||||||
_ynh_clean_check_starting
|
_ynh_clean_check_starting
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -70,8 +70,7 @@ ynh_config_add() {
|
||||||
chmod 640 $destination
|
chmod 640 $destination
|
||||||
_ynh_apply_default_permissions $destination
|
_ynh_apply_default_permissions $destination
|
||||||
|
|
||||||
if [[ "$jinja" == 1 ]]
|
if [[ "$jinja" == 1 ]]; then
|
||||||
then
|
|
||||||
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
||||||
(
|
(
|
||||||
export $(compgen -v)
|
export $(compgen -v)
|
||||||
|
|
|
@ -9,8 +9,7 @@ YNH_APP_BASEDIR=${YNH_APP_BASEDIR:-$(realpath ..)}
|
||||||
ynh_exit_properly() {
|
ynh_exit_properly() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
|
|
||||||
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]
|
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]; then
|
||||||
then
|
|
||||||
rm -rf "/var/cache/yunohost/download/"
|
rm -rf "/var/cache/yunohost/download/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -47,8 +46,7 @@ ynh_abort_if_errors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# When running an app script, auto-enable ynh_abort_if_errors except for remove script
|
# When running an app script, auto-enable ynh_abort_if_errors except for remove script
|
||||||
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && [[ "${YNH_APP_ACTION}" != "remove" ]]
|
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && [[ "${YNH_APP_ACTION}" != "remove" ]]; then
|
||||||
then
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -124,8 +122,7 @@ _acceptable_path_to_delete() {
|
||||||
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
||||||
|
|
||||||
# Legacy : A couple apps still have data in /home/$app ...
|
# Legacy : A couple apps still have data in /home/$app ...
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -231,23 +228,19 @@ _ynh_apply_default_permissions() {
|
||||||
# App files can have files of their own
|
# App files can have files of their own
|
||||||
if ynh_system_user_exists --username="$app"; then
|
if ynh_system_user_exists --username="$app"; then
|
||||||
# If this is a file in $install_dir or $data_dir : it should be owned and read+writable by $app only
|
# If this is a file in $install_dir or $data_dir : it should be owned and read+writable by $app only
|
||||||
if [ -f "$target" ] && (is_in_dir "$target" "${install_dir:-}" || is_in_dir "$target" "${data_dir:-}" || is_in_dir "$target" "/etc/$app")
|
if [ -f "$target" ] && (is_in_dir "$target" "${install_dir:-}" || is_in_dir "$target" "${data_dir:-}" || is_in_dir "$target" "/etc/$app"); then
|
||||||
then
|
|
||||||
chmod 600 "$target"
|
chmod 600 "$target"
|
||||||
chown "$app:$app" "$target"
|
chown "$app:$app" "$target"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# If this is the install dir (so far this is the only way this helper is called with a directory)
|
# If this is the install dir (so far this is the only way this helper is called with a directory)
|
||||||
if [ "$target" == "${install_dir:-}" ]
|
if [ "$target" == "${install_dir:-}" ]; then
|
||||||
then
|
|
||||||
# Read the group from the install_dir manifest resource
|
# Read the group from the install_dir manifest resource
|
||||||
local group="$(ynh_read_manifest 'resources.install_dir.group' | sed 's/null//g' | sed "s/__APP__/$app/g" | cut -f1 -d:)"
|
local group="$(ynh_read_manifest 'resources.install_dir.group' | sed 's/null//g' | sed "s/__APP__/$app/g" | cut -f1 -d:)"
|
||||||
if [[ -z "$group" ]]
|
if [[ -z "$group" ]]; then
|
||||||
then
|
|
||||||
# We set the group to www-data for webapps that do serve static assets, which therefore need to be readable by nginx ...
|
# We set the group to www-data for webapps that do serve static assets, which therefore need to be readable by nginx ...
|
||||||
# The fact that the app needs this is infered by the existence of an nginx.conf and the presence of "alias" or "root" directive
|
# The fact that the app needs this is infered by the existence of an nginx.conf and the presence of "alias" or "root" directive
|
||||||
if grep -q '^\s*alias\s\|^\s*root\s' "$YNH_APP_BASEDIR/conf/nginx.conf" 2>/dev/null;
|
if grep -q '^\s*alias\s\|^\s*root\s' "$YNH_APP_BASEDIR/conf/nginx.conf" 2> /dev/null; then
|
||||||
then
|
|
||||||
group="www-data"
|
group="www-data"
|
||||||
# Or default to "$app"
|
# Or default to "$app"
|
||||||
else
|
else
|
||||||
|
@ -407,41 +400,37 @@ ynh_spawn_app_shell() {
|
||||||
|
|
||||||
# Load the app's service name, or default to $app
|
# 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 --app=$app --key=service)
|
||||||
[ -z "$service" ] && service=$app;
|
[ -z "$service" ] && service=$app
|
||||||
|
|
||||||
# Export HOME variable
|
# Export HOME variable
|
||||||
export HOME=$install_dir;
|
export HOME=$install_dir
|
||||||
|
|
||||||
# Load the Environment variables from the app's service
|
# Load the Environment variables from the app's service
|
||||||
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
||||||
[ -n "$env_var" ] && export $env_var;
|
[ -n "$env_var" ] && export $env_var
|
||||||
|
|
||||||
# Force `php` to its intended version
|
# Force `php` to its intended version
|
||||||
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
# 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 phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
||||||
if [ -n "$phpversion" ]
|
if [ -n "$phpversion" ]; then
|
||||||
then
|
|
||||||
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
||||||
export -f php
|
export -f php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source the EnvironmentFiles from the app's service
|
# Source the EnvironmentFiles from the app's service
|
||||||
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
||||||
if [ ${#env_files[*]} -gt 0 ]
|
if [ ${#env_files[*]} -gt 0 ]; then
|
||||||
then
|
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
set -a
|
set -a
|
||||||
for file in ${env_files[*]}
|
for file in ${env_files[*]}; do
|
||||||
do
|
|
||||||
[[ $file = /* ]] && source $file
|
[[ $file = /* ]] && source $file
|
||||||
done
|
done
|
||||||
set +a
|
set +a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Activate the Python environment, if it exists
|
# Activate the Python environment, if it exists
|
||||||
if [ -f $install_dir/venv/bin/activate ]
|
if [ -f $install_dir/venv/bin/activate ]; then
|
||||||
then
|
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
set -a
|
set -a
|
||||||
source $install_dir/venv/bin/activate
|
source $install_dir/venv/bin/activate
|
||||||
|
@ -450,7 +439,7 @@ ynh_spawn_app_shell() {
|
||||||
|
|
||||||
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
||||||
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
||||||
[ -z $env_dir ] && env_dir=$install_dir;
|
[ -z $env_dir ] && env_dir=$install_dir
|
||||||
cd $env_dir
|
cd $env_dir
|
||||||
|
|
||||||
# Spawn the app shell
|
# Spawn the app shell
|
||||||
|
@ -482,25 +471,20 @@ ynh_add_swap () {
|
||||||
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
|
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
|
||||||
|
|
||||||
# Swap on SD card only if it's is specified
|
# Swap on SD card only if it's is specified
|
||||||
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
|
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]; then
|
||||||
then
|
|
||||||
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
|
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compare the available space with the size of the swap.
|
# Compare the available space with the size of the swap.
|
||||||
# And set a acceptable size from the request
|
# And set a acceptable size from the request
|
||||||
if [ $usable_space -ge $swap_max_size ]
|
if [ $usable_space -ge $swap_max_size ]; then
|
||||||
then
|
|
||||||
local swap_size=$swap_max_size
|
local swap_size=$swap_max_size
|
||||||
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
|
elif [ $usable_space -ge $(($swap_max_size / 2)) ]; then
|
||||||
then
|
|
||||||
local swap_size=$(($swap_max_size / 2))
|
local swap_size=$(($swap_max_size / 2))
|
||||||
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
|
elif [ $usable_space -ge $(($swap_max_size / 3)) ]; then
|
||||||
then
|
|
||||||
local swap_size=$(($swap_max_size / 3))
|
local swap_size=$(($swap_max_size / 3))
|
||||||
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
|
elif [ $usable_space -ge $(($swap_max_size / 4)) ]; then
|
||||||
then
|
|
||||||
local swap_size=$(($swap_max_size / 4))
|
local swap_size=$(($swap_max_size / 4))
|
||||||
else
|
else
|
||||||
echo "Not enough space left for a swap file" >&2
|
echo "Not enough space left for a swap file" >&2
|
||||||
|
@ -508,8 +492,7 @@ ynh_add_swap () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If there's enough space for a swap, and no existing swap here
|
# If there's enough space for a swap, and no existing swap here
|
||||||
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
|
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]; then
|
||||||
then
|
|
||||||
# Create file
|
# Create file
|
||||||
truncate -s 0 /swap_$app
|
truncate -s 0 /swap_$app
|
||||||
|
|
||||||
|
@ -517,8 +500,7 @@ ynh_add_swap () {
|
||||||
chattr +C /swap_$app
|
chattr +C /swap_$app
|
||||||
|
|
||||||
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
||||||
if ! fallocate -l ${swap_size}K /swap_$app
|
if ! fallocate -l ${swap_size}K /swap_$app; then
|
||||||
then
|
|
||||||
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
||||||
fi
|
fi
|
||||||
chmod 0600 /swap_$app
|
chmod 0600 /swap_$app
|
||||||
|
@ -533,8 +515,7 @@ ynh_add_swap () {
|
||||||
|
|
||||||
ynh_del_swap() {
|
ynh_del_swap() {
|
||||||
# If there a swap at this place
|
# If there a swap at this place
|
||||||
if [ -e /swap_$app ]
|
if [ -e /swap_$app ]; then
|
||||||
then
|
|
||||||
# Clean the fstab
|
# Clean the fstab
|
||||||
sed -i "/#Swap added by $app/d" /etc/fstab
|
sed -i "/#Swap added by $app/d" /etc/fstab
|
||||||
# Desactive the swap file
|
# Desactive the swap file
|
||||||
|
@ -557,8 +538,7 @@ ynh_is_main_device_a_sd_card () {
|
||||||
|
|
||||||
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
||||||
|
|
||||||
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
|
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]; then
|
||||||
then
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -74,8 +74,7 @@ do_init_regen() {
|
||||||
|
|
||||||
# Change dpkg vendor
|
# Change dpkg vendor
|
||||||
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
||||||
if readlink -f /etc/dpkg/origins/default | grep -q debian;
|
if readlink -f /etc/dpkg/origins/default | grep -q debian; then
|
||||||
then
|
|
||||||
rm -f /etc/dpkg/origins/default
|
rm -f /etc/dpkg/origins/default
|
||||||
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
||||||
fi
|
fi
|
||||||
|
@ -129,8 +128,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip ntp if inside a container (inspired from the conf of systemd-timesyncd)
|
# Skip ntp if inside a container (inspired from the conf of systemd-timesyncd)
|
||||||
if systemctl | grep -q 'ntp.service'
|
if systemctl | grep -q 'ntp.service'; then
|
||||||
then
|
|
||||||
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
|
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
|
||||||
cat > ${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf << EOF
|
cat > ${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf << EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
|
@ -192,8 +190,7 @@ do_post_regen() {
|
||||||
find /etc/systemd/system/*.service -type f | xargs -r chown root:root
|
find /etc/systemd/system/*.service -type f | xargs -r chown root:root
|
||||||
find /etc/systemd/system/*.service -type f | xargs -r chmod 0644
|
find /etc/systemd/system/*.service -type f | xargs -r chmod 0644
|
||||||
|
|
||||||
if ls -l /etc/php/*/fpm/pool.d/*.conf
|
if ls -l /etc/php/*/fpm/pool.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/php/*/fpm/pool.d/*.conf
|
chown root:root /etc/php/*/fpm/pool.d/*.conf
|
||||||
chmod 644 /etc/php/*/fpm/pool.d/*.conf
|
chmod 644 /etc/php/*/fpm/pool.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
@ -235,8 +232,7 @@ do_post_regen() {
|
||||||
grep -q '^sftp.app:' /etc/group || groupadd sftp.app
|
grep -q '^sftp.app:' /etc/group || groupadd sftp.app
|
||||||
|
|
||||||
# Propagates changes in systemd service config overrides
|
# Propagates changes in systemd service config overrides
|
||||||
if systemctl | grep -q 'ntp.service'
|
if systemctl | grep -q 'ntp.service'; then
|
||||||
then
|
|
||||||
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
|
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart ntp
|
systemctl restart ntp
|
||||||
|
@ -263,14 +259,12 @@ do_post_regen() {
|
||||||
|
|
||||||
# Change dpkg vendor
|
# Change dpkg vendor
|
||||||
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
||||||
if readlink -f /etc/dpkg/origins/default | grep -q debian;
|
if readlink -f /etc/dpkg/origins/default | grep -q debian; then
|
||||||
then
|
|
||||||
rm -f /etc/dpkg/origins/default
|
rm -f /etc/dpkg/origins/default
|
||||||
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -e /etc/yunohost/installed && test -e /etc/profile.d/check_yunohost_is_installed.sh
|
if test -e /etc/yunohost/installed && test -e /etc/profile.d/check_yunohost_is_installed.sh; then
|
||||||
then
|
|
||||||
rm /etc/profile.d/check_yunohost_is_installed.sh
|
rm /etc/profile.d/check_yunohost_is_installed.sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,7 @@ do_post_regen() {
|
||||||
main_domain=$(cat /etc/yunohost/current_host)
|
main_domain=$(cat /etc/yunohost/current_host)
|
||||||
|
|
||||||
# Automigrate legacy folder
|
# Automigrate legacy folder
|
||||||
if [ -e /usr/share/yunohost/yunohost-config/ssl/yunoCA ]
|
if [ -e /usr/share/yunohost/yunohost-config/ssl/yunoCA ]; then
|
||||||
then
|
|
||||||
mv /usr/share/yunohost/yunohost-config/ssl/yunoCA/* ${ssl_dir}
|
mv /usr/share/yunohost/yunohost-config/ssl/yunoCA/* ${ssl_dir}
|
||||||
rm -rf /usr/share/yunohost/yunohost-config
|
rm -rf /usr/share/yunohost/yunohost-config
|
||||||
# Overwrite openssl.cnf because it may still contain references to the old yunoCA dir
|
# Overwrite openssl.cnf because it may still contain references to the old yunoCA dir
|
||||||
|
|
|
@ -56,7 +56,6 @@ Pin: release *
|
||||||
Pin-Priority: -1
|
Pin-Priority: -1
|
||||||
" >> "${pending_dir}/etc/apt/preferences.d/ban_packages"
|
" >> "${pending_dir}/etc/apt/preferences.d/ban_packages"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
|
@ -68,14 +67,12 @@ do_post_regen() {
|
||||||
|
|
||||||
# Add sury key
|
# Add sury key
|
||||||
# We do this only at the post regen and if the key doesn't already exists, because we don't want the regenconf to fuck everything up if the regenconf runs while the network is down
|
# We do this only at the post regen and if the key doesn't already exists, because we don't want the regenconf to fuck everything up if the regenconf runs while the network is down
|
||||||
if [[ ! -s /etc/apt/trusted.gpg.d/extra_php_version.gpg ]]
|
if [[ ! -s /etc/apt/trusted.gpg.d/extra_php_version.gpg ]]; then
|
||||||
then
|
|
||||||
wget --timeout 900 --quiet "https://packages.sury.org/php/apt.gpg" --output-document=- | gpg --dearmor > "/etc/apt/trusted.gpg.d/extra_php_version.gpg"
|
wget --timeout 900 --quiet "https://packages.sury.org/php/apt.gpg" --output-document=- | gpg --dearmor > "/etc/apt/trusted.gpg.d/extra_php_version.gpg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure php7.4 is the default version when using php in cli
|
# Make sure php7.4 is the default version when using php in cli
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! dpkg --list | grep -q 'ii *metronome '
|
if ! dpkg --list | grep -q 'ii *metronome '; then
|
||||||
then
|
|
||||||
echo 'metronome is not installed, skipping'
|
echo 'metronome is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -74,15 +73,12 @@ do_post_regen() {
|
||||||
chown -R metronome: /var/lib/metronome/
|
chown -R metronome: /var/lib/metronome/
|
||||||
chown -R metronome: /etc/metronome/conf.d/
|
chown -R metronome: /etc/metronome/conf.d/
|
||||||
|
|
||||||
if [[ -z "$(ls /etc/metronome/conf.d/*.cfg.lua 2>/dev/null)" ]]
|
if [[ -z "$(ls /etc/metronome/conf.d/*.cfg.lua 2> /dev/null)" ]]; then
|
||||||
then
|
if systemctl is-enabled metronome &> /dev/null; then
|
||||||
if systemctl is-enabled metronome &>/dev/null
|
|
||||||
then
|
|
||||||
systemctl disable metronome --now 2> /dev/null
|
systemctl disable metronome --now 2> /dev/null
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if ! systemctl is-enabled metronome &>/dev/null
|
if ! systemctl is-enabled metronome &> /dev/null; then
|
||||||
then
|
|
||||||
systemctl enable metronome --now 2> /dev/null
|
systemctl enable metronome --now 2> /dev/null
|
||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -86,22 +86,19 @@ do_pre_regen() {
|
||||||
export domain_cert_ca=$(echo $cert_status \
|
export domain_cert_ca=$(echo $cert_status \
|
||||||
| jq ".certificates.\"$domain\".CA_type" \
|
| jq ".certificates.\"$domain\".CA_type" \
|
||||||
| tr -d '"')
|
| tr -d '"')
|
||||||
if echo "$xmpp_domain_list" | grep -q "^$domain$"
|
if echo "$xmpp_domain_list" | grep -q "^$domain$"; then
|
||||||
then
|
|
||||||
export xmpp_enabled="True"
|
export xmpp_enabled="True"
|
||||||
else
|
else
|
||||||
export xmpp_enabled="False"
|
export xmpp_enabled="False"
|
||||||
fi
|
fi
|
||||||
if echo "$mail_domain_list" | grep -q "^$domain$"
|
if echo "$mail_domain_list" | grep -q "^$domain$"; then
|
||||||
then
|
|
||||||
export mail_enabled="True"
|
export mail_enabled="True"
|
||||||
else
|
else
|
||||||
export mail_enabled="False"
|
export mail_enabled="False"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_render_template "server.tpl.conf" "${nginx_conf_dir}/${domain}.conf"
|
ynh_render_template "server.tpl.conf" "${nginx_conf_dir}/${domain}.conf"
|
||||||
if [ $mail_enabled == "True" ]
|
if [ $mail_enabled == "True" ]; then
|
||||||
then
|
|
||||||
ynh_render_template "autoconfig.tpl.xml" "${mail_autoconfig_dir}/config-v1.1.xml"
|
ynh_render_template "autoconfig.tpl.xml" "${mail_autoconfig_dir}/config-v1.1.xml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -144,8 +141,7 @@ do_pre_regen() {
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
if ls -l /etc/nginx/conf.d/*.d/*.conf
|
if ls -l /etc/nginx/conf.d/*.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/nginx/conf.d/*.d/*.conf
|
chown root:root /etc/nginx/conf.d/*.d/*.conf
|
||||||
chmod 644 /etc/nginx/conf.d/*.d/*.conf
|
chmod 644 /etc/nginx/conf.d/*.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -51,10 +51,8 @@ do_pre_regen() {
|
||||||
export backup_mx_emails="$(yunohost settings get 'email.smtp.smtp_backup_mx_emails_whitelisted' | sed "s/,/ /g")"
|
export backup_mx_emails="$(yunohost settings get 'email.smtp.smtp_backup_mx_emails_whitelisted' | sed "s/,/ /g")"
|
||||||
rm -f ${postfix_dir}/relay_recipients
|
rm -f ${postfix_dir}/relay_recipients
|
||||||
touch ${postfix_dir}/relay_recipients
|
touch ${postfix_dir}/relay_recipients
|
||||||
if [ -n "${backup_mx_domains}" ] && [ -n "${backup_mx_emails}" ]
|
if [ -n "${backup_mx_domains}" ] && [ -n "${backup_mx_emails}" ]; then
|
||||||
then
|
for mail in ${backup_mx_emails}; do
|
||||||
for mail in ${backup_mx_emails}
|
|
||||||
do
|
|
||||||
echo "$mail OK" >> ${postfix_dir}/relay_recipients
|
echo "$mail OK" >> ${postfix_dir}/relay_recipients
|
||||||
done
|
done
|
||||||
postmap ${postfix_dir}/relay_recipients
|
postmap ${postfix_dir}/relay_recipients
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
if ! dpkg --list | grep -q 'ii *mariadb-server '
|
if ! dpkg --list | grep -q 'ii *mariadb-server '; then
|
||||||
then
|
|
||||||
echo 'mysql/mariadb is not installed, skipping'
|
echo 'mysql/mariadb is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,18 +3,15 @@
|
||||||
set -e
|
set -e
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
if ! dpkg --list | grep -q "ii *postgresql-$PSQL_VERSION "
|
if ! dpkg --list | grep -q "ii *postgresql-$PSQL_VERSION "; then
|
||||||
then
|
|
||||||
echo 'postgresql is not installed, skipping'
|
echo 'postgresql is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "/etc/postgresql/$PSQL_VERSION" ]
|
if [ ! -e "/etc/postgresql/$PSQL_VERSION" ]; then
|
||||||
then
|
|
||||||
ynh_die --message="It looks like postgresql was not properly configured ? /etc/postgresql/$PSQL_VERSION is missing ... Could be due to a locale issue, c.f.https://serverfault.com/questions/426989/postgresql-etc-postgresql-doesnt-exist"
|
ynh_die --message="It looks like postgresql was not properly configured ? /etc/postgresql/$PSQL_VERSION is missing ... Could be due to a locale issue, c.f.https://serverfault.com/questions/426989/postgresql-etc-postgresql-doesnt-exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
do_pre_regen() {
|
do_pre_regen() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -35,7 +32,10 @@ do_post_regen() {
|
||||||
ynh_string_random > $PSQL_ROOT_PWD_FILE
|
ynh_string_random > $PSQL_ROOT_PWD_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -e $PSQL_ROOT_PWD_FILE ] || { chown root:postgres $PSQL_ROOT_PWD_FILE; chmod 440 $PSQL_ROOT_PWD_FILE; }
|
[ ! -e $PSQL_ROOT_PWD_FILE ] || {
|
||||||
|
chown root:postgres $PSQL_ROOT_PWD_FILE
|
||||||
|
chmod 440 $PSQL_ROOT_PWD_FILE
|
||||||
|
}
|
||||||
|
|
||||||
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$(cat $PSQL_ROOT_PWD_FILE)'" postgres
|
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$(cat $PSQL_ROOT_PWD_FILE)'" postgres
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ set -e
|
||||||
_generate_config() {
|
_generate_config() {
|
||||||
echo "domains:"
|
echo "domains:"
|
||||||
# Add yunohost.local (only if yunohost.local ain't already in ynh_domains)
|
# Add yunohost.local (only if yunohost.local ain't already in ynh_domains)
|
||||||
if ! echo "$YNH_DOMAINS" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'
|
if ! echo "$YNH_DOMAINS" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'; then
|
||||||
then
|
|
||||||
echo " - yunohost.local"
|
echo " - yunohost.local"
|
||||||
fi
|
fi
|
||||||
for domain in $YNH_DOMAINS; do
|
for domain in $YNH_DOMAINS; do
|
||||||
|
@ -15,10 +14,8 @@ _generate_config() {
|
||||||
[[ "$domain" =~ ^[^.]+\.local$ ]] || continue
|
[[ "$domain" =~ ^[^.]+\.local$ ]] || continue
|
||||||
echo " - $domain"
|
echo " - $domain"
|
||||||
done
|
done
|
||||||
if [[ -e /etc/yunohost/mdns.aliases ]]
|
if [[ -e /etc/yunohost/mdns.aliases ]]; then
|
||||||
then
|
for localalias in $(cat /etc/yunohost/mdns.aliases | grep -v "^ *$"); do
|
||||||
for localalias in $(cat /etc/yunohost/mdns.aliases | grep -v "^ *$")
|
|
||||||
do
|
|
||||||
echo " - $localalias.local"
|
echo " - $localalias.local"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -51,8 +51,7 @@ do_pre_regen() {
|
||||||
conf_files=$(ls -1 /etc/dnsmasq.d \
|
conf_files=$(ls -1 /etc/dnsmasq.d \
|
||||||
| awk '/^[^\.]+\.[^\.]+.*$/ { print $1 }')
|
| awk '/^[^\.]+\.[^\.]+.*$/ { print $1 }')
|
||||||
for domain in $conf_files; do
|
for domain in $conf_files; do
|
||||||
if [[ ! $YNH_DOMAINS =~ $domain ]] && [[ ! $domain =~ \.local$ ]]
|
if [[ ! $YNH_DOMAINS =~ $domain ]] && [[ ! $domain =~ \.local$ ]]; then
|
||||||
then
|
|
||||||
touch "${dnsmasq_dir}/${domain}"
|
touch "${dnsmasq_dir}/${domain}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -24,8 +24,7 @@ do_pre_regen() {
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
if ls -l /etc/fail2ban/jail.d/*.conf
|
if ls -l /etc/fail2ban/jail.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/fail2ban/jail.d/*.conf
|
chown root:root /etc/fail2ban/jail.d/*.conf
|
||||||
chmod 644 /etc/fail2ban/jail.d/*.conf
|
chmod 644 /etc/fail2ban/jail.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue