New version : options ; check help

This commit is contained in:
Cyrille L 2022-03-27 18:46:48 +02:00
parent ff2d43a665
commit bf7069ae59
10 changed files with 461 additions and 158 deletions

View File

@ -7,6 +7,8 @@
#======================================================================= #=======================================================================
# Folders # Folders
#======================================================================= #=======================================================================
app_name="gsl"
# Librairies # Librairies
gsl_dir_lib="/var/lib/gsl" gsl_dir_lib="/var/lib/gsl"
gsl_dir_scripts="$gsl_dir_lib/scripts" gsl_dir_scripts="$gsl_dir_lib/scripts"
@ -132,3 +134,7 @@ gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| )
# Post-listing # Post-listing
gsl_list_max_posts=5 gsl_list_max_posts=5
# Onlinde Repo
repo="https://git.a-lec.org/echolib/gsl/-/raw/main/usr/local/bin/gsl"
repo_tar="https://git.a-lec.org/echolib/gsl/-/archive/main/gsl-main.tar.gz"

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# Version: 0.0.2
# file: gsl # file: gsl
# Folder: /usr/local/bin # Folder: /usr/local/bin
# By echolib # By echolib
@ -7,6 +8,12 @@
#======================================================================= #=======================================================================
# Tool: Check needed file and sourcee if asked # Tool: Check needed file and sourcee if asked
#======================================================================= #=======================================================================
if__command() {
! [[ `command -v $1` ]] \
&& echo -e "$I_Red Missing $1 command" \
&& exit 1
}
gsl__if_file() { gsl__if_file() {
if ! [[ -f "$1" ]];then if ! [[ -f "$1" ]];then
echo "! Missing file: $1" echo "! Missing file: $1"
@ -29,6 +36,9 @@ esac
# Get conf # Get conf
gsl__if_file "/etc/gsl/gsl.conf" source gsl__if_file "/etc/gsl/gsl.conf" source
# Help & Logs
gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source
case "$1" in case "$1" in
help|--help|-h) help|--help|-h)
clear clear
@ -48,6 +58,58 @@ case "$1" in
esac esac
exit exit
;; ;;
readme)
clear
gsl__if_file "/var/lib/gsl/README.md" read
exit
;;
log|-L)
[[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \
&& echo "# No logs to show. File is empty." \
&& exit
while test "$2"
do
case "$2" in
clean|-C)
gsl_date_logs=`date +%F-%H-%M-%S`
mv "$gsl_file_logs" "$gsl_dir_logs/$gsl_date_logs.gsl.log"
rm -f "$gsl_file_logs"
printf '%s %s %s\n' \
"# Logs saved to" \
"$gsl_dir_logs/$gsl_date_logs.gsl.log" \
"and cleaned"
exit
;;
-s) gsl_logs_last_session=true ;;
-e) gsl_logs_err=true ;;
-i) gsl_logs_inf=true ;;
-w) gsl_logs_war=true ;;
*) gsl_logs_search="$2" ;;
esac
shift
done
gsl__logs_show
exit
;;
version|-v)
awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/$app_name"
exit
;;
-vv)
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
echo -n "# $app_name Current: $v_cur | "
if__command curl
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
echo -ne "Online: $v_onl\n"
exit
;;
esac esac
#======================================================================= #=======================================================================
@ -56,9 +118,6 @@ esac
# Get Tools # Get Tools
gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source
# Get Logs Manager
gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source
# Check/Create Files and Folders # Check/Create Files and Folders
gsl__create_ff gsl__create_ff
@ -88,8 +147,8 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Add Author for domain $gsl_find_domain" \ "author $2 for domain $gsl_find_domain" \
"Domain: $gsl_find_domain" "$gsl_file_auth_ndd"
gsl__authors_add gsl__authors_add
@ -97,16 +156,16 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Add Author for domain $gsl_find_domain" \ "author $2 for domain $gsl_find_domain" \
"Domain: $gsl_find_domain" "$gsl_file_auth_ndd"
;; ;;
remove) remove)
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Remove Author for domain $gsl_find_domain" \ "author $2 for domain $gsl_find_domain" \
"Domain: $gsl_find_domain" "$gsl_file_auth_ndd"
gsl__authors_remove gsl__authors_remove
@ -114,8 +173,8 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Remove Author for domain $gsl_find_domain" \ "author $2 for domain $gsl_find_domain" \
"Domain: $gsl_find_domain" "$gsl_file_auth_ndd"
;; ;;
esac esac
;; ;;
@ -143,40 +202,76 @@ case "$1" in
&& gsl author add && gsl author add
;; ;;
log|-L) edit|-E)
[[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \ ! [[ "$2" ]] \
&& echo "# No logs to show. File is empty." \ && echo "! Missing argument: post [FILE]" \
&& exit && exit 1
while test "$2"
do
case "$2" in
clean|-C)
gsl_date_logs=`date +%F-%H-%M-%S`
mv "$gsl_file_logs" "$gsl_dir_logs/$gsl_date_logs.gsl.log"
rm -f "$gsl_file_logs"
printf '%s %s %s\n' \
"# Logs saved to" \
"$gsl_dir_logs/$gsl_date_logs.gsl.log" \
"and cleaned"
exit
;;
-s) gsl_logs_last_session=true ;;
-e) gsl_logs_err=true ;;
-i) gsl_logs_inf=true ;;
-w) gsl_logs_war=true ;;
*) gsl_logs_search="$2" ;;
esac
shift
done
gsl__logs_show gsl__if_file "$2" post
if ! [[ "$EDITOR" ]];then
if [[ "$3" ]];then
if__command "$3"
EDITOR="$3"
else
if__command nano
EDITOR=`which nano`
fi
fi
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"edit $gsl_this_post with $EDITOR" \
"$PWD/$gsl_this_post"
gsl__get_sum "$PWD/$gsl_this_post"
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"edit" \
"$gsl_this_post > Hash: $gsl_post_hash | Size: $gsl_post_size" \
"$PWD/$gsl_this_post"
gsl_post_hash_old=$gsl_post_hash
$EDITOR $PWD/$gsl_this_post
gsl__get_sum "$PWD/$gsl_this_post"
if (( $gsl_post_hash != $gsl_post_hash_old ));then
gsl_log_infos="NEW > Hash: $gsl_post_hash | Size: $gsl_post_size"
gsl_log_level="$gsl_log_w"
else
gsl_log_infos="Unchanged"
gsl_log_level="$gsl_log_i"
fi
gsl__logs_print \
"$gsl_log_level" \
"Post" \
"edit" \
"$gsl_this_post > $gsl_log_infos" \
"$PWD/$gsl_this_post"
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"edit $gsl_this_post with $EDITOR" \
"$PWD/$gsl_this_post"
;;
db)
! [[ "$2" ]] \
&& echo "! Missing argument: post [FILE]" \
&& exit 1
gsl__if_file "$2" post
[[ -f "$gsl_dir_db/$gsl_this_post.db" ]] \
&& cat -n "$gsl_dir_db/$gsl_this_post.db" \
|| echo "! No DB yet for $gsl_this_post. Check it first."
exit
;; ;;
check|-C) check|-C)
gsl__check_nbr_posts gsl__check_nbr_posts
gsl_process="chk"
case "$2" in case "$2" in
-F) -F)
gsl_force_check=true gsl_force_check=true
@ -191,8 +286,8 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Check Post for domain $gsl_find_domain" \ "check Post for domain $gsl_find_domain" \
"${PWD}" "$PWD"
gsl__loop_posts check gsl__loop_posts check
@ -200,8 +295,29 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Check Post for domain $gsl_find_domain" \ "check Post for domain $gsl_find_domain" \
"${PWD}" "$PWD"
;;
sync|-s)
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"
gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www"
case "$2" in
"")
gsl__srv_sync "$gsl_srv_wip"
gsl__srv_sync "$gsl_srv_www"
;;
www)
gsl__srv_sync "$gsl_srv_www"
;;
wip)
gsl__srv_sync "$gsl_srv_wip"
;;
*)
echo "! Bad Argument: $2 ? OPT=www/wip/''"
;;
esac
exit
;; ;;
make|-M) make|-M)
@ -222,17 +338,18 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Make Post for domain $gsl_find_domain" \ "make Post for domain $gsl_find_domain" \
"${PWD}" "$PWD"
gsl sync wip
gsl__loop_posts make gsl__loop_posts make
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Make Post for domain $gsl_find_domain" \ "make Post for domain $gsl_find_domain" \
"${PWD}" "$PWD"
;; ;;
post-list) post-list)
@ -248,20 +365,19 @@ case "$1" in
exit 1 exit 1
;; ;;
esac esac
! [[ "$3" ]] \
&& echo "! Missing argument: post [FILE]" \
&& exit 1
if [[ "$3" ]];then gsl__if_file "$3" post
gsl__if_file "$3" post
else
echo "! Select a Post to add to list"
exit 1
fi
gsl__check_nbr_posts gsl__check_nbr_posts
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \ "$1 ; $gsl_post_list $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html" "$gsl_dir_domain_tpl/last-posts-list.html"
gsl__loop_posts post-list gsl__loop_posts post-list
@ -270,12 +386,76 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \ "$1 ; $gsl_post_list $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html" "$gsl_dir_domain_tpl/last-posts-list.html"
;; ;;
readme) www)
clear ! [[ "$2" ]] \
gsl__if_file "/var/lib/gsl/README.md" read && echo "! Missing argument: OPT=add/remove" \
&& exit 1
if__command rsync
gsl_www_act="$2"
case "$2" in
add)
gsl_ask="! Put online ALL wip posts (y|N)? "
;;
remove)
gsl_ask="! REMOVE ALL www posts (yes|N)? "
;;
*)
echo "! Bad argument: $2 ? OPT=add/remove"
exit 1
;;
esac
! [[ "$3" ]] \
&& echo "! Missing argument: post [FILE]/all" \
&& exit 1
case "$3" in
all)
read -rp "$gsl_ask" gsl_ask_www
case "$gsl_ask_www" in
YES|yes|Yes)
true
;;
*)
echo "# Abandon"
exit 1
;;
esac
;;
=)
gsl__if_file "$3" post
;;
esac
gsl__check_nbr_posts
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"$1 ; $2 from domain $gsl_find_domain" \
"$gsl_site_server"
gsl sync www
gsl__loop_posts www "$2"
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"$1 ; $2 from domain $gsl_find_domain" \
"$gsl_site_server"
;;
*)
gsl help
exit
;; ;;
esac esac
gsl log -s
gsl__logs_check

