aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ak-enter2
-rwxr-xr-xbin/ak-profile2
-rwxr-xr-xbin/ak-sm-files2
-rwxr-xr-xbin/ak-tempassin35
-rwxr-xr-xbin/ak-zchain-chk2
-rwxr-xr-xlib/_ak_fs4
-rwxr-xr-xlib/_ak_script22
-rwxr-xr-xmodules/articles/main.sh4
-rwxr-xr-xmodules/categories/main.sh4
-rwxr-xr-xmodules/comments/main.sh4
-rwxr-xr-xmodules/files/main.sh2
-rwxr-xr-xmodules/folders/main.sh2
-rwxr-xr-xmodules/news/main.sh6
-rwxr-xr-xmodules/reference/main.sh4
-rwxr-xr-xmodules/todos/main.sh4
15 files changed, 70 insertions, 29 deletions
diff --git a/bin/ak-enter b/bin/ak-enter
index 59bb943..e5b8fbc 100755
--- a/bin/ak-enter
+++ b/bin/ak-enter
@@ -98,7 +98,7 @@ seed="$(cat $AK_ZGENESIS)"
zblock="$entrance"
# Enter temp folder
-TEMPASSIN="$(ak-tempassin)"
+TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
counter=0
diff --git a/bin/ak-profile b/bin/ak-profile
index 1712575..c686f28 100755
--- a/bin/ak-profile
+++ b/bin/ak-profile
@@ -178,7 +178,7 @@ _ak_modules_profile_import(){
# Adds a file as a profile/add ACTION on the zchain.
_ak_modules_profile_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f $ZPROFILEDIR/$1 ]; then
FILE="$ZPROFILEDIR/$1"
diff --git a/bin/ak-sm-files b/bin/ak-sm-files
index d0514f8..1d69f08 100755
--- a/bin/ak-sm-files
+++ b/bin/ak-sm-files
@@ -42,7 +42,7 @@ main(){
FILENAME="$1"
CRP="$2"
- TEMPASSIN="$(ak-tempassin)"
+ TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
echo "Adding $FILENAME"
diff --git a/bin/ak-tempassin b/bin/ak-tempassin
index 6831dc2..42042f7 100755
--- a/bin/ak-tempassin
+++ b/bin/ak-tempassin
@@ -1,14 +1,33 @@
#!/bin/bash
-AK_TEMP="$(mktemp -d /tmp/aktmp-XXXXXXX)"
-PROGRAM="$(basename $0)"
+##
+## ak-tempassin: a `mktemp` interface
+##
+## Usage:
+##
+## -h, --help Prints this help message
+##
+## -f, --file Creates a temporary file and output fullpath
+##
+## -d, --dir Makes a temporary directory and returns its
+## fullpath
+##
+fullprogrampath="$(realpath $0)"
+PROGRAM=$(basename $0)
+descriptionString="Temp file/dir creator"
+
+# At least these
source $AK_LIBDIR/_ak_log
+source $AK_LIBDIR/_ak_script
-if [ ! -d "$AK_TEMP" ]
+# Flags to run
+if [ ! -z $1 ]
then
- _ak_log_error "Could not make $AK_TEMP directory to work in"
- echo "Could not make $AK_TEMP directory to work in"
- exit 1
+ case $1 in
+ -h | --help) _ak_usage; exit;;
+ -d | --dir) _ak_make_temp_directory; exit;;
+ -f | --file) _ak_make_temp_file; exit;;
+ * ) _ak_usage;;
+ esac
+else _ak_usage
fi
-_ak_log_info "$AK_TEMP created successfully"
-echo "$AK_TEMP"
diff --git a/bin/ak-zchain-chk b/bin/ak-zchain-chk
index 89a834f..1d9a2f7 100755
--- a/bin/ak-zchain-chk
+++ b/bin/ak-zchain-chk
@@ -50,7 +50,7 @@ zblock="$entrance"
declare -A blocks_found
# Enter temp folder
-TEMPASSIN="$(ak-tempassin)"
+TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
counter=0
diff --git a/lib/_ak_fs b/lib/_ak_fs
index ea6abb4..da09f93 100755
--- a/lib/_ak_fs
+++ b/lib/_ak_fs
@@ -65,7 +65,7 @@ _ak_fs_import(){
# Merkle tree file/references
MERKLEDIR="$AK_WORKDIR/fmrk"
# A temporary root dir to work on
- TEMPORARYDIR="$(ak-tempassin)"
+ TEMPORARYDIR="$(_ak_make_temp_directory)"
# A subdir to split the files there
TECHDIR="$TEMPORARYDIR/chks"
# A pin point to return from where we came from
@@ -306,7 +306,7 @@ _ak_fs_cat(){
fmrk="$AK_WORKDIR/fmrk"
ftr="$AK_WORKDIR/ftr"
# Enter temp folder
- TEMPASSIN="$(ak-tempassin)"
+ TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
currentNode="$treeRootHash"
counter=0
diff --git a/lib/_ak_script b/lib/_ak_script
index e9d7c0e..f24fbc9 100755
--- a/lib/_ak_script
+++ b/lib/_ak_script
@@ -67,3 +67,25 @@ _ak_not_implemented(){
#_ak_title_description
_ak_log_error "Not implemented: $*"
}
+
+_ak_make_temp_directory(){
+ AK_TEMP="$(mktemp -d /tmp/aktmp-XXXXXXX)"
+ if [ ! -d "$AK_TEMP" ]
+ then
+ _ak_log_error "Could not make $AK_TEMP directory to work in"
+ exit 1
+ fi
+ _ak_log_info "$AK_TEMP created successfully"
+ echo "$AK_TEMP"
+}
+
+_ak_make_temp_file(){
+ AK_TEMP="$(mktemp /tmp/aktmp-XXXXXXX)"
+ if [ ! -f "$AK_TEMP" ]
+ then
+ _ak_log_error "Could not make $AK_TEMP directory to work in"
+ exit 1
+ fi
+ _ak_log_info "$AK_TEMP created successfully"
+ echo "$AK_TEMP"
+}
diff --git a/modules/articles/main.sh b/modules/articles/main.sh
index 29c1c34..ebc9dd8 100755
--- a/modules/articles/main.sh
+++ b/modules/articles/main.sh
@@ -28,7 +28,7 @@ else
fi
_ak_modules_articles_create(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)"
if [ -z $EDITOR ]
@@ -85,7 +85,7 @@ _ak_modules_articles_import(){
}
_ak_modules_articles_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f $1 ]; then
FILE="$1"
diff --git a/modules/categories/main.sh b/modules/categories/main.sh
index 82fc669..089b6d7 100755
--- a/modules/categories/main.sh
+++ b/modules/categories/main.sh
@@ -30,7 +30,7 @@ else
fi
_ak_modules_categories_create(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
export NEWS_FILE="$(date +%Y%m%d_%H%M%S)"
vi $NEWS_FILE
@@ -78,7 +78,7 @@ _ak_modules_categories_import(){
exit 224
}
_ak_modules_categories_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f $1 ]; then
FILE="$1"
diff --git a/modules/comments/main.sh b/modules/comments/main.sh
index f5ebabc..925bf90 100755
--- a/modules/comments/main.sh
+++ b/modules/comments/main.sh
@@ -38,7 +38,7 @@ _ak_modules_comments_create(){
echo "ERROR" "No reference given"
exit 1
fi
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
export COMMENTS_FILE="$(date -u +%s)"
vi $COMMENTS_FILE
@@ -68,7 +68,7 @@ _ak_modules_comments_index(){
}
_ak_modules_comments_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f "$ZCOMMENTSDIR/$1" ]; then
FILE=$ZCOMMENTSDIR/$1
diff --git a/modules/files/main.sh b/modules/files/main.sh
index a3202fe..809d76d 100755
--- a/modules/files/main.sh
+++ b/modules/files/main.sh
@@ -41,7 +41,7 @@ main(){
CRP="$2"
echo "Adding $FILENAME"
_ak_log_info "Switching to tmp folder..."
- TEMPASSIN="$(ak-tempassin)"
+ TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
if [ $? == 0 ]; then
_ak_log_info "Success"
diff --git a/modules/folders/main.sh b/modules/folders/main.sh
index f155548..a87881d 100755
--- a/modules/folders/main.sh
+++ b/modules/folders/main.sh
@@ -25,7 +25,7 @@ else
_ak_log_info "Found $ZFOLDERSDIR"
exit 1
fi
-TEMPASSIN="$(ak-tempassin)"
+TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
diff --git a/modules/news/main.sh b/modules/news/main.sh
index 1a0b5e0..8770eea 100755
--- a/modules/news/main.sh
+++ b/modules/news/main.sh
@@ -48,7 +48,7 @@ fi
cd $ZNEWSDIR
_ak_modules_news_create(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
cd
curpath="$(pwd)"
@@ -113,7 +113,7 @@ _ak_modules_news_import(){
}
_ak_modules_news_add_from_file(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
if [ -f "$1" ]; then
FILE="$(realpath $1)"
cp $FILE $ZNEWSDIR
@@ -152,7 +152,7 @@ EOF
}
_ak_modules_news_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f $ZNEWSDIR/$1 ]; then
FILE="$1"
diff --git a/modules/reference/main.sh b/modules/reference/main.sh
index e6c06d3..b17b7ce 100755
--- a/modules/reference/main.sh
+++ b/modules/reference/main.sh
@@ -30,7 +30,7 @@ else
fi
_ak_modules_reference_create(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
export REFERENCEFILE="$(date -u +%s)"
if [ ! -z $1 ] && [ ! -z $2 ]
@@ -92,7 +92,7 @@ _ak_modules_reference_import(){
}
_ak_modules_reference_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ ! -f $1 ]; then
echo "File $FILE doesn't exist";
diff --git a/modules/todos/main.sh b/modules/todos/main.sh
index 299bcb0..a9786a1 100755
--- a/modules/todos/main.sh
+++ b/modules/todos/main.sh
@@ -36,7 +36,7 @@ else
fi
_ak_modules_todos_create(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
export TODOS_FILE="$(date -u +%s)"
vi $TODOS_FILE
@@ -87,7 +87,7 @@ _ak_modules_todos_import(){
}
_ak_modules_todos_add(){
- TEMP="$(ak-tempassin)"
+ TEMP="$(_ak_make_temp_directory)"
cd $TEMP
if [ -f $1 ]; then
FILE="$1"