Add tries to bithub-gen in case of server failure. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit a216b445324c2e13b1021a6f762bfd1690222c18 DIR parent a62ea82b7b12d1d2d7ca105164b9cdacc7575539 HTML Author: Annna Robert-Houdin <annna@bitreich.org> 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(-) --- DIR 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}"