View File

@ -20,6 +20,14 @@ $ gsl [ARG]
add : Add author(s) for DOMAIN add : Add author(s) for DOMAIN
remove : Remove author(s) for DOMAIN remove : Remove author(s) for DOMAIN
edit | -E [FILE] [APP] : Open in default EDITOR [FILE] or with APP
db [FILE] : Show DB statuses from [FILE]
sync [OPT] : Sync Templates to www and wip
wip : Only to wip server
www : Only to www server
check | -C [OPT] [FILE] : Check Posts errors from PWD folder or [FILE] check | -C [OPT] [FILE] : Check Posts errors from PWD folder or [FILE]
-F : Force check again -F : Force check again
@ -31,4 +39,15 @@ $ gsl [ARG]
(When converting new post, it will be added) (When converting new post, it will be added)
Pin : Set Post from [FILE] to first in Last-Posts List Pin : Set Post from [FILE] to first in Last-Posts List
Add : Add Post from [FILE] to last in Last-Posts List Add : Add Post from [FILE] to last in Last-Posts List
www [OPT1] [OPT2] : Add/Remove Post from www server
[OPT1]:
add : Add all/[FILE] to www server
rmove : remove all/[FILE] from www server
[OPT2]:
all : Select all post with wip statuses
[FILE] : Select specific post (if wip status)
version | -v : Show local versionn
-vv : Shown local and repo Versions

