gsl-statique-litterateur/usr/local/bin/gsl

176 lines
4.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2022-06-15 17:55:43 +02:00
# Version: 0.0.92
# file: gsl
# Folder: /usr/local/bin
2022-06-14 18:51:19 +02:00
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
2022-06-14 18:51:19 +02:00
#=======================================================================
2022-04-23 17:51:46 +02:00
# Tools
#=======================================================================
2022-03-27 18:46:48 +02:00
if__command() {
! [[ `command -v $1` ]] \
&& echo -e "$I_Red Missing $1 command" \
2022-04-11 18:06:38 +02:00
&& exit
2022-03-27 18:46:48 +02:00
}
2022-06-14 18:51:19 +02:00
if__file() {
if ! [[ -f "$1" ]];then
echo "! Missing file: $1"
2022-04-11 18:06:38 +02:00
exit
fi
case "$2" in
2022-06-14 18:51:19 +02:00
source) source "$1" || exit ;;
read) clear;cat "$1";exit ;;
post) gsl_this_post="$1" ;;
esac
}
2022-06-14 18:51:19 +02:00
if__folder() {
if ! [[ -d "$1" ]];then
echo "! Missing directory: $1"
exit
fi
}
2022-04-23 17:51:46 +02:00
gsl__invalid_option() {
echo "! Invalid argument '$1': $2"
exit
}
2022-04-06 18:28:48 +02:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Source files for help
#======================================================================
source__help() {
for file_help in ${gsl_files_help[@]}
do
if [[ -f "$file_help" ]];then
[[ "$file_help" == "$gsl_dir_help/gsl__help" ]] \
&& source "$file_help"
else
echo "! Installation Failure. Missing file: $file_help"
2022-04-06 18:28:48 +02:00
exit
2022-06-14 18:51:19 +02:00
fi
done
}
2022-04-06 18:28:48 +02:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Helper
# $2: arguments list
#======================================================================
help__OPTIONS() {
clear
case "$1" in
write|-w) cat "$gsl_dir_help/comment_ecrire-article.md" ;;
tpl|-T) cat "$gsl_dir_help/template-comment-creer.md" ;;
install|-i) cat "$gsl_dir_help/comment_installer-GSL.md" ;;
authors|-a) cat "$gsl_dir_help/how_to-add_remove_authors.md" ;;
setdir|-d) cat "$gsl_dir_help/how_to-set_directory_for_articles.md" ;;
param|-p) cat "$gsl_dir_help/how_to-parameters_conf.md" ;;
css) cat "$gsl_dir_help/how_to-CSS_classes.md" ;;
tips|-t) cat "$gsl_dir_help/how_to-Tips_Advises.md" ;;
""|*) cat "$gsl_dir_help/gsl_help.md" ;;
esac
exit
}
2022-04-06 18:28:48 +02:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Get CONF and source variables
#======================================================================
if__file "/etc/gsl/gsl.conf" source
2022-03-27 18:46:48 +02:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check installation and source files
#======================================================================
for dir in ${gsl_dirs[@]}
do
! [[ -d "$dir" ]] \
&& echo "! Installation Failure. Missing directory: $dir" \
&& exit
done
2022-03-27 18:46:48 +02:00
2022-06-14 18:51:19 +02:00
for file_script in ${gsl_files_scripts[@]}
do
if [[ -f "$file_script" ]];then
source "$file_script"
2022-03-27 18:46:48 +02:00
2022-06-14 18:51:19 +02:00
else
echo "! Installation Failure. Missing file: $file_help"
2022-03-27 18:46:48 +02:00
exit
2022-06-14 18:51:19 +02:00
fi
done
2022-03-13 16:20:44 +01:00
2022-06-14 18:51:19 +02:00
for dir_w in ${gsl_dirs_w[@]}
do
if ! [[ -w "$dir_w" ]];then
echo "! Installation Failure. Directory not writeable: $dir_w"
exit
fi
done
2022-02-27 19:16:16 +01:00
#=======================================================================
2022-06-14 18:51:19 +02:00
# Check ARGUMENTS
#=======================================================================
case "$1" in
2022-06-14 18:51:19 +02:00
new|-N) new__OPTIONS "$2" "$3" ;;
author|-A) author__OPTIONS "$2" ;;
log|-L) log__OPTIONS "$@" ;;
-v|-vv|--version) version__OPTIONS "$1" ;;
readme) if__file "$gsl_dir_lib/README.md" read ;;
setdir|-D) setdir__OPTIONS ;;
help|--help|-h) source__help;help__OPTIONS "$2" ;;
esac
2022-06-14 18:51:19 +02:00
# Check if registred DOMAIn and authors from PWD
domain__check
author__check || exit 0 # Check if authors registresd
2022-06-14 18:51:19 +02:00
case "$1" in
db) db__OPTIONS "$2" ;;
sync|-s) sync__OPTIONS "$2" ;;
edit|-E) edit__file_OPTIONS "$2" "$3" ;;
esac
2022-06-14 18:51:19 +02:00
if__gsl_post # from gsl__post_manager: check if .gsl
case "$1" in
check|-C) check__OPTIONS "$@" ;;
make|-M) make__OPTIONS "$@" ;;
sidebar|-S) sidebar__OPTIONS "$2" "$3" "$4" ;;
www) srv__OPTIONS "$1" "$2" "$3" ;;
wip) srv__OPTIONS "$1" "$2" "$3" ;;
2022-06-15 16:15:44 +02:00
stats) stats__datas;exit ;;
2022-06-14 18:51:19 +02:00
*) gsl help; exit ;;
esac
2022-03-27 18:46:48 +02:00
2022-06-14 18:51:19 +02:00
#======================================================================
# After process, show logs
#======================================================================
2022-04-11 18:45:33 +02:00
gsl_logs_last_session=true
2022-06-14 18:51:19 +02:00
[[ $gsl_log_order ]] \
&& gsl__logs_show \
&& exit
gsl_logs_inf=true
2022-04-11 18:45:33 +02:00
gsl__logs_show
if [[ "$gsl_checker_war" ]];then
echo
gsl_logs_war=true
gsl__logs_show
fi
if [[ "$gsl_checker_err" ]];then
2022-04-11 18:45:33 +02:00
echo
gsl_logs_err=true
gsl__logs_show
fi