diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index 91b3b9c..28daeb0 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -7,6 +7,8 @@ #======================================================================= # Folders #======================================================================= +app_name="gsl" + # Librairies gsl_dir_lib="/var/lib/gsl" gsl_dir_scripts="$gsl_dir_lib/scripts" @@ -132,3 +134,7 @@ gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| ) # Post-listing 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" diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index 91ad359..a122264 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -1,4 +1,5 @@ #!/bin/bash +# Version: 0.0.2 # file: gsl # Folder: /usr/local/bin # By echolib @@ -7,6 +8,12 @@ #======================================================================= # 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() { if ! [[ -f "$1" ]];then echo "! Missing file: $1" @@ -29,6 +36,9 @@ esac # Get conf gsl__if_file "/etc/gsl/gsl.conf" source +# Help & Logs +gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source + case "$1" in help|--help|-h) clear @@ -48,6 +58,58 @@ case "$1" in esac 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 #======================================================================= @@ -56,9 +118,6 @@ esac # Get Tools 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 @@ -88,8 +147,8 @@ case "$1" in "$gsl_log_i" \ "Starting" \ "Process" \ - "Add Author for domain $gsl_find_domain" \ - "Domain: $gsl_find_domain" + "author $2 for domain $gsl_find_domain" \ + "$gsl_file_auth_ndd" gsl__authors_add @@ -97,16 +156,16 @@ case "$1" in "$gsl_log_i" \ "Stopping" \ "Process" \ - "Add Author for domain $gsl_find_domain" \ - "Domain: $gsl_find_domain" + "author $2 for domain $gsl_find_domain" \ + "$gsl_file_auth_ndd" ;; remove) gsl__logs_print \ "$gsl_log_i" \ "Starting" \ "Process" \ - "Remove Author for domain $gsl_find_domain" \ - "Domain: $gsl_find_domain" + "author $2 for domain $gsl_find_domain" \ + "$gsl_file_auth_ndd" gsl__authors_remove @@ -114,8 +173,8 @@ case "$1" in "$gsl_log_i" \ "Stopping" \ "Process" \ - "Remove Author for domain $gsl_find_domain" \ - "Domain: $gsl_find_domain" + "author $2 for domain $gsl_find_domain" \ + "$gsl_file_auth_ndd" ;; esac ;; @@ -143,40 +202,76 @@ case "$1" in && gsl author add ;; - 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 + edit|-E) + ! [[ "$2" ]] \ + && echo "! Missing argument: post [FILE]" \ + && exit 1 - 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) gsl__check_nbr_posts - gsl_process="chk" case "$2" in -F) gsl_force_check=true @@ -191,8 +286,8 @@ case "$1" in "$gsl_log_i" \ "Starting" \ "Process" \ - "Check Post for domain $gsl_find_domain" \ - "${PWD}" + "check Post for domain $gsl_find_domain" \ + "$PWD" gsl__loop_posts check @@ -200,8 +295,29 @@ case "$1" in "$gsl_log_i" \ "Stopping" \ "Process" \ - "Check Post for domain $gsl_find_domain" \ - "${PWD}" + "check Post for domain $gsl_find_domain" \ + "$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) @@ -222,17 +338,18 @@ case "$1" in "$gsl_log_i" \ "Starting" \ "Process" \ - "Make Post for domain $gsl_find_domain" \ - "${PWD}" + "make Post for domain $gsl_find_domain" \ + "$PWD" + gsl sync wip gsl__loop_posts make gsl__logs_print \ "$gsl_log_i" \ "Stopping" \ "Process" \ - "Make Post for domain $gsl_find_domain" \ - "${PWD}" + "make Post for domain $gsl_find_domain" \ + "$PWD" ;; post-list) @@ -248,20 +365,19 @@ case "$1" in exit 1 ;; esac + + ! [[ "$3" ]] \ + && echo "! Missing argument: post [FILE]" \ + && exit 1 - if [[ "$3" ]];then - gsl__if_file "$3" post - else - echo "! Select a Post to add to list" - exit 1 - fi + gsl__if_file "$3" post gsl__check_nbr_posts gsl__logs_print \ "$gsl_log_i" \ "Starting" \ "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__loop_posts post-list @@ -270,12 +386,76 @@ case "$1" in "$gsl_log_i" \ "Stopping" \ "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" ;; - readme) - clear - gsl__if_file "/var/lib/gsl/README.md" read + www) + ! [[ "$2" ]] \ + && 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 + +gsl log -s +gsl__logs_check diff --git a/var/lib/gsl/helps/gsl_help b/var/lib/gsl/helps/gsl_help index 89602e4..ea2fa0d 100644 --- a/var/lib/gsl/helps/gsl_help +++ b/var/lib/gsl/helps/gsl_help @@ -20,6 +20,14 @@ $ gsl [ARG] add : Add 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] -F : Force check again @@ -31,4 +39,15 @@ $ gsl [ARG] (When converting new post, it will be added) Pin : Set Post from [FILE] to first 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 diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index 72b8f21..d26ac41 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -25,21 +25,19 @@ if [[ -f "$gsl_file_db_post" ]];then "$gsl_file_db_post"` else - -case "$gsl_process" in - chk) - true - ;; - *) - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "Post" \ - "Missing from $gsl_post. Check it first" \ - "$gsl_file_db_post" - gsl_checker_war=true - ;; -esac + # if check process, do not show (useless) + case "$1" in + check) true ;; + *) + gsl__logs_print \ + "$gsl_log_w" \ + "DB" \ + "Post" \ + "Missing for $gsl_post. Check it first" \ + "$gsl_file_db_post" + gsl_checker_war=true + ;; + esac fi } @@ -72,11 +70,11 @@ else ;; *) gsl__logs_print \ - "$gsl_log_w" \ - "Post" \ - "Hash" \ - "$gsl_post Changed ($gsl_post_hash)" \ - "${PWD}/$gsl_post" + "$gsl_log_w" \ + "Post" \ + "Hash" \ + "$gsl_post Changed ($gsl_post_hash)" \ + "${PWD}/$gsl_post" ;; esac @@ -87,37 +85,40 @@ fi # Set Post Status in Database according to proceess #====================================================================== gsl__db_set_post_status() { -case "$gsl_process" in +case "$1" in chk) case "$gsl_db_post_status" in - chk) + ""|chk) [[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash - gsl__db_create_post - ;; - 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 + gsl__db_create_post "$1" ;; esac ;; + wip) case "$gsl_db_post_status" in - chk) - sed -i "2s/.*/Status:$gsl_process/" "$gsl_file_db_post" && \ + chk|www) + sed -i "2s/.*/Status:$1/" "$gsl_file_db_post" && \ gsl__logs_print \ "$gsl_log_w" \ "DB" \ "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_checker_war=true ;; @@ -147,7 +148,7 @@ touch "$gsl_file_db_post" # Main Print printf '%s\n%s\n%s\n' \ "Post:${PWD}/$gsl_post:$gsl_post_hash:$gsl_post_size" \ - "Status:$gsl_process" \ + "Status:$1" \ "`cat "$gsl_db_tmp"`" \ > "$gsl_file_db_post" @@ -174,6 +175,6 @@ gsl__logs_print \ "$gsl_log_w" \ "DB" \ "Create" \ - "Datas from $gsl_post" \ + "Datas from $gsl_post (status: $1)" \ "$gsl_file_db_post" } diff --git a/var/lib/gsl/scripts/gsl__log_manager b/var/lib/gsl/scripts/gsl__log_manager index fdcac20..da0ba4a 100644 --- a/var/lib/gsl/scripts/gsl__log_manager +++ b/var/lib/gsl/scripts/gsl__log_manager @@ -7,6 +7,14 @@ #----------------------------------------------------------------------- # 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() { #1: Level #2: Type @@ -42,7 +50,7 @@ if [[ "$gsl_logs_last_session" ]];then grep -n "Starting" "$gsl_file_logs" \ | tail -1 \ | awk -F: '{print $1}'` - echo + # echo awk -v sl="$gsl_log_start_line" \ 'NR >= sl' \ "$gsl_file_logs" \ diff --git a/var/lib/gsl/scripts/gsl__page_creator b/var/lib/gsl/scripts/gsl__page_creator index bf0639e..a0dfabb 100644 --- a/var/lib/gsl/scripts/gsl__page_creator +++ b/var/lib/gsl/scripts/gsl__page_creator @@ -26,16 +26,16 @@ cat -n "$gsl_srv_wip_page" #====================================================================== gsl__srv_sync() { # Sync Files and Folders -mkdir -p "$gsl_srv_wip" +mkdir -p "$1" for folder in `find $gsl_this_conf_domain/* -type d` do - rsync -a --delete "$folder" "$gsl_srv_wip" && \ + rsync -a --delete "$folder" "$1" && \ gsl__logs_print \ - "$gsl_log_w" \ + "$gsl_log_i" \ "Server" \ "Sync" \ - "$folder in" \ - "$gsl_srv_wip" + "$folder" \ + "$1" done } @@ -45,17 +45,22 @@ done gsl__page_prepare_datas() { # Set wip folder from domain gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" +gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" # Post or Page case "$gsl_post_type" in post) 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=".." ;; page) 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="." ;; esac @@ -71,9 +76,17 @@ if [[ -f "$1" ]];then gsl__logs_print \ "$gsl_log_i" \ "SRV" \ - "Files" \ - "Exists" \ + "$2" \ + "$gsl_post_type $gsl_post exists" \ "$1" +else + gsl__logs_print \ + "$gsl_log_w" \ + "SRV" \ + "$2" \ + "$gsl_post_type $gsl_post not yet created" \ + "$1" + gsl_checker_war=true fi } @@ -253,6 +266,14 @@ cat << EOPAGE > "$gsl_srv_wip_page" 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 rm -f "$gsl_html_meta" } diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index bd35581..af7494f 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -45,9 +45,8 @@ rm -f "$gsl_tmp_post" echo -ne "\r\033[2K" -gsl__db_set_post_status +gsl__db_set_post_status chk rm -f "$gsl_db_tmp" - } #---------------------------------------------------------------------- diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index bf732ec..c0feb9f 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -18,7 +18,6 @@ gsl__all_makers() { gsl_a11y_post=`mktemp` gsl__post_content_only -gsl__srv_sync # Create Listng Page 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 [[ "$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 gsl__page_creator -gsl__db_set_post_status +gsl__db_set_post_status wip rm -f "$gsl_a11y_post" # No more Needed a11y post } diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index 7675eb9..4fdb24c 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -22,7 +22,8 @@ do # Check specific asked Post if [[ "$gsl_this_post" ]];then - ! [[ "$gsl_post" == "$gsl_this_post" ]] && continue + ! [[ "$gsl_post" == "$gsl_this_post" ]] \ + && continue fi gsl__get_sum "$gsl_post" @@ -41,7 +42,7 @@ do # Set DB Post file 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 # From COMMAND [OPT] @@ -64,43 +65,48 @@ do gsl__post_begin gsl__get_needed_headers gsl__page_prepare_datas - # echo "D> $gsl_this_conf_domain/$gsl_find_domain.conf" case "$gsl_db_post_status" in chk) gsl__all_makers ;; - wip) + *) if [[ "$gsl_post_new_hash" ]];then - rm -f "$gsl_srv_wip_page" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "wip" \ - "Delete" \ - "file ; changes in $gsl_post" \ - "$gsl_srv_wip_page" - rm -f "$gsl_file_db_post" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "DB" \ - "Delete" \ - "file ; changes in $gsl_post" \ - "$gsl_file_db_post" + if [[ -f "$gsl_srv_wip_page" ]];then + rm -f "$gsl_srv_wip_page" && \ + gsl__logs_print \ + "$gsl_log_w" \ + "wip" \ + "Delete" \ + "$gsl_post_type ; $gsl_post has changed" \ + "$gsl_srv_wip_page" + fi + if [[ -f "$gsl_file_db_post" ]];then + rm -f "$gsl_file_db_post" && \ + gsl__logs_print \ + "$gsl_log_w" \ + "DB" \ + "Delete" \ + "file ; $gsl_post has changed" \ + "$gsl_file_db_post" + fi else # Should not be used... [[ "$gsl_force_make" ]] \ && gsl__all_makers \ && continue - gsl__logs_print \ - "$gsl_log_w" \ - "Post" \ - "Make" \ - "$gsl_post already Converted" \ - "$gsl_file_db_posts" - gsl_checker_war=true - continue + if [[ -f "$gsl_srv_wip_page" ]];then + gsl__logs_print \ + "$gsl_log_w" \ + "Post" \ + "Make" \ + "$gsl_post already Converted" \ + "$gsl_file_db_posts" + gsl_checker_war=true + continue + fi fi ;; esac @@ -108,7 +114,7 @@ do post-list) case "$gsl_db_post_status" in - wip|online) + wip|www) gsl_process="wip" gsl__post_begin gsl__get_needed_headers @@ -126,15 +132,72 @@ do ;; 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 done - -# End of checkers : show logs for war and err -[[ "$gsl_checker_war" ]] \ - && gsl log -s -w - -[[ "$gsl_checker_err" ]] \ - && gsl log -s -e } #----------------------------------------------------------------------- diff --git a/var/lib/gsl/scripts/gsl__tools b/var/lib/gsl/scripts/gsl__tools index e260a5c..1917268 100644 --- a/var/lib/gsl/scripts/gsl__tools +++ b/var/lib/gsl/scripts/gsl__tools @@ -74,15 +74,15 @@ for gsl_new_dir in `set -o posix ; set \ | grep "gsl_dir_domain" \ | awk -F= '{print $2}'` do - if ! [[ -d "$gsl_new_dir" ]];then - mkdir -p "$gsl_new_dir" 2>/dev/null && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Folder" \ - "Init..." \ - "Created" \ - "$gsl_new_dir" - fi + if ! [[ -d "$gsl_new_dir" ]];then + mkdir -p "$gsl_new_dir" 2>/dev/null && \ + gsl__logs_print \ + "$gsl_log_i" \ + "Folder" \ + "Init..." \ + "Created" \ + "$gsl_new_dir" + fi done gsl__if_file "$gsl_this_conf_domain/$gsl_find_domain.conf" source