From e4c3befb5338f5dd4ff251c226dca43480198024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 11 Dec 2023 22:19:47 +0100 Subject: [PATCH] fix ynh_setup_source workaround --- scripts/_common.sh | 8 ++++++++ scripts/change_url | 6 +++++- scripts/install | 3 +-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..d4622ce 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,14 @@ # PERSONAL HELPERS #================================================= +_check_if_source_available() { + source_id=$1 + + source_url=$(cat "$YNH_APP_BASEDIR/manifest.toml" | toml_to_json | jq ".resources.sources[\"$source_id\"][\"url\"]") + + curl --output /dev/null --silent --head --fail "$source_url" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 40f93a7..cc68060 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,11 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 -ynh_change_url_nginx_config +if _check_if_source_available main; then + ynh_setup_source --dest_dir="$install_dir" -s main +else + ynh_setup_source --dest_dir="$install_dir" -s main_attic +fi #================================================= # SPECIFIC MODIFICATIONS diff --git a/scripts/install b/scripts/install index 9d44133..9bffb14 100755 --- a/scripts/install +++ b/scripts/install @@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Setting up source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" -s main \ -|| ynh_setup_source --dest_dir="$install_dir" -s main_attic +_ynh_setup_source_with_fallback chmod 750 "$install_dir" chmod -R o-rwx "$install_dir"