From 11a4191c4ccb308614cb8fcf883d29c757109f45 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Thu, 3 Aug 2023 19:34:39 +0300 Subject: Cleanup and fixed call to script --- bin/ak-follow | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/ak-follow b/bin/ak-follow index 9177c7f..0d6107c 100755 --- a/bin/ak-follow +++ b/bin/ak-follow @@ -1,14 +1,23 @@ #!/bin/bash FOLLOWING="$HOME/.arching-kaos/following" +PROGRAM="$(basename $0)" if [ ! -z $1 ] then - echo $1 >> $FOLLOWING - IPFS=$(ak-ipfs-add $FOLLOWING) - if [ $? == 0 ] - then - profile set following $IPFS - else - ak-logthis "Addition aborted" - exit 1 - fi + grep $1 $FOLLOWING + if [ $? == 0 ] + then + ak-logthis "<$(basename $0)>" "[ERROR]" "Already exists" + exit 1 + fi + echo $1 >> $FOLLOWING + IPFS=$(ak-ipfs-add $FOLLOWING) + if [ $? != 0 ] + then + ak-logthis "<$PROGRAM>" "[ERROR]" "Addition failed" + exit 1 + fi + ak-profile set following $IPFS + exit 0 fi +printf "Usage:\n\t%s \n" $PROGRAM +exit 1 -- cgit v1.2.3