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,99 +58,11 @@ case "$1" in
esac esac
exit exit
;; ;;
esac
#======================================================================= readme)
# Checking Dependancies clear
#======================================================================= gsl__if_file "/var/lib/gsl/README.md" read
# Get Tools exit
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
gsl__create_ff
gsl__find_domain
gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source
gsl__authors_list check || exit 1
gsl__if_file "$gsl_dir_scripts/gsl__new_website" source
gsl__if_file "$gsl_dir_scripts/gsl__post_checkers" source
gsl__if_file "$gsl_dir_scripts/gsl__post_manager" source
gsl__if_file "$gsl_dir_scripts/gsl__db_manager" source
gsl__if_file "$gsl_dir_scripts/gsl__post_makers" source
gsl__if_file "$gsl_dir_scripts/gsl__page_creator" source
gsl__if_file "$gsl_dir_scripts/gsl__do_commons" source
#=======================================================================
# Main
#=======================================================================
case "$1" in
author|-A)
gsl__authors_list check || exit 1
case "$2" in
"")
gsl__authors_list
;;
add)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"Add Author for domain $gsl_find_domain" \
"Domain: $gsl_find_domain"
gsl__authors_add
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"Add Author for domain $gsl_find_domain" \
"Domain: $gsl_find_domain"
;;
remove)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"Remove Author for domain $gsl_find_domain" \
"Domain: $gsl_find_domain"
gsl__authors_remove
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"Remove Author for domain $gsl_find_domain" \
"Domain: $gsl_find_domain"
;;
esac
;;
new|-N)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"New Website" \
"$gsl_dir_scripts/gsl__new_website"
gsl__new_website
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"New Website" \
"$gsl_dir_scripts/gsl__new_website"
[[ -f "$gsl_file_db_domains" ]] && \
[[ -d "$gsl_dir_user_posts" ]] \
&& cd "$gsl_dir_user_posts" \
&& gsl author add
;; ;;
log|-L) log|-L)
@ -172,11 +94,184 @@ case "$1" in
done done
gsl__logs_show 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
#=======================================================================
# Checking Dependancies
#=======================================================================
# Get Tools
gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source
# Check/Create Files and Folders
gsl__create_ff
gsl__find_domain
gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source
gsl__authors_list check || exit 1
gsl__if_file "$gsl_dir_scripts/gsl__new_website" source
gsl__if_file "$gsl_dir_scripts/gsl__post_checkers" source
gsl__if_file "$gsl_dir_scripts/gsl__post_manager" source
gsl__if_file "$gsl_dir_scripts/gsl__db_manager" source
gsl__if_file "$gsl_dir_scripts/gsl__post_makers" source
gsl__if_file "$gsl_dir_scripts/gsl__page_creator" source
gsl__if_file "$gsl_dir_scripts/gsl__do_commons" source
#=======================================================================
# Main
#=======================================================================
case "$1" in
author|-A)
gsl__authors_list check || exit 1
case "$2" in
"")
gsl__authors_list
;;
add)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"author $2 for domain $gsl_find_domain" \
"$gsl_file_auth_ndd"
gsl__authors_add
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"author $2 for domain $gsl_find_domain" \
"$gsl_file_auth_ndd"
;;
remove)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"author $2 for domain $gsl_find_domain" \
"$gsl_file_auth_ndd"
gsl__authors_remove
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"author $2 for domain $gsl_find_domain" \
"$gsl_file_auth_ndd"
;;
esac
;;
new|-N)
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"New Website" \
"$gsl_dir_scripts/gsl__new_website"
gsl__new_website
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"New Website" \
"$gsl_dir_scripts/gsl__new_website"
[[ -f "$gsl_file_db_domains" ]] && \
[[ -d "$gsl_dir_user_posts" ]] \
&& cd "$gsl_dir_user_posts" \
&& gsl author add
;;
edit|-E)
! [[ "$2" ]] \
&& echo "! Missing argument: post [FILE]" \
&& exit 1
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)
@ -249,19 +366,18 @@ case "$1" in
;; ;;
esac esac
if [[ "$3" ]];then ! [[ "$3" ]] \
&& echo "! Missing argument: post [FILE]" \
&& exit 1
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 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
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
@ -32,3 +40,14 @@ $ gsl [ARG]
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,17 +25,15 @@ 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__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Post" \ "Post" \
"Missing from $gsl_post. Check it first" \ "Missing for $gsl_post. Check it first" \
"$gsl_file_db_post" "$gsl_file_db_post"
gsl_checker_war=true gsl_checker_war=true
;; ;;
@ -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,35 +65,39 @@ 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
if [[ -f "$gsl_srv_wip_page" ]];then
rm -f "$gsl_srv_wip_page" && \ rm -f "$gsl_srv_wip_page" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"wip" \ "wip" \
"Delete" \ "Delete" \
"file ; changes in $gsl_post" \ "$gsl_post_type ; $gsl_post has changed" \
"$gsl_srv_wip_page" "$gsl_srv_wip_page"
fi
if [[ -f "$gsl_file_db_post" ]];then
rm -f "$gsl_file_db_post" && \ rm -f "$gsl_file_db_post" && \
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Delete" \ "Delete" \
"file ; changes in $gsl_post" \ "file ; $gsl_post has changed" \
"$gsl_file_db_post" "$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
if [[ -f "$gsl_srv_wip_page" ]];then
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
@ -102,13 +107,14 @@ do
gsl_checker_war=true gsl_checker_war=true
continue continue
fi fi
fi
;; ;;
esac esac
;; ;;
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
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------