aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-27 03:49:27 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-27 03:49:27 +0200
commit28717aded7df4ac4842fa308e67c1c15e1de4ffa (patch)
tree64a93db7a952dabf5c2af3b7776bdcf0d050e181
parentabdfe0a5c2a86f19aafe12ae70663ddcf83a6e39 (diff)
downloadarching-kaos-tools-28717aded7df4ac4842fa308e67c1c15e1de4ffa.tar.gz
arching-kaos-tools-28717aded7df4ac4842fa308e67c1c15e1de4ffa.tar.bz2
arching-kaos-tools-28717aded7df4ac4842fa308e67c1c15e1de4ffa.zip
Introduced and applied _ak_gpg library
-rwxr-xr-xbin/ak-articles3
-rwxr-xr-xbin/ak-categories3
-rwxr-xr-xbin/ak-comments3
-rwxr-xr-xbin/ak-data-expand5
-rwxr-xr-xbin/ak-enter5
-rwxr-xr-xbin/ak-files3
-rwxr-xr-xbin/ak-get-gpg3
-rwxr-xr-xbin/ak-get-gpg-fingerprint7
-rwxr-xr-xbin/ak-mixtapes3
-rwxr-xr-xbin/ak-news5
-rwxr-xr-xbin/ak-profile3
-rwxr-xr-xbin/ak-reference3
-rwxr-xr-xbin/ak-sm-files3
-rwxr-xr-xbin/ak-todos3
-rwxr-xr-xbin/ak-transactions3
-rwxr-xr-xbin/ak-zblock-manipulator7
-rwxr-xr-xbin/ak-zblock-pack7
17 files changed, 43 insertions, 26 deletions
diff --git a/bin/ak-articles b/bin/ak-articles
index 363aa7f..9a9f462 100755
--- a/bin/ak-articles
+++ b/bin/ak-articles
@@ -5,6 +5,7 @@ descriptionString="Articles module for Arching Kaos"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
ZARTICLESDIR="$AK_WORKDIR/articles"
TEMP="/tmp/aktmp"
@@ -91,7 +92,7 @@ _ak_modules_articles_add(){
TITLE=$(head -n 1 $FILE)
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-categories b/bin/ak-categories
index 8750159..9387651 100755
--- a/bin/ak-categories
+++ b/bin/ak-categories
@@ -5,6 +5,7 @@ descriptionString="A module for adding and refering zblocks to categories"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
if [ ! -d $AK_CATEGORIES ]; then
mkdir $AK_CATEGORIES
@@ -75,7 +76,7 @@ _ak_modules_categories_add(){
TITLE=$(head -n 1 $FILE)
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-comments b/bin/ak-comments
index 02486f5..6a4bb03 100755
--- a/bin/ak-comments
+++ b/bin/ak-comments
@@ -4,6 +4,7 @@ descriptionString="Comments module for Arching Kaos"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
ZCOMMENTSDIR="$AK_WORKDIR/comments"
TEMP="/tmp/aktmp"
@@ -64,7 +65,7 @@ _ak_modules_comments_add(){
DATETIME="$1"
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
printf '{"datetime":"%s","ipfs":"%s","detach":"%s"}' $DATETIME $FILE_IPFS_HASH $FILE_SIGNATURE > data
else
diff --git a/bin/ak-data-expand b/bin/ak-data-expand
index 0c79741..0a82e63 100755
--- a/bin/ak-data-expand
+++ b/bin/ak-data-expand
@@ -1,6 +1,7 @@
#!/bin/bash
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
if [ ! -d $AK_WORKDIR/ipfs ]
then
@@ -64,7 +65,7 @@ then
logit "ERROR" "Could not get GPG key: $gpg"
exit 1
fi
- gpg2 --homedir $AK_GPGHOME --import $gpg > /dev/null 2>&1
+ _ak_gpg_key_import_from_file $gpg > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
logit "ERROR" "Could not import GPG key: $gpg"
@@ -85,7 +86,7 @@ then
exit 1
fi
logit "INFO" "Data downloaded: $DATA"
- gpg2 --homedir $AK_GPGHOME --verify $DATA.asc $DATA > /dev/null 2>&1
+ _ak_gpg_verify_signature $DATA.asc $DATA > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
logit "ERROR" "Error while verifying signature for $DATA"
diff --git a/bin/ak-enter b/bin/ak-enter
index fd96231..01a93f9 100755
--- a/bin/ak-enter
+++ b/bin/ak-enter
@@ -21,6 +21,7 @@ PROGRAM="$(basename $0)"
descriptionString="Crawl an arching kaos chain"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
_ak_enter_title(){
description
@@ -236,7 +237,7 @@ do
logit "ERROR" "Could not get GPG key: $gpg ."
exit 1
fi
- gpg2 --homedir $AK_GPGHOME --import $gpg > /dev/null 2>&1
+ _ak_gpg_key_import_from_file $gpg > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
logit "ERROR" "Could not import GPG key: $gpg ."
@@ -259,7 +260,7 @@ do
fi
logit "INFO" "Downloaded block $block."
- gpg2 --homedir $AK_GPGHOME --verify $block.asc > /dev/null 2>&1
+ _ak_gpg_verify_signature $block.asc $block > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
logit "ERROR" "Could not verify $block with GPG key $gpg."
diff --git a/bin/ak-files b/bin/ak-files
index 2280cce..c4d6f2c 100755
--- a/bin/ak-files
+++ b/bin/ak-files
@@ -4,6 +4,7 @@ ZFILESDIR="$AK_WORKDIR/files"
TEMP="/tmp/aktmp"
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
if [ ! -d $ZFILESDIR ]; then
mkdir $ZFILESDIR
@@ -62,7 +63,7 @@ main(){
fi
logit "INFO" "Signing..."
SIGN_FILE=$FILENAME".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $SIGN_FILE $FILE
+ _ak_gpg_sign_detached $SIGN_FILE $FILE
if [ $? == 0 ]; then
logit "INFO" "Signed"
else
diff --git a/bin/ak-get-gpg b/bin/ak-get-gpg
index ca718dc..e441f87 100755
--- a/bin/ak-get-gpg
+++ b/bin/ak-get-gpg
@@ -1,2 +1,3 @@
#!/bin/bash
-ak-config show | jq -r '.gpg'
+source $AK_LIBDIR/_ak_gpg
+_ak_gpg_key_self_get_fingerprint_from_config
diff --git a/bin/ak-get-gpg-fingerprint b/bin/ak-get-gpg-fingerprint
index 34bc4e8..84025e5 100755
--- a/bin/ak-get-gpg-fingerprint
+++ b/bin/ak-get-gpg-fingerprint
@@ -1,10 +1,11 @@
#!/bin/bash
+source $AK_LIBDIR/_ak_gpg
+
if [ -z $1 ]
then
- gpg2 --fingerprint $(ak-ipfs-cat $(ak-get-gpg) | gpg2 --import 2>&1 | head -n 1 | cut -d ' ' -f 3 | sed 's/://') | head -n 2 | tail -n 1 | sed 's/ //g'
+ _ak_gpg_key_self_get_fingerprint
elif [ -n "$1" ]
then
- gpg2 --fingerprint $(ak-ipfs-cat "$1" | gpg2 --import 2>&1 | head -n 1 | cut -d ' ' -f 3 | sed 's/://') | head -n 2 | tail -n 1 | sed 's/ //g'
-
+ _ak_gpg_key_get_fingerprint_from_ipfs $1
fi
diff --git a/bin/ak-mixtapes b/bin/ak-mixtapes
index 2004ccb..242211d 100755
--- a/bin/ak-mixtapes
+++ b/bin/ak-mixtapes
@@ -5,6 +5,7 @@ PROGRAM="$(basename $0)"
descriptionString="AK mixtape block creator"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
_ak_modules_mixtapes_usage(){
_ak_modules_mixtapes_title
@@ -35,7 +36,7 @@ _ak_modules_mixtapes_main(){
MIXTAPE_IPFS_HASH=$(ak-ipfs-add $MIXTAPE_FILE)
MIXTAPE_SIGN_FILE=$MIXTAPE_FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $MIXTAPE_SIGN_FILE $MIXTAPE_FILE
+ _ak_gpg_sign_detached $MIXTAPE_SIGN_FILE $MIXTAPE_FILE
MIXTAPE_SIGNATURE=$(ak-ipfs-add $MIXTAPE_SIGN_FILE)
diff --git a/bin/ak-news b/bin/ak-news
index 5dbc847..84458c8 100755
--- a/bin/ak-news
+++ b/bin/ak-news
@@ -7,6 +7,7 @@ TEMP="/tmp/aktmp"
source $AK_LIBDIR/_ak_logit
source $AK_LIBDIR/_ak_script_description
+source $AK_LIBDIR/_ak_gpg
if [ ! -d $ZNEWSDIR ]; then
mkdir $ZNEWSDIR
@@ -103,7 +104,7 @@ _ak_modules_news_add_from_file(){
TITLE=$(head -n 1 $FILE)
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
@@ -139,7 +140,7 @@ _ak_modules_news_add(){
TITLE=$(head -n 1 $ZNEWSDIR/$FILE)
FILE_IPFS_HASH=$(ak-ipfs-add $ZNEWSDIR/$FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $ZNEWSDIR/$FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $ZNEWSDIR/$FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-profile b/bin/ak-profile
index 7633c57..fa07fcb 100755
--- a/bin/ak-profile
+++ b/bin/ak-profile
@@ -5,6 +5,7 @@ TEMP="/tmp/aktmp"
# Outputs to log file in the classic format :)
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
# Whatever the command is, we check if $ZPROFILEDIR is there.
# If NOT we create it and we change dir there.
@@ -153,7 +154,7 @@ _ak_modules_profile_add(){
echo "Adding from " $FILE
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$(pwd)/$1".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-reference b/bin/ak-reference
index 390339e..a1a800f 100755
--- a/bin/ak-reference
+++ b/bin/ak-reference
@@ -2,6 +2,7 @@
ZREFERENCESDIR="$AK_WORKDIR/references"
TEMP="/tmp/aktmp"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
echo $ZREFERENCESDIR
if [ ! -d $ZREFERENCESDIR ]; then
mkdir $ZREFERENCESDIR
@@ -86,7 +87,7 @@ _ak_modules_reference_add(){
DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}')
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-sm-files b/bin/ak-sm-files
index 6c0565b..9548b3b 100755
--- a/bin/ak-sm-files
+++ b/bin/ak-sm-files
@@ -6,6 +6,7 @@ CRD=$(cat .pwd)
PROGRAM="$(basename $0)"
#set -xe
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
if [ ! -d $ZFILESDIR ]; then
mkdir $ZFILESDIR
@@ -77,7 +78,7 @@ main(){
logit "INFO" "Signing..."
SIGN_FILE=$FILENAME".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $SIGN_FILE $FILENAME
+ _ak_gpg_sign_detached $SIGN_FILE $FILENAME
if [ $? == 0 ]; then
logit "INFO" "Signed"
else
diff --git a/bin/ak-todos b/bin/ak-todos
index 2bd4ea1..b5ce838 100755
--- a/bin/ak-todos
+++ b/bin/ak-todos
@@ -1,6 +1,7 @@
#!/bin/bash
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
ZTODOSDIR="$AK_WORKDIR/todos"
TEMP="/tmp/aktmp"
@@ -83,7 +84,7 @@ _ak_modules_todos_add(){
TITLE=$(head -n 1 $FILE)
FILE_IPFS_HASH=$(ak-ipfs-add $FILE)
FILE_SIGN_FILE=$FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE
+ _ak_gpg_sign_detached $FILE_SIGN_FILE $FILE
FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE)
cat > data <<EOF
{
diff --git a/bin/ak-transactions b/bin/ak-transactions
index f7024ef..1e374fa 100755
--- a/bin/ak-transactions
+++ b/bin/ak-transactions
@@ -5,6 +5,7 @@ _ak_modules_transactions_usage(){
}
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
_ak_modules_transactions_main(){
logit "INFO" "$FROM_ADDRESS to $TO_ADDRESS value sent: $AMOUNT"
@@ -18,7 +19,7 @@ EOF
FILE_IPFS_HASH=$(ak-ipfs-add $TRANSACTION_FILE)
SIGN_FILE=$TRANSACTION_FILE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $SIGN_FILE $TRANSACTION_FILE
+ _ak_gpg_sign_detached $SIGN_FILE $TRANSACTION_FILE
FILE_SIGNATURE=$(ak-ipfs-add $SIGN_FILE)
diff --git a/bin/ak-zblock-manipulator b/bin/ak-zblock-manipulator
index 99583fa..cf67a6e 100755
--- a/bin/ak-zblock-manipulator
+++ b/bin/ak-zblock-manipulator
@@ -17,6 +17,7 @@
# Below, the usage information
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
usage(){
echo "Usage:"
@@ -50,14 +51,14 @@ main(){
# We create a detached and armor signature of it
MESSAGE_SIGN_FILE=$MESSAGE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $MESSAGE_SIGN_FILE $MESSAGE
+ _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"
- gpg2 --homedir $AK_GPGHOME --armour --output $KEY --export $AK_FINGERPRINT
+ _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
@@ -79,7 +80,7 @@ makeZBlock(){
BLOCK="block"
BLOCK_SIG=$BLOCK".asc"
# We have a block now, so we sign it
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $BLOCK_SIG $BLOCK
+ _ak_gpg_sign_detached $BLOCK_SIG $BLOCK
# We now add the signature to IPFS
BLOCK_SIGNATURE=$(ak-ipfs-add $BLOCK_SIG)
diff --git a/bin/ak-zblock-pack b/bin/ak-zblock-pack
index 2a7c072..4f635bf 100755
--- a/bin/ak-zblock-pack
+++ b/bin/ak-zblock-pack
@@ -19,6 +19,7 @@ set -xe
# Logging patch
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_gpg
# Below, the usage information
usage(){
@@ -57,14 +58,14 @@ main(){
# We create a detached and armor signature of it
MESSAGE_SIGN_FILE=$MESSAGE".asc"
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $MESSAGE_SIGN_FILE $MESSAGE
+ _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"
- gpg2 --homedir $AK_GPGHOME --armour --output $KEY --export $AK_FINGERPRINT
+ _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
@@ -75,7 +76,7 @@ main(){
BLOCK="block"
BLOCK_SIG=$BLOCK".asc"
# We have a block now, so we sign it
- gpg2 --homedir $AK_GPGHOME --detach-sign --sign-with $AK_FINGERPRINT --armor --output $BLOCK_SIG $BLOCK
+ _ak_gpg_sign_detached $BLOCK_SIG $BLOCK
# We now add the signature to IPFS
BLOCK_SIGNATURE=$(ak-ipfs-add $BLOCK_SIG)