add-user-agent.sh - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
add-user-agent.sh (536B) | |
--- | |
1 #!/bin/sh | |
2 | |
3 if [ $# -lt 1 ]; | |
4 then | |
5 printf "usage: %s user-agent\n" "$(basename "$0")" >&2 | |
6 exit 1 | |
7 fi | |
8 | |
9 [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$… | |
10 | |
11 useragentfile="/home/annna/bin/modules/http-user-agent/user-agents.txt" | |
12 | |
13 useragent="$1" | |
14 isindb="$(grep "${useragent}" "${useragentfile}")" | |
15 if [ -z "${isindb}" ]; | |
16 then | |
17 printf "%s\n" "${useragent}" >> "${useragentfile}" | |
18 tail -n 5 "${useragentfile}" > "/tmp/user-agents.tmp" | |
19 cat "/tmp/user-agents.tmp" > "${useragentfile}" | |
20 rm "/tmp/user-agents.tmp" | |
21 fi | |
22 |