aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-06-04 18:07:39 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-06-04 18:07:39 +0300
commit0d1777251dea7d35cd774518959b4377673e1cab (patch)
treeb3d7a15725641c9e3d1d7b45150135e1f8ce9a71
parent684dd3e038ae90f0fd1f53211ce4d30141e35bf2 (diff)
downloadarching-kaos-tools-0d1777251dea7d35cd774518959b4377673e1cab.tar.gz
arching-kaos-tools-0d1777251dea7d35cd774518959b4377673e1cab.tar.bz2
arching-kaos-tools-0d1777251dea7d35cd774518959b4377673e1cab.zip
Refactoring, modules directory introduced
- All modules are now stored separately from the rest of the bin/ - You can run them now with `ak -m <module> <args>` - Files affected: * bin/ak-articles -> modules/ak-articles * bin/ak-categories -> modules/ak-categories * bin/ak-comments -> modules/ak-comments * bin/ak-files -> modules/ak-files * bin/ak-folders -> modules/ak-folders * bin/ak-mixtapes -> modules/ak-mixtapes * bin/ak-news -> modules/ak-news * bin/ak-reference -> modules/ak-reference * bin/ak-repositories -> modules/ak-repositories * bin/ak-roadmap -> modules/ak-roadmap * bin/ak-todos -> modules/ak-todos
-rwxr-xr-xbin/ak18
-rwxr-xr-xconfig.sh1
-rwxr-xr-xinit.sh23
-rwxr-xr-xinstall.sh1
-rwxr-xr-xmodules/ak-articles (renamed from bin/ak-articles)0
-rwxr-xr-xmodules/ak-categories (renamed from bin/ak-categories)0
-rwxr-xr-xmodules/ak-comments (renamed from bin/ak-comments)0
-rwxr-xr-xmodules/ak-files (renamed from bin/ak-files)0
-rwxr-xr-xmodules/ak-folders (renamed from bin/ak-folders)0
-rwxr-xr-xmodules/ak-mixtapes (renamed from bin/ak-mixtapes)0
-rwxr-xr-xmodules/ak-news (renamed from bin/ak-news)3
-rwxr-xr-xmodules/ak-reference (renamed from bin/ak-reference)0
-rwxr-xr-xmodules/ak-repositories (renamed from bin/ak-repositories)0
-rwxr-xr-xmodules/ak-roadmap (renamed from bin/ak-roadmap)0
-rwxr-xr-xmodules/ak-todos (renamed from bin/ak-todos)0
-rwxr-xr-xupdate.sh11
16 files changed, 48 insertions, 9 deletions
diff --git a/bin/ak b/bin/ak
index c64ee44..a1bc85f 100755
--- a/bin/ak
+++ b/bin/ak
@@ -52,14 +52,16 @@ fi
subcmd="$(echo $* | sed -e 's/ /-/g')"
# Add functionality for separate modules directory
-# case "$1" in
-# -m|--module)
-# shift
-# subcmd="modules/$(echo $* | sed -e 's/ /-/g')"
-# ;;
-# esac
-#
-# echo $subcmd
+case "$1" in
+ -m|--module)
+ shift
+ subcmd="$AK_MODULESDIR/$(echo $1 | sed -e 's/ /-/g')"
+ shift
+ subargs="$*"
+ $subcmd $subargs
+ _ak_exit_program $? "$subcmd module finished";
+ ;;
+esac
if [ -f "$AK_BINDIR/ak-$subcmd" ]
then
diff --git a/config.sh b/config.sh
index c122584..572041b 100755
--- a/config.sh
+++ b/config.sh
@@ -4,6 +4,7 @@ export AK_WORKDIR="$AK_ROOT/.arching-kaos"
export AK_CONFIGDIR="$AK_WORKDIR/config"
export AK_BINDIR="$AK_WORKDIR/bin"
export AK_LIBDIR="$AK_WORKDIR/lib"
+export AK_MODULESDIR="$AK_WORKDIR/modules"
export AK_ZBLOCKDIR="$AK_WORKDIR/zblocks"
export AK_BLOCKDIR="$AK_WORKDIR/blocks"
export AK_DATADIR="$AK_WORKDIR/data"
diff --git a/init.sh b/init.sh
index 331c1ae..30532f9 100755
--- a/init.sh
+++ b/init.sh
@@ -97,6 +97,7 @@ do
printf "\tOK!\n"
fi
done
+
# Find libs and create symlinks
libfiles=$(ls -1 $(pwd)/lib)
for b in $libfiles
@@ -118,3 +119,25 @@ do
printf "\tOK!\n"
fi
done
+#
+# Find modules and create symlinks
+modfiles=$(ls -1 $(pwd)/modules)
+for m in $modfiles
+do
+ if [ ! -L $AK_MODULESDIR/$m ]
+ then
+ printf "Creating symlink to %s..." "$m"
+ ln -s $(pwd)/modules/$b $AK_MODULESDIR/$m
+ if [ $? -ne 0 ]
+ then
+ if [ -L $AK_MODULESDIR/$m ]
+ then
+ printf "\tAlready exists!\n"
+ exit 1
+ fi
+ printf "\tFailed!\n"
+ exit 1
+ fi
+ printf "\tOK!\n"
+ fi
+done
diff --git a/install.sh b/install.sh
index 9d78acb..e05a634 100755
--- a/install.sh
+++ b/install.sh
@@ -147,6 +147,7 @@ fi
if [ ! -d $AK_CONFIGDIR ] ; then mkdir $AK_CONFIGDIR ;fi
if [ ! -d $AK_BINDIR ]; then mkdir $AK_BINDIR ;fi
if [ ! -d $AK_LIBDIR ]; then mkdir $AK_LIBDIR ;fi
+if [ ! -d $AK_MODULESDIR ]; then mkdir $AK_MODULESDIR ;fi
if [ ! -d $AK_ZBLOCKDIR ]; then mkdir $AK_ZBLOCKDIR ;fi
if [ ! -d $AK_BLOCKDIR ]; then mkdir $AK_BLOCKDIR ;fi
if [ ! -d $AK_DATADIR ]; then mkdir $AK_DATADIR ;fi
diff --git a/bin/ak-articles b/modules/ak-articles
index 97a8e8d..97a8e8d 100755
--- a/bin/ak-articles
+++ b/modules/ak-articles
diff --git a/bin/ak-categories b/modules/ak-categories
index c0e1e77..c0e1e77 100755
--- a/bin/ak-categories
+++ b/modules/ak-categories
diff --git a/bin/ak-comments b/modules/ak-comments
index 6193e2f..6193e2f 100755
--- a/bin/ak-comments
+++ b/modules/ak-comments
diff --git a/bin/ak-files b/modules/ak-files
index 73c8219..73c8219 100755
--- a/bin/ak-files
+++ b/modules/ak-files
diff --git a/bin/ak-folders b/modules/ak-folders
index 5aa82c7..5aa82c7 100755
--- a/bin/ak-folders
+++ b/modules/ak-folders
diff --git a/bin/ak-mixtapes b/modules/ak-mixtapes
index 712bb54..712bb54 100755
--- a/bin/ak-mixtapes
+++ b/modules/ak-mixtapes
diff --git a/bin/ak-news b/modules/ak-news
index 5865d15..b015bd6 100755
--- a/bin/ak-news
+++ b/modules/ak-news
@@ -32,6 +32,7 @@ source $AK_LIBDIR/_ak_script
source $AK_LIBDIR/_ak_ipfs
source $AK_LIBDIR/_ak_gpg
source $AK_LIBDIR/_ak_zblock
+source $AK_LIBDIR/_ak_zchain
if [ ! -d $ZNEWSDIR ]; then
mkdir $ZNEWSDIR
@@ -67,7 +68,7 @@ _ak_modules_news_create(){
_ak_modules_news_index(){
FILES="$(ls -1 $ZNEWSDIR)"
i=0
- ak-zchain-extract-cids | sort | uniq > temp
+ _ak_zchain_extract_cids | sort | uniq > temp
for FILE in $FILES
do
DATE="$(echo $FILE | cut -d - -f 1 | awk '{print $1}')"
diff --git a/bin/ak-reference b/modules/ak-reference
index 157b797..157b797 100755
--- a/bin/ak-reference
+++ b/modules/ak-reference
diff --git a/bin/ak-repositories b/modules/ak-repositories
index ffda701..ffda701 100755
--- a/bin/ak-repositories
+++ b/modules/ak-repositories
diff --git a/bin/ak-roadmap b/modules/ak-roadmap
index a30894a..a30894a 100755
--- a/bin/ak-roadmap
+++ b/modules/ak-roadmap
diff --git a/bin/ak-todos b/modules/ak-todos
index afe56f8..afe56f8 100755
--- a/bin/ak-todos
+++ b/modules/ak-todos
diff --git a/update.sh b/update.sh
index 31e49d1..db47d8b 100755
--- a/update.sh
+++ b/update.sh
@@ -40,3 +40,14 @@ do
ln -s $(pwd)/lib/$l $AK_LIBDIR/$l
fi
done
+
+# Find modules and create symlinks
+modfiles=$(ls -1 $(pwd)/modules)
+for m in $modfiles
+do
+ if [ ! -L $AK_MODULESDIR/$m ]
+ then
+ echo "Non existing link: $(basename $m) creating..."
+ ln -s $(pwd)/modules/$m $AK_MODULESDIR/$m
+ fi
+done