Fixes + checkers added

This commit is contained in:
Cyrille L 2022-02-14 02:57:58 +01:00
parent 3918057363
commit a6fe6ee50c
4 changed files with 431 additions and 189 deletions

View File

@ -9,8 +9,8 @@
#======================================================================= #=======================================================================
gsl__db_post_hash() { gsl__db_post_hash() {
gsl_db_post_hash=` gsl_db_post_hash=`
grep "$gsl_post" \ grep "$gsl_post" \
"$gsl_file_db_posts" \ "$gsl_file_db_posts" \
| awk -F"|" '{print $3}'` | awk -F"|" '{print $3}'`
} }
@ -28,38 +28,39 @@ gsl_db_post_status=`awk -F"|" '{print $4}' <<< "$gsl_db_post_exists"`
#======================================================================= #=======================================================================
gsl__db_line_post() { gsl__db_line_post() {
case "$gsl_process" in case "$gsl_process" in
Checked) Checked)
gsl_db_line=` gsl_db_line=`
printf '%s%s%s%s%s\n' \ printf '%s%s%s%s%s\n' \
"$gsl_post_ID 1|" \ "$gsl_post_ID 1|" \
"$gsl_post|" \ "$gsl_post|" \
"$gsl_post_hash|" \ "$gsl_post_hash|" \
"$gsl_post_size|" \ "$gsl_post_size|" \
"$gsl_process|"` "$gsl_process|"`
# case if post exists in DB posts.db ? # case if post exists in DB posts.db ?
gsl__db_post_exists "$gsl_file_db_posts" gsl__db_post_exists "$gsl_file_db_posts"
if [[ "$gsl_db_post_exists" ]];then
sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \ if [[ "$gsl_db_post_exists" ]];then
"$gsl_file_db_posts" && \ sed -i "${gsl_db_post_line_nbr}s/.*/$gsl_db_line/" \
gsl__logs_print \ "$gsl_file_db_posts" && \
"$gsl_log_w" \ gsl__logs_print \
"DB" \ "$gsl_log_w" \
"Post" \ "DB" \
"$gsl_post - Replaced Hash: $gsl_post_hash" \ "Post" \
"$gsl_file_db_posts" "$gsl_post - Replaced Hash: $gsl_post_hash" \
gsl_checker_war=true "$gsl_file_db_posts"
gsl_checker_war=true
else
echo "$gsl_db_line" \ else
>> "$gsl_file_db_posts" && \ echo "$gsl_db_line" \
gsl__logs_print \ >> "$gsl_file_db_posts" && \
"$gsl_log_i" \ gsl__logs_print \
"DB" \ "$gsl_log_i" \
"Post" \ "DB" \
"$gsl_post - New Line. Hash: $gsl_post_hash" \ "Post" \
"$gsl_file_db_posts" "$gsl_post - New Line. Hash: $gsl_post_hash" \
fi "$gsl_file_db_posts"
;; fi
;;
esac esac
} }

View File

