2022-02-13 17:58:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Checking Dependancies
|
|
|
|
#=======================================================================
|
|
|
|
# Get Tools
|
|
|
|
! [[ -f "/var/lib/gsl/scripts/gsl__tools" ]] \
|
2022-02-14 00:23:33 +01:00
|
|
|
&& echo "! Missing file: /var/lib/gsl/scripts/gsl__tools" \
|
|
|
|
&& return
|
2022-02-13 17:58:25 +01:00
|
|
|
source "/var/lib/gsl/scripts/gsl__tools"
|
|
|
|
|
|
|
|
# Get conf
|
|
|
|
gsl__check_source "/etc/gsl/gsl.conf" || exit 1
|
|
|
|
|
|
|
|
# Get Logs Manager
|
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__log_manager" || exit 1
|
|
|
|
|
|
|
|
# Check/Create Files and Folders
|
|
|
|
gsl__create_ff
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Main
|
|
|
|
#=======================================================================
|
|
|
|
case "$1" in
|
2022-02-14 00:23:33 +01:00
|
|
|
author|-A)
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__find_domain
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__auth_manager" || exit 1
|
2022-02-16 14:11:41 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
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"
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__authors_add
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
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"
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__authors_remove
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Stopping" \
|
|
|
|
"Process" \
|
|
|
|
"Remove Author for domain $gsl_find_domain" \
|
|
|
|
"Domain: $gsl_find_domain"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
new|-N)
|
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__new_website" || exit 1
|
|
|
|
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"
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
[[ -f "$gsl_file_db_domains" ]] && \
|
|
|
|
[[ -d "$gsl_dir_user_posts" ]] \
|
|
|
|
&& cd "$gsl_dir_user_posts" \
|
|
|
|
&& gsl author add
|
2022-02-14 00:23:33 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
log|-L)
|
2022-02-15 12:42:54 +01:00
|
|
|
[[ -z `grep '[^[:space:]]' "$gsl_file_logs" 2>/dev/null` ]] \
|
2022-02-14 00:23:33 +01:00
|
|
|
&& 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
|
|
|
|
;;
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
-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
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
check|-C)
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__find_domain # || exit 1
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__auth_manager" || exit 1
|
2022-02-15 17:56:45 +01:00
|
|
|
gsl__authors_list check || exit 1
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__post_manager" || exit 1
|
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__post_checkers" || exit 1
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_nbr_posts
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1
|
2022-02-16 14:11:41 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
case "$2" in
|
2022-02-16 16:57:20 +01:00
|
|
|
-F)
|
|
|
|
gsl_force_check=true
|
|
|
|
[[ "$3" ]] && gsl__check_opt_post "$3"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[[ "$2" ]] && gsl__check_opt_post "$2"
|
|
|
|
;;
|
2022-02-14 00:23:33 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Starting" \
|
|
|
|
"Process" \
|
|
|
|
"Check Post for domain $gsl_find_domain" \
|
|
|
|
"${PWD}"
|
|
|
|
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Found" \
|
|
|
|
"Posts" \
|
|
|
|
"$gsl_nbr_posts" \
|
|
|
|
"${PWD}"
|
|
|
|
|
|
|
|
gsl__loop_posts check
|
|
|
|
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Stopping" \
|
|
|
|
"Process" \
|
|
|
|
"Check Post for domain $gsl_find_domain" \
|
|
|
|
"${PWD}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
readme)
|
|
|
|
if [[ -f "/var/lib/gsl/README.md" ]];then
|
2022-02-13 17:58:25 +01:00
|
|
|
clear
|
2022-02-14 00:23:33 +01:00
|
|
|
cat /var/lib/gsl/README.md
|
|
|
|
else
|
|
|
|
echo "! Missing file: /var/lib/gsl/README.md"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
help|--help|-h)
|
|
|
|
gsl__check_file "$gsl_dir_helps/gsl_help" || exit 1
|
|
|
|
|
|
|
|
clear
|
|
|
|
case "$2" in
|
|
|
|
"")
|
|
|
|
cat "$gsl_dir_helps/gsl_help"
|
|
|
|
;;
|
|
|
|
new)
|
|
|
|
gsl__check_file "$gsl_dir_helps/gsl_infos_new_website" || exit 1
|
|
|
|
cat "$gsl_dir_helps/gsl_infos_new_website"
|
|
|
|
;;
|
|
|
|
install)
|
|
|
|
gsl__check_file "$gsl_dir_helps/gsl_help_install" || exit 1
|
|
|
|
cat "$gsl_dir_helps/gsl_help_install"
|
|
|
|
;;
|
2022-02-16 14:11:41 +01:00
|
|
|
write|-w)
|
|
|
|
gsl__check_file "$gsl_dir_helps/gsl_help_write_post" || exit 1
|
|
|
|
cat "$gsl_dir_helps/gsl_help_write_post"
|
|
|
|
;;
|
2022-02-14 00:23:33 +01:00
|
|
|
esac
|
|
|
|
;;
|
2022-02-13 17:58:25 +01:00
|
|
|
esac
|