Introduction
Introduction Statistics Contact Development Disclaimer Help
Add memecache-insert tool from parazyd. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 895e102dec02452a50a26be15ba5b1c619a26b38
parent 12b3538f748cacc02d2b34b6efd4c74fa79bcd8e
Author: Annna Robert-Houdin <[email protected]>
Date: Tue, 19 May 2020 19:57:39 +0200
Add memecache-insert tool from parazyd.
Hvala!
Diffstat:
A memecache-insert | 49 +++++++++++++++++++++++++++++…
1 file changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/memecache-insert b/memecache-insert
@@ -0,0 +1,49 @@
+#!/bin/sh
+set -e
+
+usage() {
+ printf "usage: %s old.meme new.meme\n" "$(basename "$0")"
+ exit 1
+}
+
+memesanity() {
+ if ! [ -e "$1" ]; then
+ printf "%s not found\n" "$1"
+ usage
+ fi
+
+ if [ "$(sed 1q "$1")" != "meme2" ]; then
+ printf "we can only work with the meme2 format\n"
+ usage
+ fi
+}
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+ usage
+fi
+
+oldmemes="$1"
+newmemes="$2"
+
+memesanity "$oldmemes"
+memesanity "$newmemes"
+
+t="$(mktemp)"
+
+tail -n+2 "$newmemes" | while read -r tag uri sum; do
+ if grep -q " ${sum}\$" "$oldmemes"; then
+ printf "%s already here\n" "$tag" >&2
+ continue
+ fi
+
+ printf "%s %s %s\n" "$tag" "$uri" "$sum"
+ printf "downloading %s ...\n" "$tag" >&2
+ curl -s "$uri" > "$(basename "$uri")"
+done > "$t"
+
+tail -n+2 "$oldmemes" >> "$t"
+
+printf "meme2\n"
+sort "$t"
+
+rm -f "$t"
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.