From 286b71a6ead8c7234cfbc0b8ece05c8239a4f32c Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 29 Mar 2023 23:45:49 +0300 Subject: Renamed everything --- bin/profile | 227 ------------------------------------------------------------ 1 file changed, 227 deletions(-) delete mode 100755 bin/profile (limited to 'bin/profile') diff --git a/bin/profile b/bin/profile deleted file mode 100755 index ed83d29..0000000 --- a/bin/profile +++ /dev/null @@ -1,227 +0,0 @@ -#!/bin/bash -PROGRAM="$(basename $0)" -ZPROFILEDIR="$WORKDIR/profile" -TEMP="/tmp/aktmp" - -# Outputs to log file in the classic format :) -logit(){ - logthis "<$PROGRAM>" "$1" "$2" -} - -# Whatever the command is, we check if $ZPROFILEDIR is there. -# If NOT we create it and we change dir there. -if [ ! -d $ZPROFILEDIR ]; then - mkdir $ZPROFILEDIR - cd $ZPROFILEDIR - logit "[INFO]" "zprofiledir created" -else - logit "[INFO]" "zprofiledir found" -fi - -tempassin(){ - if [ ! -z $1 ] - then - TEMPASSIN="$1" - else - TIMESTAMP="$(date -u +%s)" - TEMPASSIN="/tmp/aktmp_$TIMESTAMP" - fi - if [ ! -d $TEMPASSIN ]; then - mkdir $TEMPASSIN - fi - cd $TEMPASSIN - # echo "$TEMPASSIN" -} - -# This is working with DATA blocks. DATA that matched profile/add ACTION -# -# The profile settings/configuration is part of the blockchain produced. -# Hence, we need a specific DATA block that actually has the announcement of a -# {"key":"value"} pair. -show(){ - if [ ! -z $1 ] - then - logit "[INFO]" "Working with $1" - ipfs cat $(echo $(ipfs cat $1) | jq '.ipfs' -r) - else - echo "No DATA provided" - exit 1 - fi -} - -# This should retrieve a specific value from our profile otherwise it dumps the -# whole profile values. -propget(){ - if [ ! -z $1 ] - then - if [ ! -f $ZPROFILEDIR/$1 ] - then - echo "property not found" - else - cat $ZPROFILEDIR/$1 - fi - else - echo "No particular property... indexing" - index - fi -} - -propwrite(){ - cat > $ZPROPERTY_FILE << EOF -{ - "$ZPROPERTY_KEY":"${ZPROPERTY_VALUE}" -} -EOF - if [ $? == 0 ] - then - echo "Added successfully... proceeding" - IPFS_FILE=$(ipfs add -q $ZPROPERTY_FILE) - echo "Prop writting,,, $IPFS_FILE" - add $ZPROPERTY_KEY - echo "Adding to git repo..." - cd $ZPROFILEDIR - else - echo "Couldn't write to file $ZPROFILEDIR/$TO_FILE" - exit 1 - fi -} - -propset(){ - if [ ! -z $1 ] - then - ZPROPERTY_FILE="$ZPROFILEDIR/$1" - ZPROPERTY_KEY="$1" - if [ ! -f $ZPROPERTY_FILE ] - then - echo "No such property: $ZPROPERTY_KEY ... creating" - ZPROPERTY_VALUE="$2" - if [ ! -z "$ZPROPERTY_VALUE" ] - then - touch $ZPROPERTY_FILE - echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" - propwrite #"$ZPROPERTY_FILE" "${ZPROPERTY_VALUE}" - else - echo "No value for $1" - fi - else - echo found $ZPROPERTY_FILE - echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE" - ZPROPERTY_VALUE="$2" - read -p "Overwrite $1 with ${ZPROPERTY_VALUE} ? " yn - case $yn in - [Yy]* ) propwrite;;# "$ZPROPERTY_" "${ZPROPERTY_VALUE}";; - [Nn]* ) exit 130;; - * ) echo "Answer please";; - esac - echo $IPFS_FILE - show $IPFS_FILE - fi - else - echo "conditions unmet" - exit 244 - fi -} -index(){ - FILES="$(ls -1 $ZPROFILEDIR)" - i=0 - echo -n "{" - for FILE in $FILES - do - if [ $FILE != "README" ]; then - if [ $i != "0" ]; then - echo -n ","; - fi - PROP=$(echo $(cat $ZPROFILEDIR/$FILE | json2bash) | cut -d '=' -f 1 | awk '{print $0}') - VAL=$(echo $(cat $ZPROFILEDIR/$FILE | json2bash) | cut -d '=' -f 2 | awk '{print $1}') - echo -n '"'$PROP'":"'$VAL'"'; - let i+=1 - fi - done - echo "}" -} -import(){ - if [ ! -z $1 ] - then - if [ ! -d $1 ] - then - echo "Profile folder check: Folder $1 does not exist. Stopping..." - exit 4 - else - echo "Profile folder check: Folder $1 exists." - fl="$(ls -1 $1)" - for f in $fl - do - add $1/$f - done - fi - else - echo "No value" - exit 6 - fi - exit 224 -} - -# Adds a file as a profile/add ACTION on the zchain. -add(){ - tempassin - if [ -f $ZPROFILEDIR/$1 ]; then - FILE="$ZPROFILEDIR/$1" - echo "Adding from " $FILE - FILE_IPFS_HASH=$(ipfs add -q $FILE) - FILE_SIGN_FILE=$(pwd)/$1".asc" - gpg2 --detach-sign --sign-with $FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE - FILE_SIGNATURE=$(ipfs add -q $FILE_SIGN_FILE) - cat > data <\t\t\tShow profile entry from specified DATA IPFS CIDv0" - echo -e "\tset \t\tSets a profile value" - echo -e "\tget \t\t\tGets a profile value from the on-disk file." - echo "" - echo "Advanced (use with caution may produce duplicate entries):" - echo -e "\tadd \t\t\tCreates a data file from the profile file you point to (file should already be in ZPROFILEDIR." - echo -e "\timport \t\t\tImport a folder to zchain #TODO" - echo "" - exit 0 -} -if [ ! -z $1 ]; then - case $1 in - help) usage; exit;; - index) index; exit;; - show) show $2; exit;; - import) import $2; exit;; - add) add $2; exit;; - set) propset $2 "$3"; exit;; - get) propget $2; exit;; - * ) usage;; - esac -else usage -fi -- cgit v1.2.3