View File

@ -25,21 +25,19 @@ if [[ -f "$gsl_file_db_post" ]];then
"$gsl_file_db_post"` "$gsl_file_db_post"`
else else
# if check process, do not show (useless)
case "$gsl_process" in case "$1" in
chk) check) true ;;
true *)
;; gsl__logs_print \
*) "$gsl_log_w" \
gsl__logs_print \ "DB" \
"$gsl_log_w" \ "Post" \
"DB" \ "Missing for $gsl_post. Check it first" \
"Post" \ "$gsl_file_db_post"
"Missing from $gsl_post. Check it first" \ gsl_checker_war=true
"$gsl_file_db_post" ;;
gsl_checker_war=true esac
;;
esac
fi fi
} }
@ -72,11 +70,11 @@ else
;; ;;
*) *)
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
"Hash" \ "Hash" \
"$gsl_post Changed ($gsl_post_hash)" \ "$gsl_post Changed ($gsl_post_hash)" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
;; ;;
esac esac
@ -87,37 +85,40 @@ fi
# Set Post Status in Database according to proceess # Set Post Status in Database according to proceess
#====================================================================== #======================================================================
gsl__db_set_post_status() { gsl__db_set_post_status() {
case "$gsl_process" in case "$1" in
chk) chk)
case "$gsl_db_post_status" in case "$gsl_db_post_status" in
chk) ""|chk)
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash [[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl__db_create_post gsl__db_create_post "$1"
;;
wip)
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl_process="wip"
gsl__db_create_post
;;
www)
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl_process="www"
gsl__db_create_post
;;
""|=)
gsl__db_create_post
;; ;;
esac esac
;; ;;
wip) wip)
case "$gsl_db_post_status" in case "$gsl_db_post_status" in
chk) chk|www)
sed -i "2s/.*/Status:$gsl_process/" "$gsl_file_db_post" && \ sed -i "2s/.*/Status:$1/" "$gsl_file_db_post" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Post" \ "Post" \
"Status:$gsl_process ; $gsl_post" \ "Status:$1 ; $gsl_post" \
"$gsl_file_db_post"
gsl_checker_war=true
;;
esac
;;
www)
case "$gsl_db_post_status" in
wip)
sed -i "2s/.*/Status:$1/" "$gsl_file_db_post" && \
gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Post" \
"Status:$1 ; $gsl_post" \
"$gsl_file_db_post" "$gsl_file_db_post"
gsl_checker_war=true gsl_checker_war=true
;; ;;
@ -147,7 +148,7 @@ touch "$gsl_file_db_post"
# Main Print # Main Print
printf '%s\n%s\n%s\n' \ printf '%s\n%s\n%s\n' \
"Post:${PWD}/$gsl_post:$gsl_post_hash:$gsl_post_size" \ "Post:${PWD}/$gsl_post:$gsl_post_hash:$gsl_post_size" \
"Status:$gsl_process" \ "Status:$1" \
"`cat "$gsl_db_tmp"`" \ "`cat "$gsl_db_tmp"`" \
> "$gsl_file_db_post" > "$gsl_file_db_post"
@ -174,6 +175,6 @@ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Create" \ "Create" \
"Datas from $gsl_post" \ "Datas from $gsl_post (status: $1)" \
"$gsl_file_db_post" "$gsl_file_db_post"
} }

