aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.com>2021-12-25 17:40:02 +0200
committerkaotisk <kaotisk@arching-kaos.com>2021-12-25 17:40:02 +0200
commit136f49738454f5441b7b44a76a837aea16c79b71 (patch)
tree2cee419a31e902c7ef7598b718e4c4b48ee7bde6
parent16ef6e4c03e1c69afd9419888f475fe5fb16e9b7 (diff)
downloadarching-kaos-tools-136f49738454f5441b7b44a76a837aea16c79b71.tar.gz
arching-kaos-tools-136f49738454f5441b7b44a76a837aea16c79b71.tar.bz2
arching-kaos-tools-136f49738454f5441b7b44a76a837aea16c79b71.zip
Added temporary folder
-rwxr-xr-xbin/news49
1 files changed, 42 insertions, 7 deletions
diff --git a/bin/news b/bin/news
index bd0bc95..cd6f55b 100755
--- a/bin/news
+++ b/bin/news
@@ -1,5 +1,6 @@
#!/bin/bash
ZNEWSDIR="$WORKDIR/news"
+TEMP="/tmp/aktmp"
echo $ZNEWSDIR
if [ ! -d $ZNEWSDIR ]; then
mkdir $ZNEWSDIR
@@ -9,11 +10,26 @@ if [ ! -d $ZNEWSDIR ]; then
echo "Qmetc" >> README
git add README
git commit -m "Initiated news repository"
- echo znewsdir created along with git repo
+ echo "znewsdir created along with git repo"
else
- echo znewsdir found
+ 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
export NEWS_FILE="$(date +%Y%m%d_%H%M%S)"
vi $NEWS_FILE
echo "Renaming..."
@@ -21,12 +37,14 @@ create(){
TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' )
IPFS_FILE=$(ipfs add -q $NEWS_FILE)
mv $NEWS_FILE $ZNEWSDIR/$TO_FILE
- cd $ZNEWSDIR
- sed -e 's,Qm.*,'"$IPFS_FILE"',g' README
- add $TO_FILE
+ sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZNEWSDIR/README
+ add $ZNEWSDIR/$TO_FILE
echo "Adding to git repo..."
+ cd $ZNEWSDIR
git add $TO_FILE README
git commit -m "Added $TO_FILE with $(head -n 1 $ZNEWSDIR/$TO_FILE)"
+ git clean --force
+ # rm -rf $TEMP
}
index(){
FILES="$(ls -1 $ZNEWSDIR)"
@@ -45,10 +63,28 @@ title(){
}
import(){
echo "#TODO"
- echo $1
+ if [ ! -z $1 ]
+ then
+ if [ ! -d $1 ]
+ then
+ echo "Folder does not exists"
+ exit 4
+ else
+ echo "Folder $1 exists"
+ fl="$(ls -1 $1)"
+ for f in $fl
+ do
+ add $1/$f
+ done
+ fi
+ else
+ echo "No value"
+ exit 6
+ fi
exit 224
}
add(){
+ tempassin
if [ -f $1 ]; then
FILE="$1"
echo "Adding news from " $FILE
@@ -75,7 +111,6 @@ EOF
if [ $? == 0 ]
then
echo "News added successfully"
- exit 0
else
echo "error??"
exit 1