aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-08-03 19:34:39 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-08-03 19:34:39 +0300
commit11a4191c4ccb308614cb8fcf883d29c757109f45 (patch)
tree552d621f6e20253ca14ce3160613e2d159f729df /bin
parent09e8affcadf0106bef20f2ba0a6a19e9f2e3e1fe (diff)
downloadarching-kaos-tools-11a4191c4ccb308614cb8fcf883d29c757109f45.tar.gz
arching-kaos-tools-11a4191c4ccb308614cb8fcf883d29c757109f45.tar.bz2
arching-kaos-tools-11a4191c4ccb308614cb8fcf883d29c757109f45.zip
Cleanup and fixed call to script
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak-follow27
1 files changed, 18 insertions, 9 deletions
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 <AKID_IPFS_CID_v0>\n" $PROGRAM
+exit 1