View File

@ -7,6 +7,14 @@
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# Print in log file # Print in log file
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl__logs_check() {
[[ "$gsl_checker_war" ]] \
&& echo && gsl log -s -w
[[ "$gsl_checker_err" ]] \
&& echo && gsl log -s -e
}
gsl__logs_print() { gsl__logs_print() {
#1: Level #1: Level
#2: Type #2: Type
@ -42,7 +50,7 @@ if [[ "$gsl_logs_last_session" ]];then
grep -n "Starting" "$gsl_file_logs" \ grep -n "Starting" "$gsl_file_logs" \
| tail -1 \ | tail -1 \
| awk -F: '{print $1}'` | awk -F: '{print $1}'`
echo # echo
awk -v sl="$gsl_log_start_line" \ awk -v sl="$gsl_log_start_line" \
'NR >= sl' \ 'NR >= sl' \
"$gsl_file_logs" \ "$gsl_file_logs" \

View File

@ -26,16 +26,16 @@ cat -n "$gsl_srv_wip_page"
#====================================================================== #======================================================================
gsl__srv_sync() { gsl__srv_sync() {
# Sync Files and Folders # Sync Files and Folders
mkdir -p "$gsl_srv_wip" mkdir -p "$1"
for folder in `find $gsl_this_conf_domain/* -type d` for folder in `find $gsl_this_conf_domain/* -type d`
do do
rsync -a --delete "$folder" "$gsl_srv_wip" && \ rsync -a --delete "$folder" "$1" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_i" \
"Server" \ "Server" \
"Sync" \ "Sync" \
"$folder in" \ "$folder" \
"$gsl_srv_wip" "$1"
done done
} }
@ -45,17 +45,22 @@ done
gsl__page_prepare_datas() { gsl__page_prepare_datas() {
# Set wip folder from domain # Set wip folder from domain
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"
gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www"
# Post or Page # Post or Page
case "$gsl_post_type" in case "$gsl_post_type" in
post) post)
gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug/index.html" gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug/index.html"
gsl__check_srv_files "$gsl_srv_wip_page" gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug/index.html"
gsl__check_srv_files "$gsl_srv_wip_page" wip
gsl__check_srv_files "$gsl_srv_www_page" www
gsl_uri=".." gsl_uri=".."
;; ;;
page) page)
gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug.html" gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug.html"
gsl__check_srv_files "$gsl_srv_wip_page" gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug.html"
gsl__check_srv_files "$gsl_srv_wip_page" wip
gsl__check_srv_files "$gsl_srv_www_page" www
gsl_uri="." gsl_uri="."
;; ;;
esac esac
@ -71,9 +76,17 @@ if [[ -f "$1" ]];then
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"SRV" \ "SRV" \
"Files" \ "$2" \
"Exists" \ "$gsl_post_type $gsl_post exists" \
"$1" "$1"
else
gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"$2" \
"$gsl_post_type $gsl_post not yet created" \
"$1"
gsl_checker_war=true
fi fi
} }
@ -253,6 +266,14 @@ cat << EOPAGE > "$gsl_srv_wip_page"
</html> </html>
EOPAGE EOPAGE
gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"wip" \
"$gsl_post_type $gsl_post created" \
"$gsl_srv_wip_page"
gsl_checker_war=true
# No more needed html meta file # No more needed html meta file
rm -f "$gsl_html_meta" rm -f "$gsl_html_meta"
} }

