Add add-user-agent.sh script. - 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 cb17345a1b7c3cbcc1bed613c888e86d7da1a16a DIR parent 0e1bfeca8a4e170caf67d4acec8b2bd074d8dcaf HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sun, 3 Sep 2023 21:01:31 +0200 Add add-user-agent.sh script. Diffstat: A modules/http-user-agent/add-user-a… | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+), 0 deletions(-) --- DIR diff --git a/modules/http-user-agent/add-user-agent.sh b/modules/http-user-agent/add-user-agent.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ $# -lt 1 ]; +then + printf "usage: %s user-agent\n" "$(basename "$0")" >&2 + exit 1 +fi + +[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : + +useragentfile="/home/annna/bin/modules/http-user-agent/user-agents.txt" + +useragent="$1" +isindb="$(grep "${useragent}" "${useragentfile}")" +if [ -z "${isindb}" ]; +then + printf "%s\n" "${useragent}" >> "${useragentfile}" + cat "${useragentfile}" | tail -n 5 > "/tmp/user-agents.tmp" + cat "/tmp/user-agents.tmp" > "${useragentfile}" + rm "/tmp/user-agents.tmp" +fi +