diff --git a/hooks/post_app_install b/hooks/post_app_install index 8c20e3e..5280790 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -1,3 +1,3 @@ #!/bin/bash -bash __INSTALL_DIR__/update_config_if_needed.sh +bash __INSTALL_DIR__/update_config_if_needed.sh install diff --git a/hooks/post_app_remove b/hooks/post_app_remove index 8c20e3e..6dd5b97 100644 --- a/hooks/post_app_remove +++ b/hooks/post_app_remove @@ -1,3 +1,3 @@ #!/bin/bash -bash __INSTALL_DIR__/update_config_if_needed.sh +bash __INSTALL_DIR__/update_config_if_needed.sh remove diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 8c20e3e..aa8cbdd 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -1,3 +1,3 @@ #!/bin/bash -bash __INSTALL_DIR__/update_config_if_needed.sh +bash __INSTALL_DIR__/update_config_if_needed.sh upgrade diff --git a/scripts/_common.sh b/scripts/_common.sh index 10b6dd2..199a9d8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -80,7 +80,7 @@ load_vars() { readonly net_gateway="$(ip --json route show default | jq -r '.[0].dev')" readonly net_interface_list="$(ip --json link show | jq -r '.[].ifname | select(. != "lo")' | interface_speed_map)" readonly net_max_speed="$(cat /sys/class/net/*/speed 2>/dev/null | sort | tail -n1 | sed 's|-1|1000|g')" - readonly ssh_port="$((grep ssh_port /etc/yunohost/settings.yml || echo 22) | cut -d: -f2 | xargs)" + readonly ssh_port="$((([ -e /etc/yunohost/settings.yml ] && grep ssh_port /etc/yunohost/settings.yml) || echo 22) | cut -d: -f2 | xargs)" readonly port_infos="$(python3 <= 8.0 so we ignore older pools readonly php_pools_infos="$(grep -E '^\[.*\]' \ --exclude=/etc/php/*/fpm/pool.d/"$app"_status.conf \ diff --git a/scripts/backup b/scripts/backup index 9ba95ee..08373d1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,6 @@ #!/bin/bash source ../settings/scripts/_common.sh -source ../settings/scripts/experimental_helper.sh source /usr/share/yunohost/helpers load_vars diff --git a/scripts/remove b/scripts/remove index b19ce75..cdcd09b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -41,12 +41,12 @@ for pool_dir_by_version in /etc/php/*; do fi done -if ynh_psql_user_exists --user="$db_user"; then - ynh_psql_drop_user "$db_user" -fi -if ynh_mysql_user_exists --user="$db_user"; then +if $mysql_installed && ynh_mysql_user_exists --user="$db_user"; then ynh_mysql_drop_user "$db_user" fi +if $postgresql_installed && ynh_psql_user_exists --user="$db_user"; then + ynh_psql_drop_user "$db_user" +fi _ynh_apt autoremove --purge monitorix ynh_safe_rm "$install_dir" diff --git a/scripts/restore b/scripts/restore index 96a9cd8..99fea63 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,6 @@ #!/bin/bash source ../settings/scripts/_common.sh -source ../settings/scripts/experimental_helper.sh source /usr/share/yunohost/helpers load_vars diff --git a/sources/update_config_if_needed.sh b/sources/update_config_if_needed.sh index c8996c2..c063d39 100644 --- a/sources/update_config_if_needed.sh +++ b/sources/update_config_if_needed.sh @@ -5,6 +5,7 @@ set -eu app=__APP__ YNH_APP_BASEDIR=/etc/yunohost/apps/"$app" YNH_HELPERS_VERSION=2.1 +YNH_APP_ACTION="$1" pushd /etc/yunohost/apps/$app/conf source ../scripts/_common.sh @@ -80,7 +81,7 @@ if "$status_dirty"; then if "$phpfpm_installed"; then config_php_fpm fi - ynh_systemctl --service_name="$app" --action=restart --log_path='systemd' --line_match=' - Ok, ready.' - ynh_systemctl --service_name=nginx --action=reload + ynh_systemctl --service="$app" --action=restart --log_path=systemd --wait_until=' - Ok, ready.' + ynh_systemctl --service=nginx --action=reload save_vars_current_value fi