From 3ca08bd3296480ed86f4f58f05affe98d6f470ce Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 9 Dec 2017 15:24:05 +0000 Subject: [PATCH] Importer for old bookman files svn path=/trunk/; revision=12 --- import.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 import.sh diff --git a/import.sh b/import.sh new file mode 100755 index 0000000..aec5ba1 --- /dev/null +++ b/import.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +HTTP_COOKIE='id=____________' +mkdir -p 'users/____________' +. ./index.cgi >&- + +seq=$(date +%s) +seqid(){ + { printf "$( + while [ -n "$seq" -a "${seq}" -gt 0 ]; do + # ^^ double condition seems necessary in dash + # (possibly due to faulty result caching?) + printf \\%o $((seq % 256)) + seq=$((seq / 256)) + done + )" | tac + head -c5 /dev/urandom + } \ + | uuencode -m - \ + | sed -n '2{y;+/;:_;;p}' +} + + +import="$1" +order=1000 +BDB="users/$(genid)" + +mkdir -p "${BDB}/favicons" + +while read l; do + case "$l" in + folder=*) + fid="$(seqid)" + name="$(QUERY_STRING="$l" GET folder)" + file="${BDB}/${fid}.bm" + printf '%s\t%s\t%s\n' "$fid" "$(HTML "$name")" "$order" >"$file" + order="$(($order + 1000))" + seq=$(($seq + 1)) + printf 'Setting up Folder: %s\n' "$name" + ;; + title=*) + title="$(QUERY_STRING="$l" GET title)" + ;; + content=*) + uri="$(QUERY_STRING="$l" GET content |head -n1)" + if [ -f "$file" -a -n "$title" ]; then + bid=$(seqid) + printf '%s\t%s\t%s\n' "$bid" "$(HTML "$title")" "$uri" >>"$file" + getFavicon "$uri" "$bid" & + seq=$(($seq + 1)) + printf 'Added record "%s" to %s\n' "$title" "$file" + fi + ;; + esac +done <"$import" + +printf 'Finished import to collection: %s\n' "${BDB##*/}" -- 2.39.2