aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-06-09 06:52:03 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-06-09 06:52:03 +0300
commitba1173c9ec87b14a6ba6772d5ebfaafb81c7f888 (patch)
tree38c4c4972844d8616f220aa65e00b265ff7945ec
parent1a572d674b2c94bbe5b094f563c4875c77575227 (diff)
downloadarching-kaos-tools-ba1173c9ec87b14a6ba6772d5ebfaafb81c7f888.tar.gz
arching-kaos-tools-ba1173c9ec87b14a6ba6772d5ebfaafb81c7f888.tar.bz2
arching-kaos-tools-ba1173c9ec87b14a6ba6772d5ebfaafb81c7f888.zip
Refactoring
-rwxr-xr-xbin/ak2
-rwxr-xr-xbin/ak-config16
-rwxr-xr-xbin/ak-ipfs-starter3
-rwxr-xr-xbin/ak-node-info14
-rwxr-xr-xbin/ak-profile6
-rwxr-xr-xbin/ak-startup14
-rwxr-xr-xlib/_ak_ipfs7
-rwxr-xr-xlib/_ak_node14
-rwxr-xr-xmodules/articles/main.sh (renamed from modules/ak-articles)15
-rwxr-xr-xmodules/categories/main.sh (renamed from modules/ak-categories)0
-rwxr-xr-xmodules/comments/main.sh (renamed from modules/ak-comments)0
-rwxr-xr-xmodules/files/main.sh (renamed from modules/ak-files)0
-rwxr-xr-xmodules/folders/main.sh (renamed from modules/ak-folders)0
-rwxr-xr-xmodules/mixtapes/main.sh (renamed from modules/ak-mixtapes)0
-rwxr-xr-xmodules/news/main.sh (renamed from modules/ak-news)0
-rwxr-xr-xmodules/reference/main.sh (renamed from modules/ak-reference)0
-rwxr-xr-xmodules/repositories/main.sh (renamed from modules/ak-repositories)0
-rwxr-xr-xmodules/roadmap/main.sh (renamed from modules/ak-roadmap)0
-rwxr-xr-xmodules/todos/main.sh (renamed from modules/ak-todos)0
-rwxr-xr-xupdate.sh9
20 files changed, 57 insertions, 43 deletions
diff --git a/bin/ak b/bin/ak
index c9f960e..539176a 100755
--- a/bin/ak
+++ b/bin/ak
@@ -64,7 +64,7 @@ case "$1" in
exit 1
fi
subargs="$*"
- $subcmd $subargs
+ $subcmd/main.sh $subargs
_ak_exit_program $? "$subcmd module finished";
;;
esac
diff --git a/bin/ak-config b/bin/ak-config
index 1655593..bda8564 100755
--- a/bin/ak-config
+++ b/bin/ak-config
@@ -17,6 +17,7 @@ descriptionString="Arching Kaos Configuration Tool"
source $AK_LIBDIR/_ak_script
source $AK_LIBDIR/_ak_gpg
source $AK_LIBDIR/_ak_ipfs
+source $AK_LIBDIR/_ak_node
_ak_config_show(){
# We will be using our public key also to put it in the block later
@@ -29,9 +30,9 @@ _ak_config_show(){
echo '
{
"profile":'$profile',
- "genesis":"'$(cat $HOME/.arching-kaos/config/zgenesis)'",
+ "genesis":"'$(cat $AK_WORKDIR/config/zgenesis)'",
"gpg":"'$GPG_PUB_KEY'",
- "zchain":"'$(cat $HOME/.arching-kaos/config/zchain)'",
+ "zchain":"'$(cat $AK_WORKDIR/config/zchain)'",
"zlatest":"'$(ak-get-zlatest)'"
}'| jq;
}
@@ -39,12 +40,12 @@ _ak_config_show(){
_ak_config_publish(){
_ak_config_show | jq -c -M > tmpfile
_ak_ipfs key list | grep ak-config 2> /dev/null 1>&2
- if [ "$?" -ne 0 ]
+ if [ $? -ne 0 ]
then
- _ak_ipfs key gen ak-config
+ _ak_ipfs_key_gen ak-config
fi
_ak_ipfs_name_publish --key=ak-config /ipfs/$(_ak_ipfs_add tmpfile)
- if [ "$?" != 0 ]
+ if [ $? != 0 ]
then
echo -e "\033[0;34mError on publishing\033[0;0m\nYour information:\n"
cat tmpfile
@@ -54,10 +55,11 @@ _ak_config_publish(){
}
_ak_config_published(){
- _ak_ipfs_cat $(ak-node-info --ipfs) | jq
+ _ak_ipfs_cat $(_ak_node_info_ipfs_hash) | jq
}
-if [ ! -z $1 ]; then
+if [ ! -z $1 ] && [ -n "$1" ]
+then
case $1 in
--help| -h) _ak_usage;exit;;
--show) _ak_config_show;exit;;
diff --git a/bin/ak-ipfs-starter b/bin/ak-ipfs-starter
index ae483f8..6b63c3c 100755
--- a/bin/ak-ipfs-starter
+++ b/bin/ak-ipfs-starter
@@ -2,8 +2,9 @@
PROGRAM="$(basename $0)"
source $AK_LIBDIR/_ak_log
+source $AK_LIBDIR/_ak_ipfs
-screen -dmS akipfsd ak-ipfs-daemon
+screen -dmS akipfsd _ak_ipfs_daemon
if [ $? -ne 0 ]
then
logit "ERROR" "Failed to start IPFS daemon"
diff --git a/bin/ak-node-info b/bin/ak-node-info
index b667fd3..42f6822 100755
--- a/bin/ak-node-info
+++ b/bin/ak-node-info
@@ -15,19 +15,7 @@ PROGRAM=$(basename $0)
descriptionString="Quick description"
source $AK_LIBDIR/_ak_log
source $AK_LIBDIR/_ak_script
-source $AK_LIBDIR/_ak_ipfs
-# Resolves the IPNS key "ak-config" to its current IPFS value
-# Return IPFS CIDv0 without /ipfs/ prefix
-_ak_node_info_ipfs_hash(){
- _ak_ipfs_name_resolve /ipns/$(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///'
-}
-
-# Finds ak-config ipns key
-# Returns IPNS key
-_ak_node_info_ipns_key(){
- _ak_ipfs_key_list_full | grep ak-config | awk '{print $1}'
-}
-
+source $AK_LIBDIR/_ak_node
if [ ! -z "$1" ]
then
diff --git a/bin/ak-profile b/bin/ak-profile
index d513c9a..2fab750 100755
--- a/bin/ak-profile
+++ b/bin/ak-profile
@@ -81,7 +81,7 @@ _ak_modules_profile_propget(){
fi
}
-propwrite(){
+_ak_modules_profile_propwrite(){
cat > $ZPROPERTY_FILE << EOF
{
"$ZPROPERTY_KEY":"${ZPROPERTY_VALUE}"
@@ -113,7 +113,7 @@ _ak_modules_profile_propset(){
then
touch $ZPROPERTY_FILE
echo "$ZPROPERTY_KEY = $ZPROPERTY_VALUE in file $ZPROPERTY_FILE"
- propwrite #"$ZPROPERTY_FILE" "${ZPROPERTY_VALUE}"
+ _ak_modules_profile_propwrite #"$ZPROPERTY_FILE" "${ZPROPERTY_VALUE}"
else
echo "No value for $1"
fi
@@ -123,7 +123,7 @@ _ak_modules_profile_propset(){
ZPROPERTY_VALUE="$2"
read -p "Overwrite $1 with ${ZPROPERTY_VALUE} ? " yn
case $yn in
- [Yy]* ) propwrite;;# "$ZPROPERTY_" "${ZPROPERTY_VALUE}";;
+ [Yy]* ) _ak_modules_profile_propwrite;;# "$ZPROPERTY_" "${ZPROPERTY_VALUE}";;
[Nn]* ) exit 130;;
* ) echo "Answer please";;
esac
diff --git a/bin/ak-startup b/bin/ak-startup
index 7a67e58..87d1fe3 100755
--- a/bin/ak-startup
+++ b/bin/ak-startup
@@ -1,12 +1,14 @@
#!/bin/bash
-PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:$HOME/bin:$HOME/.arching-kaos/bin
-#screen -dmS ipfs-daemon ipfs daemon
source $HOME/.arching-kaos/rc
-ak-ipfs-starter
-ak-log-rotate
-# screen -dmS akdaemon
+PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:$HOME/bin:$AK_WORKDIR/bin
+
+source $AK_LIBDIR/_ak_ipfs
+source $AK_LIBDIR/_ak_log
+_ak_ipfs_starter
+_ak_log_rotate
+
ak-daemon > $AK_WORKDIR/akd.log 2>&1 & printf '%s' "$!" > $AK_WORKDIR/akd.pid
if [ ! -z $1 ] && [ -n "$1" ] && [ "$1" == "--podman" ]
then
- ak log follow
+ _ak_log_follow
fi
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs
index 8780f51..1f2b5ce 100755
--- a/lib/_ak_ipfs
+++ b/lib/_ak_ipfs
@@ -6,6 +6,11 @@ _ak_ipfs(){
export IPFS_PATH=$AK_IPFS_REPO; ipfs $*
}
+_ak_ipfs_daemon(){
+ _ak_ipfs daemon --routing=dht --migrate &
+ printf '%s' "$!" > $AK_WORKDIR/akipfsd.pid
+}
+
_ak_ipfs_get_peers(){
_ak_ipfs swarm peers 1> /dev/null 2>&1
if [ $? == 0 ]
@@ -288,7 +293,7 @@ _ak_ipfs_swarm_peers(){
}
_ak_ipfs_starter(){
- _ak_ipfs daemon --routing=dht --migrate
+ _ak_ipfs_daemon
if [ $? -ne 0 ]
then
logit "ERROR" "Failed to start IPFS daemon"
diff --git a/lib/_ak_node b/lib/_ak_node
new file mode 100755
index 0000000..c1436d9
--- /dev/null
+++ b/lib/_ak_node
@@ -0,0 +1,14 @@
+#!/bin/bash
+source $AK_LIBDIR/_ak_ipfs
+
+# Resolves the IPNS key "ak-config" to its current IPFS value
+# Return IPFS CIDv0 without /ipfs/ prefix
+_ak_node_info_ipfs_hash(){
+ _ak_ipfs_name_resolve /ipns/$(_ak_node_info_ipns_key) | sed -e 's/\/ipfs\///'
+}
+
+# Finds ak-config ipns key
+# Returns IPNS key
+_ak_node_info_ipns_key(){
+ _ak_ipfs_key_list_full | grep ak-config | awk '{print $1}'
+}
diff --git a/modules/ak-articles b/modules/articles/main.sh
index 97a8e8d..382466b 100755
--- a/modules/ak-articles
+++ b/modules/articles/main.sh
@@ -22,11 +22,6 @@ TEMP="/tmp/aktmp"
if [ ! -d $ZARTICLESDIR ]; then
mkdir $ZARTICLESDIR
cd $ZARTICLESDIR
- #git init
- echo "Articles repository" > README
- echo "Qmetc" >> README
- #git add README
- #git commit -m "Initiated articles repository"
logit "INFO" "zarticlesdir created"
else
logit "INFO" "zarticlesdir found"
@@ -51,11 +46,9 @@ _ak_modules_articles_create(){
_ak_modules_articles_add $ZARTICLESDIR/$TO_FILE
logit "INFO" "Adding to git repo..."
cd $ZARTICLESDIR
- # git add $TO_FILE README
- # git commit -m "Added $TO_FILE with $(head -n 1 $ZARTICLESDIR/$TO_FILE)"
- # git clean --force
rm -rf $TEMP
}
+
_ak_modules_articles_index(){
FILES="$(ls -1 $ZARTICLESDIR)"
i=0
@@ -67,9 +60,7 @@ _ak_modules_articles_index(){
let i+=1
done
}
-_ak_modules_articles_title(){
- description
-}
+
_ak_modules_articles_import(){
echo "#TODO"
if [ ! -z $1 ]
@@ -92,6 +83,7 @@ _ak_modules_articles_import(){
fi
exit 224
}
+
_ak_modules_articles_add(){
TEMP="$(ak-tempassin)"
cd $TEMP
@@ -126,6 +118,7 @@ EOF
exit 1
fi
}
+
if [ ! -z $1 ]; then
case $1 in
-h | --help) _ak_usage; exit;;
diff --git a/modules/ak-categories b/modules/categories/main.sh
index c0e1e77..c0e1e77 100755
--- a/modules/ak-categories
+++ b/modules/categories/main.sh
diff --git a/modules/ak-comments b/modules/comments/main.sh
index 6193e2f..6193e2f 100755
--- a/modules/ak-comments
+++ b/modules/comments/main.sh
diff --git a/modules/ak-files b/modules/files/main.sh
index 73c8219..73c8219 100755
--- a/modules/ak-files
+++ b/modules/files/main.sh
diff --git a/modules/ak-folders b/modules/folders/main.sh
index 5aa82c7..5aa82c7 100755
--- a/modules/ak-folders
+++ b/modules/folders/main.sh
diff --git a/modules/ak-mixtapes b/modules/mixtapes/main.sh
index 712bb54..712bb54 100755
--- a/modules/ak-mixtapes
+++ b/modules/mixtapes/main.sh
diff --git a/modules/ak-news b/modules/news/main.sh
index b015bd6..b015bd6 100755
--- a/modules/ak-news
+++ b/modules/news/main.sh
diff --git a/modules/ak-reference b/modules/reference/main.sh
index 157b797..157b797 100755
--- a/modules/ak-reference
+++ b/modules/reference/main.sh
diff --git a/modules/ak-repositories b/modules/repositories/main.sh
index ffda701..ffda701 100755
--- a/modules/ak-repositories
+++ b/modules/repositories/main.sh
diff --git a/modules/ak-roadmap b/modules/roadmap/main.sh
index a30894a..a30894a 100755
--- a/modules/ak-roadmap
+++ b/modules/roadmap/main.sh
diff --git a/modules/ak-todos b/modules/todos/main.sh
index afe56f8..afe56f8 100755
--- a/modules/ak-todos
+++ b/modules/todos/main.sh
diff --git a/update.sh b/update.sh
index db47d8b..09fe584 100755
--- a/update.sh
+++ b/update.sh
@@ -30,6 +30,15 @@ do
fi
done
+find $AK_MODULESDIR -type l | while read link
+do
+ if [ ! -f $link ]
+ then
+ echo "Non working link: $(basename $link) removing..."
+ rm $link
+ fi
+done
+
# Find scripts and create symlinks
libfiles=$(ls -1 $(pwd)/lib)
for l in $libfiles