From fd39098a2c792fda3e8642e7437ecc160effbd25 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 17 Jul 2023 10:04:30 +0200 Subject: [PATCH] chore: add script to generate hard coded instances --- update-instances.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 update-instances.sh diff --git a/update-instances.sh b/update-instances.sh new file mode 100755 index 000000000..bfb36d04e --- /dev/null +++ b/update-instances.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# fetch instances from public api +INSTANCES=$(curl -s 'https://piped-instances.kavin.rocks') + +# generate instances list for settings +echo -e "\nContent for res/values/array.xml\n" + +echo '' +echo $INSTANCES | jq '.[].name' | while read name; do + echo " $name" | tr -d '"' +done + +echo -e '\n\n' +echo $INSTANCES | jq '.[].api_url' | while read url; do + echo " $url" | tr -d '"' +done +echo -e '' + +# generate android url schemes +echo -e "\n\nContent for AndroidManifest.xml to be replaced\n" + +gen_frontends() { + echo $INSTANCES | jq '.[].api_url' | while read url; do + _url=$(echo "$url" | tr -d '"') + _frontend_url=$(curl -Ls -o /dev/null -w %{url_effective} "$_url") + _host=$(echo ${_frontend_url/https:\/\//} | tr -d '/') + echo " " + done +} +echo "$(gen_frontends)" | sort | uniq