View File

@ -45,9 +45,8 @@ rm -f "$gsl_tmp_post"
echo -ne "\r\033[2K" echo -ne "\r\033[2K"
gsl__db_set_post_status gsl__db_set_post_status chk
rm -f "$gsl_db_tmp" rm -f "$gsl_db_tmp"
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -18,7 +18,6 @@ gsl__all_makers() {
gsl_a11y_post=`mktemp` gsl_a11y_post=`mktemp`
gsl__post_content_only gsl__post_content_only
gsl__srv_sync
# Create Listng Page # Create Listng Page
gsl__page_listing_create Add gsl__page_listing_create Add
@ -50,11 +49,18 @@ rm -f "$gsl_tmp_post" # No more Needed tmp file post
# Create SRV folder according to post type # Create SRV folder according to post type
[[ "$gsl_post_type" == "post" ]] \ [[ "$gsl_post_type" == "post" ]] \
&& mkdir -p "$gsl_srv_wip/$gsl_header_slug/" && mkdir -p "$gsl_srv_wip/$gsl_header_slug/" \
&& gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"wip" \
"Create folder: $gsl_header_slug" \
"$gsl_srv_wip/$gsl_header_slug/" \
&& gsl_checker_war=true
# Create HTML Page using gsl_a11y_post # Create HTML Page using gsl_a11y_post
gsl__page_creator gsl__page_creator
gsl__db_set_post_status gsl__db_set_post_status wip
rm -f "$gsl_a11y_post" # No more Needed a11y post rm -f "$gsl_a11y_post" # No more Needed a11y post
} }

View File

