2022-02-13 17:58:25 +01:00
|
|
|
#!/bin/bash
|
2022-03-08 17:53:40 +01:00
|
|
|
# file: gsl
|
|
|
|
# Folder: /usr/local/bin
|
|
|
|
# By echolib
|
|
|
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Tool: Check needed file and sourcee if asked
|
|
|
|
#=======================================================================
|
|
|
|
gsl__if_file() {
|
|
|
|
if ! [[ -f "$1" ]];then
|
|
|
|
echo "! Missing file: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$2" in
|
|
|
|
source)
|
|
|
|
source "$1" || exit 1
|
|
|
|
;;
|
|
|
|
read)
|
|
|
|
cat "$1"
|
|
|
|
;;
|
|
|
|
post)
|
|
|
|
gsl_this_post="$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-03-13 16:20:44 +01:00
|
|
|
# Get conf
|
|
|
|
gsl__if_file "/etc/gsl/gsl.conf" source
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
help|--help|-h)
|
|
|
|
clear
|
|
|
|
case "$2" in
|
|
|
|
"")
|
|
|
|
gsl__if_file "$gsl_dir_helps/gsl_help" read
|
|
|
|
;;
|
|
|
|
new)
|
|
|
|
gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" read
|
|
|
|
;;
|
|
|
|
install)
|
|
|
|
gsl__if_file "$gsl_dir_helps/gsl_help_install" read
|
|
|
|
;;
|
|
|
|
write|-w)
|
|
|
|
gsl__if_file "$gsl_dir_helps/gsl_help_write_post" read
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-02-13 17:58:25 +01:00
|
|
|
#=======================================================================
|
|
|
|
# Checking Dependancies
|
|
|
|
#=======================================================================
|
|
|
|
# Get Tools
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
# Get Logs Manager
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
# Check/Create Files and Folders
|
|
|
|
gsl__create_ff
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__find_domain
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__authors_list check || exit 1
|
2022-03-08 17:53:40 +01:00
|
|
|
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
|
2022-02-27 19:16:16 +01:00
|
|
|
|
2022-02-13 17:58:25 +01:00
|
|
|
#=======================================================================
|
|
|
|
# Main
|
|
|
|
#=======================================================================
|
|
|
|
case "$1" in
|
2022-02-14 00:23:33 +01:00
|
|
|
author|-A)
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__authors_list check || exit 1
|
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
|
|
|
|
;;
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
new|-N)
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Starting" \
|
|
|
|
"Process" \
|
|
|
|
"New Website" \
|
|
|
|
"$gsl_dir_scripts/gsl__new_website"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__new_website
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
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
|
|
|
;;
|
2022-02-19 18:17:09 +01:00
|
|
|
|
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
|
2022-03-08 17:53:40 +01:00
|
|
|
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
|
2022-02-14 00:23:33 +01:00
|
|
|
done
|
2022-02-13 17:58:25 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_show
|
|
|
|
;;
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
check|-C)
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_nbr_posts
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl_process="chk"
|
2022-02-14 00:23:33 +01:00
|
|
|
case "$2" in
|
2022-02-16 16:57:20 +01:00
|
|
|
-F)
|
|
|
|
gsl_force_check=true
|
2022-03-08 17:53:40 +01:00
|
|
|
[[ "$3" ]] && gsl__if_file "$3" post
|
2022-02-16 16:57:20 +01:00
|
|
|
;;
|
|
|
|
*)
|
2022-03-08 17:53:40 +01:00
|
|
|
[[ "$2" ]] && gsl__if_file "$2" post
|
2022-02-16 16:57:20 +01:00
|
|
|
;;
|
2022-02-14 00:23:33 +01:00
|
|
|
esac
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Starting" \
|
|
|
|
"Process" \
|
|
|
|
"Check Post for domain $gsl_find_domain" \
|
|
|
|
"${PWD}"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
gsl__loop_posts check
|
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
2022-02-19 18:17:09 +01:00
|
|
|
"Stopping" \
|
|
|
|
"Process" \
|
|
|
|
"Check Post for domain $gsl_find_domain" \
|
2022-02-14 00:23:33 +01:00
|
|
|
"${PWD}"
|
2022-02-19 18:17:09 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
make|-M)
|
|
|
|
gsl__check_nbr_posts
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl_process="wip"
|
|
|
|
gsl_post_list="Add"
|
2022-03-02 17:25:23 +01:00
|
|
|
case "$2" in
|
|
|
|
-F)
|
|
|
|
gsl_force_make=true
|
2022-03-08 17:53:40 +01:00
|
|
|
[[ "$3" ]] && gsl__if_file "$3" post
|
2022-03-02 17:25:23 +01:00
|
|
|
;;
|
|
|
|
*)
|
2022-03-08 17:53:40 +01:00
|
|
|
[[ "$2" ]] && gsl__if_file "$2" post
|
2022-03-02 17:25:23 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Starting" \
|
|
|
|
"Process" \
|
|
|
|
"Make Post for domain $gsl_find_domain" \
|
|
|
|
"${PWD}"
|
|
|
|
|
|
|
|
gsl__loop_posts make
|
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Stopping" \
|
|
|
|
"Process" \
|
2022-02-19 18:17:09 +01:00
|
|
|
"Make Post for domain $gsl_find_domain" \
|
2022-02-14 00:23:33 +01:00
|
|
|
"${PWD}"
|
|
|
|
;;
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-03-06 15:57:20 +01:00
|
|
|
post-list)
|
2022-03-08 17:53:40 +01:00
|
|
|
case "$2" in
|
|
|
|
add)
|
|
|
|
gsl_post_list="Add"
|
|
|
|
;;
|
|
|
|
pin)
|
|
|
|
gsl_post_list="Pin"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "! Bad Argument: $2"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [[ "$3" ]];then
|
|
|
|
gsl__if_file "$3" post
|
2022-03-06 15:57:20 +01:00
|
|
|
else
|
|
|
|
echo "! Select a Post to add to list"
|
2022-03-08 17:53:40 +01:00
|
|
|
exit 1
|
2022-03-06 15:57:20 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
gsl__check_nbr_posts
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Starting" \
|
|
|
|
"Process" \
|
2022-03-08 17:53:40 +01:00
|
|
|
"Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \
|
2022-03-06 15:57:20 +01:00
|
|
|
"$gsl_dir_domain_tpl/last-posts-list.html"
|
|
|
|
|
|
|
|
gsl__loop_posts post-list
|
|
|
|
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Stopping" \
|
|
|
|
"Process" \
|
2022-03-08 17:53:40 +01:00
|
|
|
"Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \
|
2022-03-06 15:57:20 +01:00
|
|
|
"$gsl_dir_domain_tpl/last-posts-list.html"
|
|
|
|
;;
|
|
|
|
|
2022-02-14 00:23:33 +01:00
|
|
|
readme)
|
2022-03-06 16:28:29 +01:00
|
|
|
clear
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__if_file "/var/lib/gsl/README.md" read
|
2022-02-14 00:23:33 +01:00
|
|
|
;;
|
2022-02-13 17:58:25 +01:00
|
|
|
esac
|