Adding #network tag. - 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 edc97536595c67bc8a79b64b7c099cc2c851d9f5 DIR parent d1f9a008ca39d112c62e17eb926dd89af65030b8 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Tue, 19 May 2020 19:29:02 +0200 Adding #network tag. Diffstat: M annna-add-hashtag | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+), 0 deletions(-) --- DIR diff --git a/annna-add-hashtag b/annna-add-hashtag @@ -5,6 +5,7 @@ set -x memecachedir="/br/gopher/memecache" hashtagdb="/home/annna/bin/modules/hashtags/hashtags.txt" unprocessed="/home/annna/bin/modules/hashtags/unprocessed.txt" +memeindex="/br/gopher/memecache/meme.index" [ ! -e "${hashtagdb}" ] && touch "${hashtagdb}" @@ -95,6 +96,33 @@ inserttag() { chmod 664 "${hashtagdb}" } +inserttag() { + tag="$1" + uri="$2" + + grep "${tag} " $memeindex >/dev/null + if [ $? -eq 0 ]; + then + printf "tag '%s' already in index.\n" "${tag}" >&2 + return 1 + fi + + stag="$(printf "${tag}\n" | cut -c 2-)" + cd "${memecachedir}" + tagfile="$(basename "$(find . -name "${stag}.*" | grep -v .orig)")" + checksum="$(sha512sum "${tagfile}" | cut -d' ' -f 1)" + tagtype="$(get-tagtype "${tagfile}")" + memecacheuri="gopher://bitreich.org/${tagtype}/memecache/${tagfile}" + + printf "%s %s %s\n" "${tag}" "${memecacheuri}" "${checksum}" >> "${memeindex}" + printf "tag '%s' added as '%s' to meme index.\n" "${tag}" "${memecacheuri}" >&2 + LC_ALL=C sort -t ' ' -k1,1 "${memeindex}" > "${memeindex}.sort" + mv "$memeindex.sort" "${memeindex}" + # keep permissions shared. + chown ':bitreich' "${memeindex}" + chmod 664 "${memeindex}" +} + addtag() { tag="$1" uri="$2"