aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2022-08-10 04:39:14 +0300
committerkaotisk <kaotisk@arching-kaos.org>2022-08-10 04:39:14 +0300
commitd1be63af8bf6683fb0f53ec26991277bf0f4423e (patch)
treef771face937fd25bcf58d8b3ea35401b5b995724 /bin
parentd6595e3a11736008ce10389ae81e3ea43e53b615 (diff)
downloadarching-kaos-tools-d1be63af8bf6683fb0f53ec26991277bf0f4423e.tar.gz
arching-kaos-tools-d1be63af8bf6683fb0f53ec26991277bf0f4423e.tar.bz2
arching-kaos-tools-d1be63af8bf6683fb0f53ec26991277bf0f4423e.zip
Simple duplication of code
Diffstat (limited to 'bin')
-rwxr-xr-xbin/news44
1 files 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 <<EOF
+{
+ "datetime":"$DATETIME",
+ "title":"$TITLE",
+ "filename":"$FILE",
+ "ipfs":"$FILE_IPFS_HASH",
+ "detach":"$FILE_SIGNATURE"
+}
+EOF
+ else
+ echo "File $FILE doesn't exist";
+ exit 2
+ fi
+ pack_z_block "news/add" data
+ if [ $? == 0 ]
+ then
+ echo "News added successfully"
+ else
+ echo "error??"
+ exit 1
+ fi
+}
add(){
tempassin
if [ -f $ZNEWSDIR/$1 ]; then
@@ -133,7 +169,7 @@ if [ ! -z $1 ]; then
help) usage; exit;;
index) index; exit;;
import) import $2; exit;;
- add) add $2; exit;;
+ add) add2 $2; exit;;
create) create; exit;;
* ) usage;;
esac