aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-08-03 19:33:17 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-08-03 19:33:17 +0300
commit09e8affcadf0106bef20f2ba0a6a19e9f2e3e1fe (patch)
tree2b5da03a87a13fc43233e79332a242c42168c70b
parentec34fa3d4c2fd608930bc95c80283a1be2b5bf62 (diff)
downloadarching-kaos-tools-09e8affcadf0106bef20f2ba0a6a19e9f2e3e1fe.tar.gz
arching-kaos-tools-09e8affcadf0106bef20f2ba0a6a19e9f2e3e1fe.tar.bz2
arching-kaos-tools-09e8affcadf0106bef20f2ba0a6a19e9f2e3e1fe.zip
Cleanup
-rwxr-xr-xbin/ak-folders71
1 files changed, 27 insertions, 44 deletions
diff --git a/bin/ak-folders b/bin/ak-folders
index 3654b67..65ff69f 100755
--- a/bin/ak-folders
+++ b/bin/ak-folders
@@ -1,19 +1,25 @@
#!/bin/bash
# The following creates a mixtape data message
+PROGRAM="$(basename $0)"
ZFOLDERSDIR="$AK_WORKDIR/folders"
TEMP="/tmp/aktmp"
+
+logit(){
+ ak-logthis "<$PROGRAM>" "$1" "$2"
+}
+
if [ ! -d $ZFOLDERSDIR ]; then
- mkdir $ZFOLDERSDIR
- cd $ZFOLDERSDIR
+ mkdir $ZFOLDERSDIR
+ cd $ZFOLDERSDIR
else
- ak-logthis "error $ZFOLDERSDIR not found"
+ logit "[ERROR]" "error $ZFOLDERSDIR not found or/and could not be created"
fi
TEMPASSIN="$(ak-tempassin)"
cd $TEMPASSIN
usage(){
- title
- echo "$0 - folder"
+ title
+ echo "$PROGRAM - folder"
}
add(){
@@ -27,49 +33,25 @@ main(){
FOLDERNAME="$1"
CRP="$2"
echo "Adding $FOLDERNAME"
- ak-logthis "Copying $1 to temporary folder"
+ logit "[INFO]" "Copying $1 to temporary folder"
cp -r $2/$1 $1
if [ $? == 0 ]; then
- ak-logthis "Copied successfully"
+ logit "[INFO]" "Copied successfully"
else
- ak-logthis "Error copying..."
+ logit "[ERROR]" "Error copying..."
fi
FOLDER="$1"
- ak-logthis "Adding $FOLDER to IPFS..."
+ logit "[INFO]" "Adding $FOLDER to IPFS..."
FOLDER_IPFS_HASH=$(ak-ipfs-add $FOLDER)
if [ $? == 0 ]; then
- ak-logthis "done"
+ logit "[INFO]" "done"
else
- ak-logthis "error"
+ logit "[ERROR]" "error"
fi
- ak-logthis "Folders are not signing..."
-
-# NOT NEEDED HERE
-# SIGN_FOLDER=$FOLDERNAME".asc"
-# gpg2 --detach-sign --sign-with $FINGERPRINT --armor --output $SIGN_FOLDER $FOLDER
-# if [ $? == 0 ]; then
-# ak-logthis "Signed"
-# else
-# ak-logthis "Error while signing"
-# fi
-#
-# ak-logthis "Adding signature to IPFS"
-# SIGNATURE=$(ak-ipfs-add $SIGN_FOLDER)
-# if [ $? == 0 ]; then
-# ak-logthis "Added"
-# else
-# ak-logthis "Error while adding"
-# fi
+ logit "[WARNING]" "Folders are not signing..."
-# cat > data <<EOF
-# {
-# "timestamp":"$(date -u +%s)",
-# "foldername":"$FOLDERNAME",
-# "ipfs":"$FOLDER_IPFS_HASH"
-# }
-# EOF
printf '{"timestamp":"%s","foldername":"%s","ipfs":"%s"}' $(date -u +%s) $FOLDERNAME $FOLDER_IPFS_HASH
echo "Printing data..."
@@ -79,23 +61,24 @@ main(){
ak-pack_z_block folders/add $(pwd)/data
if [ $? == 0 ]
then
- echo "cool"
+ echo "cool"
else
- echo "not?"
- exit 2
+ echo "not?"
+ exit 2
fi
}
title(){
+ echo "$PROGRAM"
echo "Folder block creator"
}
if [ ! -z $1 ]; then
- case $1 in
- help) usage; exit;;
- add) add $2; exit;;
- *) usage; exit;;
- esac
+ case $1 in
+ help) usage; exit;;
+ add) add $2; exit;;
+ *) usage; exit;;
+ esac
else usage
fi