@ -11,126 +11,144 @@ gsl__post_all_checkers() {
clear clear
unset gsl_check_done unset gsl_check_done
echo -n ": Searching for Headers..." echo -n ": Searching for needed Headers..."
gsl__post_check_headers gsl__post_check_needed_headers
echo -ne "\r\033[2K: Searching for #1..." echo -ne "\r\033[2K: Searching for #1..."
gsl__post_check_h1 gsl__post_check_h1
echo -ne "\r\033[2K: Searching for Paragraph"
gsl__post_check_paragraphs
echo -ne "\r\033[2K: Searching for Content MARKERS..."
gsl__post_check_markers
echo -ne "\r\033[2K: Searching for BLOCKQUOTE..."
gsl__post_check_blockquote
echo -ne "\r\033[2K: Searching for ABBR..."
gsl__post_check_abbr
echo echo
#echo -ne "\r\033[2K"
# End of checkers : show logs for war and err # End of checkers : show logs for war and err
[[ "$gsl_checker_war" ]] \ [[ "$gsl_checker_war" ]] \
&& gsl log -s -w && gsl log -s -w
[[ "$gsl_checker_err" ]] \ [[ "$gsl_checker_err" ]] \
&& gsl log -s -e && gsl log -s -e
} }
#======================================================================= #=======================================================================
# Check Post for VALID Content HEADERS # Check Post for MISSING & VALID Content HEADERS
#======================================================================= #=======================================================================
gsl__post_check_headers() { gsl__post_check_needed_headers() {
# #-----------------------------------------------------------------------
# Check if Missing NEEDED HEADERS # Check if Missing NEEDED HEADERS
# #-----------------------------------------------------------------------
# Title # Title
gsl_header_title=`gsl__get_header "$gsl_marker_title" "$gsl_post"` gsl_header_title=`gsl__get_header "$gsl_marker_title" "$gsl_post"`
! [[ "$gsl_header_title" ]] \ ! [[ "$gsl_header_title" ]] \
&& gsl__logs_print \ && gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Title" \ "Title" \
"Post" \ "Post" \
"Missing" \ "Missing" \
"${PWD}/$gsl_post" \ "${PWD}/$gsl_post" \
&& gsl_checker_err=true && gsl_checker_err=true
# Slug # Slug
gsl_header_slug=`gsl__get_header "$gsl_marker_slug" "$gsl_post"` gsl_header_slug=`gsl__get_header "$gsl_marker_slug" "$gsl_post"`
! [[ "$gsl_header_slug" ]] \ ! [[ "$gsl_header_slug" ]] \
&& gsl__logs_print \ && gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Slug" \ "Slug" \
"Post" \ "Post" \
"Missing" \ "Missing" \
"${PWD}/$gsl_post" \ "${PWD}/$gsl_post" \
&& gsl_checker_err=true && gsl_checker_err=true \
&& gsl_slug_err=true
# Author # Author
gsl_header_author=`gsl__get_header "$gsl_marker_author" "$gsl_post"` gsl_header_author=`gsl__get_header "$gsl_marker_author" "$gsl_post"`
! [[ "$gsl_header_author" ]] \ ! [[ "$gsl_header_author" ]] \
&& gsl__logs_print \ && gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Author" \ "Author" \
"Post" \ "Post" \
"Missing" \ "Missing" \
"${PWD}/$gsl_post" \ "${PWD}/$gsl_post" \
&& gsl_checker_err=true && gsl_checker_err=true \
&& gsl_author_err=true
# Date # Date
gsl_header_date=`gsl__get_header "$gsl_marker_date" "$gsl_post"` gsl_header_date=`gsl__get_header "$gsl_marker_date" "$gsl_post"`
! [[ "$gsl_header_date" ]] \ ! [[ "$gsl_header_date" ]] \
&& gsl__logs_print \ && gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Date" \ "Date" \
"Post" \ "Post" \
"Missing" \ "Missing" \
"${PWD}/$gsl_post" \ "${PWD}/$gsl_post" \
&& gsl_checker_err=true && gsl_checker_err=true \
&& gsl_date_err=true
# Description # Description
gsl_header_info=`gsl__get_header "$gsl_marker_info" "$gsl_post"` gsl_header_info=`gsl__get_header "$gsl_marker_info" "$gsl_post"`
! [[ "$gsl_header_info" ]] \ ! [[ "$gsl_header_info" ]] \
&& gsl__logs_print \ && gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Infos" \ "Infos" \
"Post" \ "Post" \
"Missing" \ "Missing" \
"${PWD}/$gsl_post" \ "${PWD}/$gsl_post" \
&& gsl_checker_err=true && gsl_checker_err=true
# #-----------------------------------------------------------------------
# Check for VALID Content HEADERS # Check for VALID Content HEADERS
# #-----------------------------------------------------------------------
# Author registred # Author registred
if ! [[ `grep "$gsl_header_author" "$gsl_file_auth_ndd"` ]];then if ! [[ "$gsl_author_err" ]] && \
gsl__logs_print \ ! [[ `grep "$gsl_header_author" "$gsl_file_auth_ndd"` ]];then
gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Author" \ "Author" \
"Post" \ "Post" \
"$gsl_header_author not registred for domain $gsl_find_domain" \ "$gsl_header_author not registred for domain $gsl_find_domain" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_err=true gsl_checker_err=true
fi fi
# Date Format YYYY-MM-DD # Date Format YYYY-MM-DD
if ! [[ "$gsl_header_date" =~ $gsl_test_date ]];then if ! [[ "$gsl_date_err" ]] && \
gsl__logs_print \ ! [[ "$gsl_header_date" =~ $gsl_test_date ]];then
gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Date" \ "Date" \
"Post" \ "Post" \
"$gsl_header_date not YYYY-MM-DD" \ "$gsl_header_date not YYYY-MM-DD" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_err=true gsl_checker_err=true
fi fi
[[ "$gsl_checker_err" ]] && return
# Slug format title-post # Slug format title-post
gsl_header_slug_test=${gsl_header_slug// /-} if ! [[ "$gsl_slug_err" ]];then
if ! [[ "$gsl_header_slug" == "$gsl_header_slug_test" ]];then gsl_header_slug_test=${gsl_header_slug// /-}
gsl_new_header_slug="$gsl_marker_slug$gsl_header_slug_test"
sed -i "s|$gsl_marker_slug$gsl_header_slug|$gsl_new_header_slug" \ if ! [[ "$gsl_header_slug" == "$gsl_header_slug_test" ]];then
"$gsl_post" && \ gsl_new_header_slug="$gsl_marker_slug$gsl_header_slug_test"
gsl__logs_print \ sed -i \
"s|$gsl_marker_slug$gsl_header_slug|$gsl_new_header_slug" \
"$gsl_post" && \
gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Slug" \ "Slug" \
"Post" \ "Post" \
"Changed: $gsl_header_slug_test" \ "Changed: $gsl_header_slug_test" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_war=true
gsl_header_slug=$gsl_header_slug_test
gsl_checker_war=true
fi
fi fi
} }
@ -139,17 +157,206 @@ fi
#======================================================================= #=======================================================================
gsl__post_check_h1() { gsl__post_check_h1() {
gsl_post_begin=` gsl_post_begin=`
grep -n "#1" $gsl_post \ grep -n "#1" $gsl_post \
| head -1 \ | head -1 \
| awk -F: '{print $1}'` | awk -F: '{print $1}'`
if ! [[ "$gsl_post_begin" ]];then if ! [[ "$gsl_post_begin" ]];then
gsl__logs_print \ gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_e" \
"Begin" \ "Begin" \
"Post" \ "Post" \
"Missing content: #1 TITLE" \ "Missing content: #1 TITLE" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_err=true gsl_checker_err=true
fi fi
} }
#=======================================================================
# Check for paragraphs ( and )
#=======================================================================
gsl__post_check_paragraphs() {
gsl_post_p_open_nbr=`
awk -v line="$gsl_post_begin" \
-v op="$gsl_mo_p" \
'NR > line && $1 == op' \
"$gsl_post" \
| wc -l`
gsl_post_p_close_nbr=`
awk -v line="$gsl_post_begin" \
-v cp="$gsl_mc_p" \
'NR > line && $1 == cp' \
"$gsl_post" \
| wc -l`
if (( "$gsl_post_p_open_nbr" == 0 ));then
gsl__logs_print \
"$gsl_log_e" \
"Paragraph" \
"Post" \
"Missing content: ( and ) at begining lines" \
"${PWD}/$gsl_post"
gsl_checker_err=true
gsl_checker_err=true
return
fi
if (( "$gsl_post_p_open_nbr" == "$gsl_post_p_close_nbr" ));then
gsl_post_stat_p="$gsl_post_p_open_nbr"
else
gsl__logs_print \
"$gsl_log_e" \
"Paragraph" \
"Post" \
"Mismatch: (=$gsl_post_p_open_nbr ; )=$gsl_post_p_close_nbr" \
"${PWD}/$gsl_post"
gsl_checker_err=true
return
fi
}
#=======================================================================
# Check and count MARKERS content (Strong, links...)
#=======================================================================
gsl__post_check_markers() {
gsl_markers_nbr=$(( ${#gsl_o_markers[@]} - 1 ))
gsl_post_stat_m=(0 0 0 0 0 0)
while read -r "gsl_post_line"
do
gsl_line_nbr=`awk -F":" '{print $1}' <<< $gsl_post_line`
for gsl_i in `seq 0 $gsl_markers_nbr`
do
if [[ "$gsl_post_line" =~ ${gsl_o_markers[gsl_i]} ]];then
# Open Marker by Type
gsl_o=`
grep -o "${gsl_o_markers[gsl_i]}" \
<<< $gsl_post_line \
| wc -l`
# Close Marker by Type
gsl_c=`
grep -o "${gsl_c_markers[gsl_i]}" \
<<< $gsl_post_line \
| wc -l`
# Strong Vs Bold | 2= **_ / 3= *_ in array
if (( $gsl_i == 2 ));then
gsl_oS=$gsl_o # Open Strong marker nbr
gsl_cS=$gsl_c # Close Strong marker nbr
elif (( $gsl_i == 3 ));then
# Count difference from Strong
if (( $gsl_oS ));then
gsl_o=$(( $gsl_o - $gsl_oS ))
unset gsl_oS
fi
if (( $gsl_cS ));then
gsl_c=$(( $gsl_c - $gsl_cS ))
unset gsl_cS
fi
fi
# Compare
if ! (( $gsl_o == $gsl_c ));then
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"${gsl_i_markers[gsl_i]}" \
"Line $gsl_line_nbr: Mismatch ${gsl_u_markers[gsl_i]}" \
"${PWD}/$gsl_post"
gsl_checker_err=true
else
gsl_post_stat_m[gsl_i]=$(( gsl_post_stat_m[gsl_i] + gsl_o ))
fi
fi
done
done < <(awk -v line="$gsl_post_begin" \
'NR >= line {print NR":",$0}' \
"$gsl_post")
# Show Counts in logs
for gsl_i in `seq 0 $gsl_markers_nbr`
do
if (( ${gsl_post_stat_m[gsl_i]} >= 1 ));then
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"${gsl_i_markers[gsl_i]}" \
"NBR=${gsl_post_stat_m[gsl_i]} > ${gsl_u_markers[gsl_i]}" \
"${PWD}/$gsl_post"
fi
done
}
#=======================================================================
# Check for blockquotes: ---
#=======================================================================
gsl__post_check_blockquote() {
gsl_post_blockquotes_nbr=`
awk -v line="$gsl_post_begin" \
-v bq="$gsl_mark_blockquote" \
'NR > line && $1 == bq' \
"$gsl_post" \
| wc -l`
gsl_post_blockquotes_nbr_r=$(( $gsl_post_blockquotes_nbr % 2 ))
if [[ "$gsl_post_blockquotes_nbr_r" -eq 0 ]];then
gsl_post_stat_bq=$(( $gsl_post_blockquotes_nbr / 2 ))
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Blockquotes" \
"NBR=$gsl_post_stat_bq > $gsl_mark_blockquote (2x)" \
"${PWD}/$gsl_post"
fi
}
#=======================================================================
# Check Post for ABBR HEADER + Content
#=======================================================================
gsl__post_check_abbr() {
while read -r "gsl_header_abbr"
do
gsl_post_abbr_s=`gsl__get_header_field 1 "$gsl_header_abbr"`
gsl_post_abbr_l=`gsl__get_header_field 2 "$gsl_header_abbr"`
gsl_post_line_nbr=`gsl__get_line "$gsl_header_abbr" "$gsl_post"`
if ! [[ "$gsl_post_abbr_s" ]] || \
! [[ "$gsl_post_abbr_l" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"ABBR" \
"Missing Line $gsl_post_line_nbr. $gsl_marker_abbr: Short : Long" \
"${PWD}/$gsl_post"
gsl_checker_err=true
continue
fi
while read -r "gsl_content_line_nbr"
do
gsl_abbr_lines+="$gsl_content_line_nbr,"
done < <(gsl__get_content_line "$gsl_post_abbr_s" "$gsl_post" )
if ! [[ "$gsl_abbr_lines" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"ABBR" \
"Missing content: $gsl_post_abbr_s" \
"${PWD}/$gsl_post"
gsl_checker_err=true
else
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"ABBR" \
"Found: $gsl_post_abbr_s line $gsl_abbr_lines" \
"${PWD}/$gsl_post"
fi
done < <(gsl__get_header "$gsl_marker_abbr" "$gsl_post")
}

View File

@ -9,8 +9,9 @@
#======================================================================= #=======================================================================
gsl__check_nbr_posts() { gsl__check_nbr_posts() {
gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l` gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l`
(( $gsl_nbr_posts == 0 )) \ (( $gsl_nbr_posts == 0 )) \
&& echo "! No Posts found with .gsl extension" && echo "! No Posts found with .gsl extension"
} }
#======================================================================= #=======================================================================
@ -19,54 +20,55 @@ gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l`
gsl__loop_posts() { gsl__loop_posts() {
for gsl_post in `ls -1 *.gsl 2>/dev/null` for gsl_post in `ls -1 *.gsl 2>/dev/null`
do do
# Post too small # Post too small
gsl__post_hash_size gsl__post_hash_size
if (( "$gsl_post_size" <= $gsl_post_min_size ));then if (( "$gsl_post_size" <= $gsl_post_min_size ));then
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"Size" \
"Too small $gsl_post_size <= $gsl_post_min_size" \
"${PWD}/$gsl_post"
continue
fi
case "$1" in
check)
if ! [[ "$gsl_force_check" ]];then
gsl__post_compare_hash || continue
fi
gsl__logs_print \ gsl__logs_print \
"$gsl_log_e" \ "$gsl_log_i" \
"Post" \ "Reading" \
"Size" \ "Post" \
"Too small $gsl_post_size <= $gsl_post_min_size" \ "$gsl_post" \
"${PWD}/$gsl_post" "${PWD}"
gsl__post_all_checkers
# No error: Check/Write to DB (posts.db)
gsl_process="Checked"
gsl__db_line_post
;;
make)
gsl_process="Made"
gsl__db_post_exists "$gsl_file_db_posts"
if [[ "$gsl_db_post_status" == "Made" ]];then
gsl__logs_print
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Made (Converted)" \
"$gsl_file_db_posts"
continue continue
fi fi
;;
case "$1" in esac
check)
gsl__post_compare_hash && continue
gsl__logs_print \
"$gsl_log_i" \
"Reading" \
"Post" \
"$gsl_post" \
"${PWD}"
gsl__post_all_checkers
# No error: Check/Write to DB (posts.db)
if ! [[ "$gsl_checker_err" ]];then
gsl_process="Checked"
gsl__db_line_post
fi
;;
make)
gsl_process="Made"
gsl__db_post_exists "$gsl_file_db_posts"
if [[ "$gsl_db_post_status" == "Made" ]];then
gsl__logs_print
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Made (Converted)" \
"$gsl_file_db_posts"
continue
fi
;;
esac
done done
[[ "$gsl_check_done" ]] \ [[ "$gsl_check_done" ]] \
&& echo "# All posts already checked" && echo "# All posts already checked"
} }
#======================================================================= #=======================================================================
@ -84,21 +86,49 @@ gsl_post_size=`awk '{print $2}' <<< "$gsl_post_csum"`
gsl__post_compare_hash() { gsl__post_compare_hash() {
gsl__db_post_hash gsl__db_post_hash
if [[ "$gsl_db_post_hash" == "$gsl_post_hash" ]];then if [[ "$gsl_db_post_hash" == "$gsl_post_hash" ]];then
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Post" \ "Post" \
"Hash" \ "Hash" \
"$gsl_post already Checked from $gsl_post_hash" \ "$gsl_post already Checked from $gsl_post_hash" \
"$gsl_file_db_posts" "$gsl_file_db_posts"
gsl_check_done=true gsl_check_done=true
return 1
fi fi
} }
#======================================================================= #=======================================================================
# Get everything after the marker. $1: marker | $2: File # Get line nbr from Post... $1: TERM | $2: File
#=======================================================================
gsl__get_line() {
awk -v s="$1" \
'match($0,s) {print NR}' \
"$2"
}
#=======================================================================
# Get everything after the marker... $1: marker | $2: File
#======================================================================= #=======================================================================
gsl__get_header() { gsl__get_header() {
awk -F"$1" -v marker="$1" \ awk -F"$1" -v marker="$1" \
'{if ($0 ~ marker) print $2}' \ '{if ($0 ~ marker) print $2}' \
"$2" 2>/dev/null "$2" 2>/dev/null
}
#=======================================================================
# Get fields from variable... $1: field | $2: variable
#=======================================================================
gsl__get_header_field() {
awk -F" : " -v f="$1" \
'NFS=f {print $NFS}' \
<<< "$2"
}
#=======================================================================
# Get fields from variable... $1: field | $2: variable
#=======================================================================
gsl__get_content_line() {
awk -v line="$gsl_post_begin" -v s="$1" \
'NR >= line && $0 ~ s {print NR}' \
"$2"
} }

View File

@ -21,7 +21,7 @@ fi
#======================================================================= #=======================================================================
gsl__check_file() { gsl__check_file() {
if ! [[ -f "$1" ]];then if ! [[ -f "$1" ]];then
return 1 return
fi fi
} }
@ -33,21 +33,21 @@ gsl__create_ff() {
for gsl_folder in "$gsl_dir_db" \ for gsl_folder in "$gsl_dir_db" \
"$gsl_dir_logs" "$gsl_dir_logs"
do do
if ! [[ -d "$gsl_folder" ]];then if ! [[ -d "$gsl_folder" ]];then
echo ": Creating $gsl_folder and give permissions to $USER" echo ": Creating $gsl_folder and give permissions to $USER"
sudo mkdir -p "$gsl_folder" && \ sudo mkdir -p "$gsl_folder" && \
sudo chown -R $USER:$USER "$gsl_folder" sudo chown -R $USER:$USER "$gsl_folder"
fi fi
done done
# Files # Files
for gsl_file in "$gsl_file_logs" \ for gsl_file in "$gsl_file_logs" \
"$gsl_file_db_posts" \ "$gsl_file_db_posts" \
"$gsl_file_db_stats" \ "$gsl_file_db_stats" \
"$gsl_file_db_domains" "$gsl_file_db_domains"
do do
gsl__check_file "$gsl_file" || \ gsl__check_file "$gsl_file" || \
touch "$gsl_file" touch "$gsl_file"
done done
} }
@ -56,26 +56,29 @@ done
#======================================================================= #=======================================================================
gsl__find_domain() { gsl__find_domain() {
gsl_nbr_domains=` gsl_nbr_domains=`
find . -maxdepth 1 -not -type d -type f -iname "gsl.*.*" 2>/dev/null \ find . -maxdepth 1 -not -type d -type f \
| wc -l` -iname "gsl.*.*" 2>/dev/null \
| wc -l`
if (( $gsl_nbr_domains > 1 ));then if (( $gsl_nbr_domains > 1 ));then
echo "! Too much domains registred here: Set only One per folder" echo "! Too much domains registred here: Set only One per folder"
return return
elif (( $gsl_nbr_domains == 0 ));then elif (( $gsl_nbr_domains == 0 ));then
echo "! No registred domain here: change or set folder. See help new" echo "! No registred domain here: change or set folder. See help new"
return return
fi fi
gsl_find_domain=` gsl_find_domain=`
find . -maxdepth 1 -not -type d -type f -iname "gsl.*.*" 2>/dev/null` find . -maxdepth 1 -not -type d -type f \
-iname "gsl.*.*" 2>/dev/null`
if [[ "$gsl_find_domain" ]];then if [[ "$gsl_find_domain" ]];then
gsl_find_domain=` gsl_find_domain=`
awk -F"." '{print $(NF-1)"."$NF}' \ awk -F"." '{print $(NF-1)"."$NF}' \
<<< $gsl_find_domain` <<< $gsl_find_domain`
gsl_find_domain=${gsl_find_domain,,}
gsl_find_domain=${gsl_find_domain,,}
gsl__check_domain "$gsl_find_domain" gsl__check_domain "$gsl_find_domain"
fi fi
} }
@ -84,6 +87,7 @@ fi
#======================================================================= #=======================================================================
gsl__check_domain() { gsl__check_domain() {
gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"` gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"`
! [[ "$gsl_this_conf_domain" ]] \ ! [[ "$gsl_this_conf_domain" ]] \
&& echo "! Domain Not found: $1" && echo "! Domain Not found: $1"
} }