Add tries to bithub-gen in case of server failure. - annna - Annna the nice fri… | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit a216b445324c2e13b1021a6f762bfd1690222c18 | |
parent a62ea82b7b12d1d2d7ca105164b9cdacc7575539 | |
Author: Annna Robert-Houdin <[email protected]> | |
Date: Fri, 7 Apr 2023 15:27:32 +0200 | |
Add tries to bithub-gen in case of server failure. | |
Diffstat: | |
M bithub-gen | 19 ++++++++++++++++--- | |
1 file changed, 16 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/bithub-gen b/bithub-gen | |
@@ -4,9 +4,22 @@ export PATH="$PATH:/home/annna/bin" | |
bithubarchive="/br/gopher/bithub/read_text" | |
bithubbaseuri="gophers://bitreich.org/0/bithub/read_text" | |
-essayurl="$(essay-gen)" | |
-cd "${bithubarchive}" | |
-essayfile="$(curl -s "${essayurl}" | sed -n "2p;" | tr ' /' '__').txt" | |
+ | |
+essayfile=".txt" | |
+maxtries=3 | |
+while [ "${essayfile}" = ".txt" ]; | |
+do | |
+ [ $maxtries -eq 0 ] && exit 1 | |
+ | |
+ essayurl="$(essay-gen)" | |
+ cd "${bithubarchive}" | |
+ essayfile="$(curl -s "${essayurl}" | sed -n "2p;" | tr ' /' '__').txt" | |
+ if [ "${essayfile}" = ".txt" ]; | |
+ then | |
+ maxtries=$(($maxtries - 1)) | |
+ continue | |
+ fi | |
+done | |
curl -s "${essayurl}" > "${essayfile}" | |
printf "%s/%s\n" "${bithubbaseuri}" "${essayfile}" |