From 57f0f016a6c9947c19cc4ebab0c50193f17935b5 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 11 Feb 2022 07:52:48 +0200 Subject: Better written I suppose --- bin/ak-files | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'bin/ak-files') diff --git a/bin/ak-files b/bin/ak-files index f830e17..f698290 100755 --- a/bin/ak-files +++ b/bin/ak-files @@ -1,12 +1,43 @@ #!/bin/bash # The following creates a mixtape data message # We can extend it by calling the pack_z_block.sh mixtape/add data +ZFILESDIR="$WORKDIR/files" +TEMP="/tmp/aktmp" +if [ ! -d $ZFILESDIR ]; then + mkdir $ZFILESDIR + cd $ZFILESDIR + git init +else + logthis "error $ZFILESDIR not found" +fi +tempassin(){ + if [ ! -z $1 ]; + then + TEMPASSIN="$1" + else + TIMESTAMP="$(date -u +%s)" + TEMPASSIN="/tmp/aktmp_$TIMESTAMP" + fi + if [ ! -d $TEMPASSIN ]; then + mkdir $TEMPASSIN + fi + cd $TEMPASSIN + echo "$TEMPASSIN" + +} usage(){ title echo "$0 - file" } +add(){ + PWD="$(pwd)" + FILE="$PWD/$1" + main + cat $PWD/data | json_pp + pack_z_block file/add $PWD/data +} main(){ echo "Adding $FILE" @@ -34,12 +65,11 @@ title(){ } -if [ ! -z $1 ]; -then - PWD="$(pwd)" - FILE="$PWD/$1" - main - cat $PWD/data | json_pp - pack_z_block file/add $PWD/data +if [ ! -z $1 ]; then + case $1 in + help) usage; exit;; + add) add $2; exit;; + *) usage; exit;; + esac else usage fi -- cgit v1.2.3