@ -22,7 +22,8 @@ do
# Check specific asked Post # Check specific asked Post
if [[ "$gsl_this_post" ]];then if [[ "$gsl_this_post" ]];then
! [[ "$gsl_post" == "$gsl_this_post" ]] && continue ! [[ "$gsl_post" == "$gsl_this_post" ]] \
&& continue
fi fi
gsl__get_sum "$gsl_post" gsl__get_sum "$gsl_post"
@ -41,7 +42,7 @@ do
# Set DB Post file # Set DB Post file
gsl_file_db_post="$gsl_dir_db/$gsl_post.db" gsl_file_db_post="$gsl_dir_db/$gsl_post.db"
gsl__db_get_post_datas gsl__db_get_post_datas "$1"
gsl__db_compare_post_hash gsl__db_compare_post_hash
# From COMMAND [OPT] # From COMMAND [OPT]
@ -64,43 +65,48 @@ do
gsl__post_begin gsl__post_begin
gsl__get_needed_headers gsl__get_needed_headers
gsl__page_prepare_datas gsl__page_prepare_datas
# echo "D> $gsl_this_conf_domain/$gsl_find_domain.conf"
case "$gsl_db_post_status" in case "$gsl_db_post_status" in
chk) chk)
gsl__all_makers gsl__all_makers
;; ;;
wip) *)
if [[ "$gsl_post_new_hash" ]];then if [[ "$gsl_post_new_hash" ]];then
rm -f "$gsl_srv_wip_page" && \ if [[ -f "$gsl_srv_wip_page" ]];then
gsl__logs_print \ rm -f "$gsl_srv_wip_page" && \
"$gsl_log_w" \ gsl__logs_print \
"wip" \ "$gsl_log_w" \
"Delete" \ "wip" \
"file ; changes in $gsl_post" \ "Delete" \
"$gsl_srv_wip_page" "$gsl_post_type ; $gsl_post has changed" \
rm -f "$gsl_file_db_post" && \ "$gsl_srv_wip_page"
gsl__logs_print \ fi
"$gsl_log_w" \ if [[ -f "$gsl_file_db_post" ]];then
"DB" \ rm -f "$gsl_file_db_post" && \
"Delete" \ gsl__logs_print \
"file ; changes in $gsl_post" \ "$gsl_log_w" \
"$gsl_file_db_post" "DB" \
"Delete" \
"file ; $gsl_post has changed" \
"$gsl_file_db_post"
fi
else else
# Should not be used... # Should not be used...
[[ "$gsl_force_make" ]] \ [[ "$gsl_force_make" ]] \
&& gsl__all_makers \ && gsl__all_makers \
&& continue && continue
gsl__logs_print \ if [[ -f "$gsl_srv_wip_page" ]];then
"$gsl_log_w" \ gsl__logs_print \
"Post" \ "$gsl_log_w" \
"Make" \ "Post" \
"$gsl_post already Converted" \ "Make" \
"$gsl_file_db_posts" "$gsl_post already Converted" \
gsl_checker_war=true "$gsl_file_db_posts"
continue gsl_checker_war=true
continue
fi
fi fi
;; ;;
esac esac
@ -108,7 +114,7 @@ do
post-list) post-list)
case "$gsl_db_post_status" in case "$gsl_db_post_status" in
wip|online) wip|www)
gsl_process="wip" gsl_process="wip"
gsl__post_begin gsl__post_begin
gsl__get_needed_headers gsl__get_needed_headers
@ -126,15 +132,72 @@ do
;; ;;
esac esac
;; ;;
www)
gsl__post_begin
gsl__get_needed_headers
gsl__page_prepare_datas
gsl_checker_war=true
case "$2" in
add)
case "$gsl_db_post_status" in
wip)
rsync -a --delete \
"$gsl_srv_wip_page" "$gsl_srv_www_page" && \
gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"www" \
"Synced: $gsl_post_type $gsl_post" \
"$gsl_srv_www_page"
gsl__db_set_post_status www
;;
www)
gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"www" \
"$gsl_post_type $gsl_post already synced" \
"$gsl_srv_www_page"
;;
*)
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"Status" \
"$gsl_db_post_status: $gsl_post not Converted" \
"$gsl_file_db_posts"
gsl_checker_err=true
;;
esac
;;
remove)
case "$gsl_post_type" in
post)
! [[ -d "$gsl_srv_www_page" ]] \
&& return
gsl_rm_c="rm -rf"
;;
page)
! [[ -f "$gsl_srv_www_page" ]] \
&& return
gsl_rm_c="rm -f"
;;
esac
$gsl_rm_c "$gsl_srv_www_page" && \
gsl__logs_print \
"$gsl_log_w" \
"SRV" \
"www" \
"REMOVED $gsl_post_type $gsl_post" \
"$gsl_srv_www_page"
gsl__db_set_post_status wip
;;
esac
;;
esac esac
done done
# End of checkers : show logs for war and err
[[ "$gsl_checker_war" ]] \
&& gsl log -s -w
[[ "$gsl_checker_err" ]] \
&& gsl log -s -e
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------

View File

@ -74,15 +74,15 @@ for gsl_new_dir in `set -o posix ; set \
| grep "gsl_dir_domain" \ | grep "gsl_dir_domain" \
| awk -F= '{print $2}'` | awk -F= '{print $2}'`
do do
if ! [[ -d "$gsl_new_dir" ]];then if ! [[ -d "$gsl_new_dir" ]];then
mkdir -p "$gsl_new_dir" 2>/dev/null && \ mkdir -p "$gsl_new_dir" 2>/dev/null && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Folder" \ "Folder" \
"Init..." \ "Init..." \
"Created" \ "Created" \
"$gsl_new_dir" "$gsl_new_dir"
fi fi
done done
gsl__if_file "$gsl_this_conf_domain/$gsl_find_domain.conf" source gsl__if_file "$gsl_this_conf_domain/$gsl_find_domain.conf" source