From d1be63af8bf6683fb0f53ec26991277bf0f4423e Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 10 Aug 2022 04:39:14 +0300 Subject: Simple duplication of code --- bin/news | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/bin/news b/bin/news index dfd389d..6a73e38 100755 --- a/bin/news +++ b/bin/news @@ -65,16 +65,18 @@ import(){ echo "#TODO" if [ ! -z $1 ] then - if [ ! -d $1 ] + if [ ! -d "$1" ] then - echo "Folder does not exists" + echo $1 + echo "Folder does not exist" exit 4 else echo "Folder $1 exists" fl="$(ls -1 $1)" for f in $fl do - add $1/$f + echo $1 $f + add2 "$1/$f" done fi else @@ -83,6 +85,40 @@ import(){ fi exit 224 } +add2(){ + tempassin + if [ -f $1 ]; then + FILE="$1" + cp $FILE $ZNEWSDIR + echo "Adding news from " $FILE + DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') + TITLE=$(head -n 1 $FILE) + FILE_IPFS_HASH=$(ipfs add -q $FILE) + FILE_SIGN_FILE=$FILE".asc" + gpg --detach-sign --sign-with $FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE + FILE_SIGNATURE=$(ipfs add -q $FILE_SIGN_FILE) + cat > data <