aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-profile
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ak-profile')
-rwxr-xr-xbin/ak-profile48
1 files changed, 34 insertions, 14 deletions
diff --git a/bin/ak-profile b/bin/ak-profile
index a595080..02ed5a7 100755
--- a/bin/ak-profile
+++ b/bin/ak-profile
@@ -1,4 +1,22 @@
-#!/bin/bash
+#!/usr/bin/env bash
+###
+### arching-kaos-tools
+### Tools to interact and build an Arching Kaos Infochain
+### Copyright (C) 2021 - 2025 kaotisk
+###
+### This program is free software: you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation, either version 3 of the License, or
+### (at your option) any later version.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program. If not, see <http://www.gnu.org/licenses/>.
+###
##
## Indexes, shows, imports, adds, sets and gets values from and to the
## zchain and files.
@@ -25,11 +43,13 @@ PROGRAM=$(basename $0)
descriptionString="Profile module"
ZPROFILEDIR="$AK_WORKDIR/profile"
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_script
-source $AK_LIBDIR/_ak_ipfs
-source $AK_LIBDIR/_ak_gpg
-source $AK_LIBDIR/_ak_zblock
+source $AK_LIBDIR/_ak_lib_load
+_ak_lib_load _ak_log
+_ak_lib_load _ak_script
+_ak_lib_load _ak_datetime
+_ak_lib_load _ak_ipfs
+_ak_lib_load _ak_gpg
+_ak_lib_load _ak_zblock
# Whatever the command is, we check if $ZPROFILEDIR is there.
# If NOT we create it and we change dir there.
@@ -48,7 +68,7 @@ cd $ZPROFILEDIR
# The profile settings/configuration is part of the blockchain produced.
# Hence, we need a specific DATA block that actually has the announcement of a
# {"key":"value"} pair.
-_ak_modules_profile_show(){
+function _ak_modules_profile_show(){
if [ ! -z $1 ]
then
_ak_log_info "Working with $1"
@@ -61,7 +81,7 @@ _ak_modules_profile_show(){
# This should retrieve a specific value from our profile otherwise it dumps the
# whole profile values.
-_ak_modules_profile_propget(){
+function _ak_modules_profile_propget(){
if [ ! -z $1 ]
then
if [ ! -f $ZPROFILEDIR/$1 ]
@@ -76,7 +96,7 @@ _ak_modules_profile_propget(){
fi
}
-_ak_modules_profile_propwrite(){
+function _ak_modules_profile_propwrite(){
cat > $ZPROPERTY_FILE << EOF
{
"$ZPROPERTY_KEY":"${ZPROPERTY_VALUE}"
@@ -95,7 +115,7 @@ EOF
fi
}
-_ak_modules_profile_propset(){
+function _ak_modules_profile_propset(){
if [ ! -z $1 ]
then
ZPROPERTY_FILE="$ZPROFILEDIR/$1"
@@ -130,7 +150,7 @@ _ak_modules_profile_propset(){
exit 244
fi
}
-_ak_modules_profile_index(){
+function _ak_modules_profile_index(){
FILES="$(ls -1 $ZPROFILEDIR)"
i=0
echo -n "{"
@@ -149,7 +169,7 @@ _ak_modules_profile_index(){
echo "}"
}
-_ak_modules_profile_import(){
+function _ak_modules_profile_import(){
if [ ! -z $1 ]
then
if [ ! -d $1 ]
@@ -172,7 +192,7 @@ _ak_modules_profile_import(){
}
# Adds a file as a profile/add ACTION on the zchain.
-_ak_modules_profile_add(){
+function _ak_modules_profile_add(){
TEMPASSIN="$(_ak_make_temp_directory)"
cd $TEMPASSIN
if [ -f $ZPROFILEDIR/$1 ]; then
@@ -184,7 +204,7 @@ _ak_modules_profile_add(){
FILE_SIGNATURE=$(_ak_ipfs_add $FILE_SIGN_FILE)
cat > data <<EOF
{
- "datetime":"$(date -u +%s)",
+ "datetime":"$(_ak_datetime_unix)",
"ipfs":"$FILE_IPFS_HASH",
"detach":"$FILE_SIGNATURE"
}