I've drafted a script that uploads a git repository. I've also made a tiny script that retrieves transactions based on tags. Many things are missing. I'm tihnking the most important thing is to make sure it can find very old transactions, which means letting the user provide important tag material. I think it would be helpful to add information on the associated public key to the output. I can maybe mutate this to have it appear like tags. 0822
0903 https://github.com/xloem/savegit untested!
From 0aec75410dd9f2899e0e8b9829ece14c76074013 Mon Sep 17 00:00:00 2001 From: John Doe <[email protected]> Date: Sun, 11 Dec 2022 08:58:00 -0500 Subject: [PATCH] - --- _.bash | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ upload_one.bash | 27 ++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 _.bash create mode 100644 upload_one.bash diff --git a/_.bash b/_.bash new file mode 100644 index 0000000..8828c6b --- /dev/null +++ b/_.bash @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -o pipefail + +echo Usage: [GATEWAY=https://arweave.*] [OWNER=owner_address] "$0" [tag=value]... +echo Note: data is not encoded so no quotes + +if [ -z "$GATEWAY" ] +then + GATEWAY=https://arweave.net + #GATEWAY=https://arweave.dev + #GATEWAY=https://arweave.live # paid + #GATEWAY=https://arweave-dev.everpay.io +fi + +if [ -n "$OWNER" ] +then + OWNER=", owners: [\\\"$OWNER\\\"]" +fi + +TAGS='' +for tag in "$@" +do + TAG_NAME="${tag%%=*}" + TAG_VALUE="${tag#*=}" + if [ -n "$TAGS" ] + then + TAGS="$TAGS," + fi + TAGS="$TAGS"'{name:\"'"$TAG_NAME"'\", values:[\"'"$TAG_VALUE"'\"]}' +done +if [ -z "$TAGS" ] +then + TAGS='[ {name:\"git\",values:[\"git\"]} ]' +fi + +#TAG_NAME="Content-Type" +#TAG_VALUE="text/html" +#TAGS='[ {name:\"'"$TAG_NAME"'\", values:[\"'"$TAG_VALUE"'\"]} ]' +GRAPHQL='{ + "query": + "query{ transactions( '"tags: $TAGS $OWNER"' ) { edges { node { id owner { address } tags { name value } } } } }", + "variables":{} +}' + +#echo "$GRAPHQL" +curl --fail-with-body -v -H 'Content-Type: application/json' -d "$GRAPHQL" "$GATEWAY"/graphql | + sed -e 's!{!{\n!g' | + sed -ne 's!.*"id":"\([^"]*\)".*!'"$GATEWAY"'/\1!p; s!.*"name":"\(.*\)","value":"\(.*\)".*!\t\1=\2!p; s!.*"address":"\([^"]*\)".*!\taddress \1!p;' || { echo 'FAIL' 1>&2; false; } + #sed -ne 's!.*"id":"\([^"]*\)".*!'"$GATEWAY"'/\1!p; ' + diff --git a/upload_one.bash b/upload_one.bash new file mode 100644 index 0000000..f68c85b --- /dev/null +++ b/upload_one.bash @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +echo "Usage: $0 repository_dir wallet_path" + +repository_path="$1" +wallet_path="$2" +mkdir -p "$repository_dir/.git" +tmpdir="$repository_dir/.git/$$" + +# install arkb with yarn or npm +#yarn global add arkb +# or with npm +#npm install --global arkb + +# check your wallet address and balance if needed +arkb balance --wallet "$wallet_path" + +git clone -- --mirror --bare "$repository_path" "$tmpdir" +git --git-dir "$tmpdir" update-server-info + +# keepme files might be unneeded, unsure +find "$tmpdir" -type d -empty | xargs touch + +# deploy with arkb +echo "This is a git repository uploaded with arkb." > "$tmpdir"/index.txt +arkb deploy "$tmpdir" --wallet "$wallet_path" --index index.txt --bundle --debug --tag-name git --tag-value git --no-colors + -- 2.36.1.37.gdc8c8deaa6
