diff options
-rwxr-xr-x | ipfs-check-install-setup-init-update | 63 | ||||
-rwxr-xr-x | lib/_ak_gpg | 15 | ||||
-rwxr-xr-x | lib/_ak_zblock | 38 |
3 files changed, 49 insertions, 67 deletions
diff --git a/ipfs-check-install-setup-init-update b/ipfs-check-install-setup-init-update index c20a0f2..663b009 100755 --- a/ipfs-check-install-setup-init-update +++ b/ipfs-check-install-setup-init-update @@ -1,23 +1,12 @@ #!/bin/bash +source lib/_ak_ipfs +source lib/_ak_log + if [ ! -d $AK_BINDIR ]; then mkdir $AK_BINDIR ;fi if [ ! -d $AK_ARCHIVESDIR ]; then mkdir $AK_ARCHIVESDIR ;fi -logthis(){ - echo "$(date -u +%s) $1 $2" >> $AK_WORKDIR/logs -} - -install(){ - logthis "[INFO]" "Attempting to install IPFS..." - IPFS_VERSION="$(curl -s https://dist.ipfs.tech/kubo/versions | tail -1)" - - IPFS_TARGET_FILE="kubo_"$IPFS_VERSION"_linux-amd64.tar.gz" - - logthis "[INFO]" "Downloading ipfs $IPFS_VERSION" - if [ ! -f $AK_ARCHIVESDIR/$IPFS_TARGET_FILE ] - then - wget -O $AK_ARCHIVESDIR/$IPFS_TARGET_FILE https://dist.ipfs.tech/kubo/$IPFS_VERSION/$IPFS_TARGET_FILE ; - fi - logthis "[INFO]" "Making temp files" +_ak_ipfs_install(){ + logit "INFO" "Making temp files" pwd > pwd mktemp > tempassin ak_curdir=$(cat pwd) @@ -27,44 +16,22 @@ install(){ cp kubo/ipfs $AK_BINDIR/ipfs cd $ak_curdir rm -rf $TEMPASSIN - logthis "[INFO]" "ipfs installed on $AK_BINDIR" - - if [ ! -d $HOME/.ipfs ] - then - mkdir $HOME/.ipfs - $AK_BINDIR/ipfs init - fi -} - -swarm_install() { - # Setting the SHA512SUM for our swarm - SWARMSHA512SUM="7001e37412758c43d372a969e977ca11511e034c8c1e233a58dc3ce1c6f3c1aa7d2da8cba9944a5eabaa8885742bfe6cc6794224c146b7129da8f633b53b9cfc" - - if [ ! -f $HOME/.ipfs/swarm.key ] - then - logthis "[INFO]" "Downloading swarm key" - wget -O $HOME/.ipfs/swarm.key https://arching-kaos.net/files/swarm.key - elif [ -f $HOME/.ipfs/swarm.key ] && [ "$(sha512sum $HOME/.ipfs/swarm.key | awk '{ print $1 }')" == "$SWARMSHA512SUM" ] - then - logthis "[INFO]" "Congrats! You are already in our swarm" - else - logthis "[ERROR]" "Found swarm.key but not ours" - logthis "[ERROR]" "Visit https://arching-kaos.net/files/swarm.key and copy it to your ipfs folder" - fi + logit "INFO" "ipfs installed on $AK_BINDIR" } which ipfs > /dev/null 2>&1 -if [ $? != 0 ]; then - install - ipfs init - swarm_install +if [ $? -ne 0 ]; then + _ak_ipfs_download + _ak_ipfs_install + _ak_ipfs init + _ak_ipfs_swarm_install else - logthis "[INFO]" "Found IPFS! Skipping downloading..." - swarm_install + logit "INFO" "Found IPFS! Skipping downloading..." + _ak_ipfs_swarm_install fi if [ ! -d $HOME/.ipfs ]; then - ipfs init - swarm_install + _ak_ipfs init + _ak_ipfs_swarm_install fi if [ ! -f $AK_ZGENESIS ] diff --git a/lib/_ak_gpg b/lib/_ak_gpg index 4c73188..d8010b2 100755 --- a/lib/_ak_gpg +++ b/lib/_ak_gpg @@ -117,3 +117,18 @@ _ak_gpg_key_self_export(){ exit 1 fi } + +_ak_gpg_list_keys(){ + _ak_gpg --list-keys | grep '^ ' | awk '{print $1}' | tr '\n' ' ' +} + +_ak_gpg_select_key(){ + select x in $(_ak_gpg_list_keys) + do + echo $x + if [ -n "$x" ] + then + break + fi + done +} diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 07f4981..cd4fa95 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -39,18 +39,18 @@ _ak_zblock_show(){ # # # # We can extend this with calling the encoder and further send the transaction # # -# +# # #FINGERPRINT="CHANGE THIS TO YOUR DEFAULT FINGERPRINT" # # We acquire the GPG fingerprint by email address # # The following example finds kaos@kaos.kaos' GPG fingerprint like this # # FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -1 | head -n1 | awk '{print $1}')" -# +# # # Below, the usage information # PROGRAM="$(basename $0)" # source $AK_LIBDIR/_ak_log # source $AK_LIBDIR/_ak_ipfs # source $AK_LIBDIR/_ak_gpg -# +# # usage(){ # echo "Usage:" # echo "$PROGRAM -b block_file | -h block_hash | dunno" @@ -74,28 +74,28 @@ _ak_zblock_show(){ # echo " will be unverified." # echo "" # } -# +# # main(){ -# +# # logit "INFO" "We are doing" $BLOCK_TO_ADD "with content" $PREVIOUS # # We add it to IPFS # MESSAGE_HASH=$(_ak_ipfs_add $MESSAGE) -# +# # # We create a detached and armor signature of it # MESSAGE_SIGN_FILE=$MESSAGE".asc" # _ak_gpg_sign_detached $MESSAGE_SIGN_FILE $MESSAGE -# +# # # We add the signature to IPFS # MESSAGE_SIGNATURE=$(_ak_ipfs_add $MESSAGE_SIGN_FILE) -# +# # # We will be using our public key also to put it in the block later # KEY="gpg.pub" # _ak_gpg_key_self_export $KEY # GPG_PUB_KEY=$(_ak_ipfs_add $KEY) -# +# # # Acquire last block of information, to chain this one with previous posted # PREVIOUS=$(_ak_ipfs_files_stat /zlatest | head -n 1) -# +# # # We create a block of json like this: # cat > block <<EOF # { @@ -113,13 +113,13 @@ _ak_zblock_show(){ # BLOCK_SIG=$BLOCK".asc" # # We have a block now, so we sign it # _ak_gpg_sign_detached $BLOCK_SIG $BLOCK -# +# # # We now add the signature to IPFS # BLOCK_SIGNATURE=$(_ak_ipfs_add $BLOCK_SIG) -# +# # # We also add the block! # BLOCK=$(_ak_ipfs_add $BLOCK) -# +# # # So we now do the think almost again # cat > zblock << EOF # { @@ -132,31 +132,31 @@ _ak_zblock_show(){ # ZBLOCK=$(_ak_ipfs_add $ZBL) # echo $ZBLOCK # } -# +# # if [ ! -z $2 ]; # then # PWD="$(pwd)" -# +# # # We ask which BLOCK is goind to be edited # BLOCK_TO_ADD="$1" # # We ask for a ZBLOCK or GENESIS to put in the BLOCK # PREVIOUS="$2" -# +# # _ak_ipfs_cat "$BLOCK_TO_ADD" # if [ $? == 0 ]; # then # echo "Nice! We found the block" # _ak_ipfs_get "$BLOCK_TO_ADD" -# +# # sed -i.bak -e 's/^.*previous.*$/\"previous\":\"'$PREVIOUS'\"/' $BLOCK_TO_ADD # cat $BLOCK_TO_ADD | jq -M -# +# # exit 2 # else # echo "Too bad, it seems the block is not there" # exit 1 # fi -# +# # # cat $PWD/zblock | jq -M # # Optional or extending with # # python send_as_ak_tx $ZBLOCK |