aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-04-03 01:14:58 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-04-03 01:14:58 +0300
commitd747677c2860326e7d673861319dcb0e2149daa4 (patch)
tree640c4bbca466665eee68e4735688b3cdd4022ee3
parent4f8fb0a8acd5eec0caaf1087d7ecf91f9166c807 (diff)
downloadarching-kaos-tools-d747677c2860326e7d673861319dcb0e2149daa4.tar.gz
arching-kaos-tools-d747677c2860326e7d673861319dcb0e2149daa4.tar.bz2
arching-kaos-tools-d747677c2860326e7d673861319dcb0e2149daa4.zip
Fixed temporary folder creation
-rwxr-xr-xbin/ak-articles22
-rwxr-xr-xbin/ak-categories21
-rwxr-xr-xbin/ak-comments20
-rwxr-xr-xbin/ak-files17
-rwxr-xr-xbin/ak-folders17
-rwxr-xr-xbin/ak-news24
-rwxr-xr-xbin/ak-profile17
-rwxr-xr-xbin/ak-reference20
-rwxr-xr-xbin/ak-sm-files17
-rwxr-xr-xbin/ak-tempassin10
-rwxr-xr-xbin/ak-todos21
11 files changed, 40 insertions, 166 deletions
diff --git a/bin/ak-articles b/bin/ak-articles
index 1eb3056..e198712 100755
--- a/bin/ak-articles
+++ b/bin/ak-articles
@@ -14,21 +14,10 @@ if [ ! -d $ZARTICLESDIR ]; then
else
echo "zarticlesdir 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
-}
+
create(){
- tempassin $TEMP
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
pwd
export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)"
vi $ARTICLES_FILE
@@ -83,8 +72,9 @@ import(){
fi
exit 224
}
-add(){
- tempassin
+add()
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $1 ]; then
FILE="$1"
echo "Adding articles from " $FILE
diff --git a/bin/ak-categories b/bin/ak-categories
index 5bc67d7..45d11ff 100755
--- a/bin/ak-categories
+++ b/bin/ak-categories
@@ -14,22 +14,10 @@ if [ ! -d $ZNEWSDIR ]; then
else
echo "znewsdir 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
-}
+
create(){
- tempassin $TEMP
- pwd
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
export NEWS_FILE="$(date +%Y%m%d_%H%M%S)"
vi $NEWS_FILE
echo "Renaming..."
@@ -84,7 +72,8 @@ import(){
exit 224
}
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $1 ]; then
FILE="$1"
echo "Adding news from " $FILE
diff --git a/bin/ak-comments b/bin/ak-comments
index 2934e00..7feb889 100755
--- a/bin/ak-comments
+++ b/bin/ak-comments
@@ -9,19 +9,7 @@ if [ ! -d $ZCOMMENTSDIR ]; then
else
ak-logthis "[INFO]" "zcommentsdir 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
-}
+
create(){
if [ ! -z $1 ]
then
@@ -31,7 +19,8 @@ create(){
echo "[ERROR]" "No reference given"
exit 1
fi
- tempassin $TEMP
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
export COMMENTS_FILE="$(date -u +%s)"
vi $COMMENTS_FILE
echo "Renaming..."
@@ -65,7 +54,8 @@ title(){
echo comments
}
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f "$ZCOMMENTSDIR/$1" ]; then
FILE=$ZCOMMENTSDIR/$1
echo "Adding comments from " $FILE
diff --git a/bin/ak-files b/bin/ak-files
index 448ae76..92c7e17 100755
--- a/bin/ak-files
+++ b/bin/ak-files
@@ -21,21 +21,6 @@ if [ ! -d $ZFILESDIR ]; then
else
logit "[INFO]" "$ZFILESDIR 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(){
echo "$PROGRAM - file"
@@ -52,7 +37,7 @@ main(){
CRP="$2"
echo "Adding $FILENAME"
logit "[INFO]" "Switching to tmp folder..."
- TEMPASSIN="$(tempassin)"
+ TEMPASSIN="$(ak-tempassin)"
cd $TEMPASSIN
if [ $? == 0 ]; then
logit "[INFO]" "Success"
diff --git a/bin/ak-folders b/bin/ak-folders
index df88ca1..b30f401 100755
--- a/bin/ak-folders
+++ b/bin/ak-folders
@@ -10,21 +10,6 @@ if [ ! -d $ZFOLDERSDIR ]; then
else
ak-logthis "error $ZFOLDERSDIR 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
@@ -42,7 +27,7 @@ main(){
CRP="$2"
echo "Adding $FOLDERNAME"
ak-logthis "Switching to tmp folder..."
- TEMPASSIN="$(tempassin)"
+ TEMPASSIN="$(ak-tempassin)"
cd $TEMPASSIN
if [ $? == 0 ]; then
ak-logthis "Success"
diff --git a/bin/ak-news b/bin/ak-news
index 1658065..812ef34 100755
--- a/bin/ak-news
+++ b/bin/ak-news
@@ -22,22 +22,10 @@ fi
cd $ZNEWSDIR
-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
-}
-
create(){
- tempassin $TEMP
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
+ cd
curpath="$(pwd)"
export NEWS_FILE="$(date +%Y%m%d_%H%M%S)"
vi $NEWS_FILE
@@ -92,7 +80,8 @@ import(){
exit 224
}
add2(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $1 ]; then
FILE="$1"
cp $FILE $ZNEWSDIR
@@ -126,7 +115,8 @@ EOF
fi
}
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $ZNEWSDIR/$1 ]; then
FILE="$1"
echo "Adding news from " $FILE
diff --git a/bin/ak-profile b/bin/ak-profile
index 63df6fd..0b08fe3 100755
--- a/bin/ak-profile
+++ b/bin/ak-profile
@@ -18,20 +18,6 @@ else
logit "[INFO]" "zprofiledir 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"
-}
# This is working with DATA blocks. DATA that matched profile/add ACTION
#
@@ -163,7 +149,8 @@ import(){
# Adds a file as a profile/add ACTION on the zchain.
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $ZPROFILEDIR/$1 ]; then
FILE="$ZPROFILEDIR/$1"
echo "Adding from " $FILE
diff --git a/bin/ak-reference b/bin/ak-reference
index e2ad2df..2484ba0 100755
--- a/bin/ak-reference
+++ b/bin/ak-reference
@@ -14,21 +14,10 @@ if [ ! -d $ZREFERENCESDIR ]; then
else
ak-logthis "zreferencesdir 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
-}
+
create(){
- tempassin $TEMP
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
#pwd
export REFERENCEFILE="$(date -u +%s)"
if [ ! -z $1 ] && [ ! -z $2 ]
@@ -95,7 +84,8 @@ import(){
exit 224
}
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $1 ]; then
FILE="$1"
echo "Adding references from " $FILE
diff --git a/bin/ak-sm-files b/bin/ak-sm-files
index 7eb3b7d..a22c0d7 100755
--- a/bin/ak-sm-files
+++ b/bin/ak-sm-files
@@ -21,21 +21,6 @@ if [ ! -d $ZFILESDIR ]; then
else
logit "[INFO]" "$ZFILESDIR 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(){
echo "$PROGRAM - file"
@@ -54,7 +39,7 @@ main(){
CRP="$2"
echo "Adding $FILENAME"
logit "[INFO]" "Switching to tmp folder..."
- TEMPASSIN="$(tempassin)"
+ TEMPASSIN="$(ak-tempassin)"
cd $TEMPASSIN
if [ $? == 0 ]; then
diff --git a/bin/ak-tempassin b/bin/ak-tempassin
index 101796e..e692769 100755
--- a/bin/ak-tempassin
+++ b/bin/ak-tempassin
@@ -1,9 +1,3 @@
#!/bin/bash
-TEMP="/tmp/aktmp"
-TIMESTAMP="$(date -u +%s)"
-export TEMPASSIN="${TEMP}_${TIMESTAMP}"
-if [ ! -d $TEMPASSIN ]; then
- mkdir $TEMPASSIN
-fi
-cd $TEMPASSIN
-echo "Created temporariry folder $TEMPASSASIN"
+AK_TEMP="mktemp -d aktmp-XXXXXXX"
+echo "$AK_TEMP"
diff --git a/bin/ak-todos b/bin/ak-todos
index 218feda..46b9021 100755
--- a/bin/ak-todos
+++ b/bin/ak-todos
@@ -13,22 +13,10 @@ if [ ! -d $ZTODOSDIR ]; then
else
ak-logthis "ztodosdir 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
-}
+
create(){
- tempassin $TEMP
- pwd
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
export TODOS_FILE="$(date -u +%s)"
vi $TODOS_FILE
ak-logthis "Renaming..."
@@ -83,7 +71,8 @@ import(){
exit 224
}
add(){
- tempassin
+ TEMP="$(ak-tempassin)"
+ cd $TEMP
if [ -f $1 ]; then
FILE="$1"
ak-logthis "Adding todos from $FILE"