gsl-statique-litterateur/var/lib/gsl/scripts/gsl__post_manager

131 lines
3.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# file: gsl__post_manager
# Folder: /var/lib/gsl/scripts
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
2022-02-21 17:25:08 +01:00
#-----------------------------------------------------------------------
# -----------------------------------------------------------
# MAIN LOOP. Read from Post list. Do according to Post Status
# -----------------------------------------------------------
#-----------------------------------------------------------------------
gsl__loop_posts() {
2022-02-19 18:17:09 +01:00
gsl__logs_print \
"$gsl_log_i" \
"Found" \
"Posts" \
"$gsl_nbr_posts" \
"${PWD}"
for gsl_post in `ls -1 *.gsl 2>/dev/null`
do
2022-03-01 18:39:46 +01:00
# Check specific asked Post
if [[ "$gsl_this_post" ]];then
! [[ "$gsl_post" == "$gsl_this_post" ]] && continue
fi
2022-03-01 18:39:46 +01:00
gsl__get_sum "$gsl_post"
2022-02-14 02:57:58 +01:00
# Post too small
if (( "$gsl_post_size" <= $gsl_post_min_size ));then
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"Size" \
2022-02-27 19:16:16 +01:00
"$gsl_post - Too small $gsl_post_size <= $gsl_post_min_size" \
2022-02-14 02:57:58 +01:00
"${PWD}/$gsl_post"
continue
fi
2022-03-01 18:39:46 +01:00
# Set DB Post file
gsl_file_db_post="$gsl_dir_db/$gsl_post.db"
gsl__db_get_post_datas
2022-02-21 17:25:08 +01:00
# From COMMAND [OPT]
2022-02-14 02:57:58 +01:00
case "$1" in
check)
if ! [[ "$gsl_force_check" ]];then
2022-03-01 18:39:46 +01:00
gsl__db_compare_post_hash || continue
2022-02-14 02:57:58 +01:00
fi
gsl__logs_print \
2022-02-14 02:57:58 +01:00
"$gsl_log_i" \
"Reading" \
"Post" \
"$gsl_post" \
"${PWD}"
gsl_process="Checked"
2022-02-21 17:25:08 +01:00
gsl__all_checkers
2022-02-14 02:57:58 +01:00
;;
make)
gsl_process="Made"
2022-03-01 18:39:46 +01:00
gsl__db_compare_post_hash && continue
2022-02-17 17:21:35 +01:00
case "$gsl_db_post_status" in
Checked)
2022-02-21 17:25:08 +01:00
gsl__all_makers
2022-02-17 17:21:35 +01:00
;;
Made)
gsl__logs_print
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Converted" \
"$gsl_file_db_posts"
continue
;;
esac
2022-02-14 02:57:58 +01:00
;;
esac
done
2022-03-01 18:39:46 +01:00
# End of checkers : show logs for war and err
2022-02-19 18:17:09 +01:00
[[ "$gsl_checker_war" ]] \
&& gsl log -s -w
[[ "$gsl_checker_err" ]] \
&& gsl log -s -e
[[ "$gsl_check_done" ]] \
&& echo "# Check already done"
}
2022-02-21 17:25:08 +01:00
#-----------------------------------------------------------------------
# --------------------
# Doing some checkings
# --------------------
#-----------------------------------------------------------------------
#=======================================================================
2022-02-21 17:25:08 +01:00
# Check NAME post from [OPT] ; should be from autocompletion
#=======================================================================
2022-02-21 17:25:08 +01:00
gsl__check_opt_post() {
[[ `ls -1 *.gsl | grep "$1"` ]] \
&& gsl_this_post="$1"
}
#=======================================================================
# Check if posts from PWD folder
#=======================================================================
gsl__check_nbr_posts() {
gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l`
! (( $gsl_nbr_posts >= 1 )) \
&& echo "! No Posts found with .gsl extension" \
&& exit 1
}
#======================================================================
# Create TMP file > Get Content Post Only (after #1)
#======================================================================
gsl__post_content_only() {
gsl_tmp_post=`mktemp`
awk -v l="$gsl_post_begin" \
'NR >= l' \
"$gsl_post" \
> "$gsl_tmp_post"
2022-02-15 12:42:54 +01:00
}