diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-06-14 22:36:12 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-06-14 22:36:12 +0300 |
commit | 4217dc0560bf40b4fa7ae6a6f964bd56b418712e (patch) | |
tree | 020e304e23b29d0eb12199c2f605f1262a3beb04 /modules | |
parent | 7743751290bb4e7678940be65725a48386e7b986 (diff) | |
download | arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.tar.gz arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.tar.bz2 arching-kaos-tools-4217dc0560bf40b4fa7ae6a6f964bd56b418712e.zip |
Refactoring
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/articles/main.sh | 10 | ||||
-rwxr-xr-x | modules/categories/main.sh | 20 | ||||
-rwxr-xr-x | modules/comments/main.sh | 8 | ||||
-rwxr-xr-x | modules/files/main.sh | 36 | ||||
-rwxr-xr-x | modules/folders/main.sh | 18 | ||||
-rwxr-xr-x | modules/news/main.sh | 28 | ||||
-rwxr-xr-x | modules/reference/main.sh | 4 | ||||
-rwxr-xr-x | modules/todos/main.sh | 16 |
8 files changed, 70 insertions, 70 deletions
diff --git a/modules/articles/main.sh b/modules/articles/main.sh index 382466b..29c1c34 100755 --- a/modules/articles/main.sh +++ b/modules/articles/main.sh @@ -22,9 +22,9 @@ TEMP="/tmp/aktmp" if [ ! -d $ZARTICLESDIR ]; then mkdir $ZARTICLESDIR cd $ZARTICLESDIR - logit "INFO" "zarticlesdir created" + _ak_log_info "zarticlesdir created" else - logit "INFO" "zarticlesdir found" + _ak_log_info "zarticlesdir found" fi _ak_modules_articles_create(){ @@ -33,18 +33,18 @@ _ak_modules_articles_create(){ export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)" if [ -z $EDITOR ] then - logit "ERROR" "No $EDITOR found. Exiting..." + _ak_log_error "No $EDITOR found. Exiting..." exit 1 fi $EDITOR $ARTICLES_FILE - logit "INFO" "Renaming..." + _ak_log_info "Renaming..." TITLE="$(head -n 1 $ARTICLES_FILE)" TO_FILE=$ARTICLES_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) IPFS_FILE=$(_ak_ipfs_add $ARTICLES_FILE) mv $ARTICLES_FILE $ZARTICLESDIR/$TO_FILE sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZARTICLESDIR/README _ak_modules_articles_add $ZARTICLESDIR/$TO_FILE - logit "INFO" "Adding to git repo..." + _ak_log_info "Adding to git repo..." cd $ZARTICLESDIR rm -rf $TEMP } diff --git a/modules/categories/main.sh b/modules/categories/main.sh index c0e1e77..82fc669 100755 --- a/modules/categories/main.sh +++ b/modules/categories/main.sh @@ -24,9 +24,9 @@ source $AK_LIBDIR/_ak_zblock if [ ! -d $AK_CATEGORIES ]; then mkdir $AK_CATEGORIES cd $AK_CATEGORIES - logit "INFO" "AK_CATEGORIES created" + _ak_log_info "AK_CATEGORIES created" else - logit "INFO" "AK_CATEGORIES found" + _ak_log_info "AK_CATEGORIES found" fi _ak_modules_categories_create(){ @@ -34,7 +34,7 @@ _ak_modules_categories_create(){ cd $TEMP export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" vi $NEWS_FILE - logit "INFO" "Renaming..." + _ak_log_info "Renaming..." TITLE="$(head -n 1 $NEWS_FILE)" TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) IPFS_FILE=$(_ak_ipfs_add $NEWS_FILE) @@ -61,10 +61,10 @@ _ak_modules_categories_import(){ then if [ ! -d $1 ] then - logit "ERROR" "Folder does not exists" + _ak_log_error "Folder does not exists" exit 4 else - logit "INFO" "Folder $1 exists" + _ak_log_info "Folder $1 exists" fl="$(ls -1 $1)" for f in $fl do @@ -72,7 +72,7 @@ _ak_modules_categories_import(){ done fi else - logit "ERROR" "No value" + _ak_log_error "No value" exit 6 fi exit 224 @@ -82,7 +82,7 @@ _ak_modules_categories_add(){ cd $TEMP if [ -f $1 ]; then FILE="$1" - logit "INFO" "Adding news from " $FILE + _ak_log_info "Adding news from " $FILE DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $FILE) FILE_IPFS_HASH=$(_ak_ipfs_add $FILE) @@ -99,15 +99,15 @@ _ak_modules_categories_add(){ } EOF else - logit "ERROR" "File $FILE doesn't exist"; + _ak_log_error "File $FILE doesn't exist"; exit 2 fi _ak_zblock_pack "news/add" $(pwd)/data if [ $? == 0 ] then - logit "INFO" "News added successfully" + _ak_log_info "News added successfully" else - logit "ERROR" "error??" + _ak_log_error "error??" exit 1 fi } diff --git a/modules/comments/main.sh b/modules/comments/main.sh index 6193e2f..f5ebabc 100755 --- a/modules/comments/main.sh +++ b/modules/comments/main.sh @@ -24,9 +24,9 @@ TEMP="/tmp/aktmp" if [ ! -d $ZCOMMENTSDIR ]; then mkdir $ZCOMMENTSDIR cd $ZCOMMENTSDIR - logit "INFO" "zcommentsdir created" + _ak_log_info "zcommentsdir created" else - logit "INFO" "zcommentsdir found" + _ak_log_info "zcommentsdir found" fi _ak_modules_comments_create(){ @@ -34,7 +34,7 @@ _ak_modules_comments_create(){ then REFER_TO="$1" else - logit "ERROR" "No reference given" + _ak_log_error "No reference given" echo "ERROR" "No reference given" exit 1 fi @@ -47,7 +47,7 @@ _ak_modules_comments_create(){ IPFS_FILE=$(_ak_ipfs_add $COMMENTS_FILE) mv $COMMENTS_FILE $ZCOMMENTSDIR/$TO_FILE _ak_modules_comments_add $TO_FILE - logit "INFO" "Adding to git repo..." + _ak_log_info "Adding to git repo..." cd $ZCOMMENTSDIR if [ ! -z $REFER_TO ] then diff --git a/modules/files/main.sh b/modules/files/main.sh index 73c8219..a3202fe 100755 --- a/modules/files/main.sh +++ b/modules/files/main.sh @@ -19,15 +19,15 @@ if [ ! -d $ZFILESDIR ]; then mkdir $ZFILESDIR if [ $? == 0 ] then - logit "INFO" "Folder $ZFILESDIR created!" + _ak_log_info "Folder $ZFILESDIR created!" else - logit "ERROR" "Failed to create $ZFILESDIR folder" + _ak_log_error "Failed to create $ZFILESDIR folder" exit 1 fi cd $ZFILESDIR git init else - logit "INFO" "$ZFILESDIR found!" + _ak_log_info "$ZFILESDIR found!" fi _ak_modules_files_add(){ @@ -40,47 +40,47 @@ main(){ FILENAME="$1" CRP="$2" echo "Adding $FILENAME" - logit "INFO" "Switching to tmp folder..." + _ak_log_info "Switching to tmp folder..." TEMPASSIN="$(ak-tempassin)" cd $TEMPASSIN if [ $? == 0 ]; then - logit "INFO" "Success" + _ak_log_info "Success" else - logit "ERROR" "Error with tmp folder" + _ak_log_error "Error with tmp folder" exit 5 fi - logit "INFO" "Copying $1 to $TEMPASSIN" + _ak_log_info "Copying $1 to $TEMPASSIN" cp $2/$1 $TEMPASSIN/$1 if [ $? == 0 ]; then - logit "INFO" "Copied successfully" + _ak_log_info "Copied successfully" else - logit "ERROR" "Error copying..." + _ak_log_error "Error copying..." fi FILE="$TEMPASSIN/$1" - logit "INFO" "Adding $FILE to IPFS..." + _ak_log_info "Adding $FILE to IPFS..." FILE_IPFS_HASH=$(_ak_ipfs_add $FILE) if [ $? == 0 ]; then - logit "INFO" "Added $FILE to IPFS" + _ak_log_info "Added $FILE to IPFS" else - logit "ERROR" "Error in adding the $FILE to IPFS" + _ak_log_error "Error in adding the $FILE to IPFS" fi - logit "INFO" "Signing..." + _ak_log_info "Signing..." SIGN_FILE=$FILENAME".asc" _ak_gpg_sign_detached $SIGN_FILE $FILE if [ $? == 0 ]; then - logit "INFO" "Signed" + _ak_log_info "Signed" else - logit "ERROR" "Error while signing" + _ak_log_error "Error while signing" fi - logit "INFO" "Adding signature to IPFS" + _ak_log_info "Adding signature to IPFS" SIGNATURE=$(_ak_ipfs_add $TEMPASSIN/$SIGN_FILE) if [ $? == 0 ]; then - logit "INFO" "Added" + _ak_log_info "Added" else - logit "ERROR" "Error while adding" + _ak_log_error "Error while adding" fi cat > $TEMPASSIN/data <<EOF diff --git a/modules/folders/main.sh b/modules/folders/main.sh index 5aa82c7..f155548 100755 --- a/modules/folders/main.sh +++ b/modules/folders/main.sh @@ -20,9 +20,9 @@ source $AK_LIBDIR/_ak_zblock if [ ! -d $ZFOLDERSDIR ]; then mkdir $ZFOLDERSDIR - logit "ERROR" "error $ZFOLDERSDIR not found or/and could not be created" + _ak_log_error "error $ZFOLDERSDIR not found or/and could not be created" else - logit "INFO" "Found $ZFOLDERSDIR" + _ak_log_info "Found $ZFOLDERSDIR" exit 1 fi TEMPASSIN="$(ak-tempassin)" @@ -40,24 +40,24 @@ _ak_modules_folders_main(){ FOLDERNAME="$1" CRP="$2" echo "Adding $FOLDERNAME" - logit "INFO" "Copying $1 to temporary folder" + _ak_log_info "Copying $1 to temporary folder" cp -r $2/$1 $1 if [ $? == 0 ]; then - logit "INFO" "Copied successfully" + _ak_log_info "Copied successfully" else - logit "ERROR" "Error copying..." + _ak_log_error "Error copying..." fi FOLDER="$1" - logit "INFO" "Adding $FOLDER to IPFS..." + _ak_log_info "Adding $FOLDER to IPFS..." FOLDER_IPFS_HASH=$(_ak_ipfs_add $FOLDER) if [ $? == 0 ]; then - logit "INFO" "done" + _ak_log_info "done" else - logit "ERROR" "error" + _ak_log_error "error" fi - logit "WARNING" "Folders are not signing..." + _ak_log_warning "Folders are not signing..." printf '{"timestamp":"%s","foldername":"%s","ipfs":"%s"}' $(date -u +%s) $FOLDERNAME $FOLDER_IPFS_HASH diff --git a/modules/news/main.sh b/modules/news/main.sh index b015bd6..1a0b5e0 100755 --- a/modules/news/main.sh +++ b/modules/news/main.sh @@ -37,12 +37,12 @@ source $AK_LIBDIR/_ak_zchain if [ ! -d $ZNEWSDIR ]; then mkdir $ZNEWSDIR if [ $? -ne 0 ]; then - logit "ERROR" "$ZNEWSDIR couldn't be created" + _ak_log_error "$ZNEWSDIR couldn't be created" exit 1 fi - logit "INFO" "$ZNEWSDIR created" + _ak_log_info "$ZNEWSDIR created" else - logit "INFO" "$ZNEWSDIR found" + _ak_log_info "$ZNEWSDIR found" fi cd $ZNEWSDIR @@ -120,7 +120,7 @@ _ak_modules_news_add_from_file(){ cp $FILE $TEMP FILE="$(basename $1)" cd $TEMP - logit "INFO" "Adding news from " $FILE + _ak_log_info "Adding news from " $FILE DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $FILE) FILE_IPFS_HASH=$(_ak_ipfs_add $FILE) @@ -137,15 +137,15 @@ _ak_modules_news_add_from_file(){ } EOF else - logit "ERROR" "File $FILE doesn't exist"; + _ak_log_error "File $FILE doesn't exist"; exit 2 fi _ak_zblock_pack "news/add" $(pwd)/data if [ $? == 0 ] then - logit "INFO" "News added successfully" + _ak_log_info "News added successfully" else - logit "ERROR" "Failed to pack zblock" + _ak_log_error "Failed to pack zblock" exit 1 fi rm -rf $TEMP @@ -156,7 +156,7 @@ _ak_modules_news_add(){ cd $TEMP if [ -f $ZNEWSDIR/$1 ]; then FILE="$1" - logit "INFO" "Adding news from " $FILE + _ak_log_info "Adding news from " $FILE DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $ZNEWSDIR/$FILE) FILE_IPFS_HASH=$(_ak_ipfs_add $ZNEWSDIR/$FILE) @@ -173,15 +173,15 @@ _ak_modules_news_add(){ } EOF else - logit "ERROR" "File $1 doesn't exist"; + _ak_log_error "File $1 doesn't exist"; exit 2 fi _ak_zblock_pack "news/add" $(pwd)/data if [ $? == 0 ] then - logit "INFO" "News added successfully" + _ak_log_info "News added successfully" else - logit "ERROR" "error??" + _ak_log_error "error??" exit 1 fi } @@ -203,7 +203,7 @@ _ak_modules_news_read(){ _ak_ipfs_cat $linkToText else - logit "ERROR" "Not a news block." + _ak_log_error "Not a news block." echo "ERROR Not a news block." exit 1 fi @@ -214,7 +214,7 @@ _ak_modules_news_html(){ ak-enter -l 1 $1 > temp if [ $? -ne 0 ] then - logit "ERROR" "Failed to retrieve zblock $1" + _ak_log_error "Failed to retrieve zblock $1" exit 22 fi module="`cat temp | jq -r '.[].module'`" @@ -281,7 +281,7 @@ _ak_modules_news_html(){ echo " </tr>" echo '</table>' else - logit "ERROR" "Not a news block." + _ak_log_error "Not a news block." exit 1 fi rm temp diff --git a/modules/reference/main.sh b/modules/reference/main.sh index 157b797..e6c06d3 100755 --- a/modules/reference/main.sh +++ b/modules/reference/main.sh @@ -24,9 +24,9 @@ source $AK_LIBDIR/_ak_zblock if [ ! -d $ZREFERENCESDIR ]; then mkdir $ZREFERENCESDIR cd $ZREFERENCESDIR - logit "INFO" "zreferencesdir created" + _ak_log_info "zreferencesdir created" else - logit "INFO" "zreferencesdir found" + _ak_log_info "zreferencesdir found" fi _ak_modules_reference_create(){ diff --git a/modules/todos/main.sh b/modules/todos/main.sh index afe56f8..299bcb0 100755 --- a/modules/todos/main.sh +++ b/modules/todos/main.sh @@ -30,9 +30,9 @@ TEMP="/tmp/aktmp" if [ ! -d $ZTODOSDIR ]; then mkdir $ZTODOSDIR cd $ZTODOSDIR - logit "INFO" "ztodosdir created along with git repo" + _ak_log_info "ztodosdir created along with git repo" else - logit "INFO" "ztodosdir found" + _ak_log_info "ztodosdir found" fi _ak_modules_todos_create(){ @@ -40,13 +40,13 @@ _ak_modules_todos_create(){ cd $TEMP export TODOS_FILE="$(date -u +%s)" vi $TODOS_FILE - logit "INFO" "Renaming..." + _ak_log_info "Renaming..." TITLE="$(head -n 1 $TODOS_FILE)" TO_FILE=$TODOS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) IPFS_FILE=$(_ak_ipfs_add $TODOS_FILE) mv $TODOS_FILE $ZTODOSDIR/$TO_FILE _ak_modules_todos_add $ZTODOSDIR/$TO_FILE - logit "INFO" "Adding to git repo..." + _ak_log_info "Adding to git repo..." cd $ZTODOSDIR # rm -rf $TEMP } @@ -91,7 +91,7 @@ _ak_modules_todos_add(){ cd $TEMP if [ -f $1 ]; then FILE="$1" - logit "INFO" "Adding todos from $FILE" + _ak_log_info "Adding todos from $FILE" DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $FILE) FILE_IPFS_HASH=$(_ak_ipfs_add $FILE) @@ -108,15 +108,15 @@ _ak_modules_todos_add(){ } EOF else - logit "ERROR" "File $FILE doesn't exist"; + _ak_log_error "File $FILE doesn't exist"; exit 2 fi _ak_zblock_pack "todos/add" $(pwd)/data if [ $? == 0 ] then - logit "INFO" "Todos added successfully" + _ak_log_info "Todos added successfully" else - logit "ERROR" "error?? _ak_zblock_pack failed" + _ak_log_error "error?? _ak_zblock_pack failed" exit 1 fi } |