Better Domain Configuration

This commit is contained in:
Cyrille L 2022-08-09 17:17:23 +02:00
parent 5308a72f27
commit ba9086d264
7 changed files with 132 additions and 69 deletions

View File

@ -6,6 +6,15 @@ STL: Statique Littérateur
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
## [0.2.2]
### Added
#### Domain Configuration
- More infos at resume
- New simple check for mail and lang
- Answer y is equal to Y...
- Domain values can have " for sidebar title, about, title and copyright
## [0.2.1]
### Added
#### Changeslogs

View File

@ -6,6 +6,15 @@ STL: Statique Littérateur
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
## [0.2.2]
### Added
#### Domain Configuration
- More infos at resume
- New simple check for mail and lang
- Answer y is equal to Y...
- Domain values can have " for sidebar title, about, title and copyright
## [0.2.1]
### Added
#### Changeslogs

View File

@ -1,20 +1,6 @@
# Added
## Changeslogs
- CHANGELOG.md
- last-version.md in help folder (for -v and -u arguments)
## Arguments
- - -v: Show installed version and last changes
- - -u: Check for available update and show last changes
- - -U: like -u, but ask to perform upgrade (except for debian based)
- - --help: like help, -h
- - license: show STL license
## Dependancies
- curl
## Article
- Check article size (must be > 60 to be checked)
## DB
- db (ARTICLE): Inform if article is not in Database yet
## Domain Configuration
- More infos at resume
- New simple check for mail and lang
- Answer y is equal to Y...
- Domain values can have " for sidebar title, about, title and copyright

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Version: 0.2.1
# Version: 0.2.2
# Name: Statique Littérateur
# Type: Executable
# file: stl

View File

@ -6,6 +6,15 @@ STL: Statique Littérateur
- Changelog: https://git.a-lec.org/echolib/stl/-/blob/main/CHANGELOG.md
- License: https://git.a-lec.org/echolib/stl/-/blob/main/LICENSE
## [0.2.2]
### Added
#### Domain Configuration
- More infos at resume
- New simple check for mail and lang
- Answer y is equal to Y...
- Domain values can have " for sidebar title, about, title and copyright
## [0.2.1]
### Added
#### Changeslogs

View File

@ -1,20 +1,6 @@
# Added
## Changeslogs
- CHANGELOG.md
- last-version.md in help folder (for -v and -u arguments)
## Arguments
- - -v: Show installed version and last changes
- - -u: Check for available update and show last changes
- - -U: like -u, but ask to perform upgrade (except for debian based)
- - --help: like help, -h
- - license: show STL license
## Dependancies
- curl
## Article
- Check article size (must be > 60 to be checked)
## DB
- db (ARTICLE): Inform if article is not in Database yet
## Domain Configuration
- More infos at resume
- New simple check for mail and lang
- Answer y is equal to Y...
- Domain values can have " for sidebar title, about, title and copyright

View File

@ -40,17 +40,17 @@ if [[ -f "$stl_file_pwd_conf" ]];then
source "$stl_file_pwd_conf" # Source config PWD file
else
echo "# No domain set from this directory"
echo "# No domain set for this directory: $PWD"
[[ $domain_add ]] && domain__set
[[ $domain_check ]] || exit # exit if domain__get call
fi
# From command line domain
# From command line domain only (check)
if [[ $domain_check ]] && [[ $domain_name ]];then
[[ $domain_edit ]] \
&& nano "$stl_file_pwd_conf"
echo "# Domain set from this directory: $domain_name"
echo "# Domain '$domain_name' set for this directory: $PWD"
exit
fi
}
@ -109,8 +109,8 @@ if__writeable "$PWD"
else
read -rp "- Use 'https://' protocol (N for 'http://') ? " set_prot
case "$set_prot" in
Y) domain_protocol="https://" ;;
N) domain_protocol="http://" ;;
Y|y) domain_protocol="https://" ;;
N|n) domain_protocol="http://" ;;
*) echo "# Maybe later...";exit ;;
esac
domain_ask+="$domain_name"
@ -120,12 +120,16 @@ if__writeable "$PWD"
# ----------
# Processing question to config domain
# ----------
echo -e "\n# You will be asked to confirm after resume"
printf '\n%s\n%s\n\n' \
"# You will be asked to confirm after resume" \
"# Empty anwser or mismatch value cancel process !"
# DOMAIN is set in command line ?
# ----------
case "$domain_name" in
'')
read -rp "- Which domain to set ? " domain_name
read -rp "- Which domain to set (i.e. www.example.com) ? " domain_name
is__set "$domain_name"
is__protocol
;;
@ -136,63 +140,97 @@ case "$domain_name" in
read -rp "$domain_ask (Y|*) ? " domain_confirm
case "$domain_confirm" in
Y) true ;;
*) echo "# Maybe later...";exit ;;
Y|y) true ;;
*) echo "# Maybe later...";exit ;;
esac
;;
esac
# Where is the server ? /var/www ?
# ----------
read -erp "- Where is your server URI ? " srv_uri
is__set "srv_uri"
[[ "${srv_uri: -1}" == "/" ]] \
&& srv_uri=${srv_uri::-1}
! [[ -d "$srv_uri" ]] \
&& echo "! Missing directory" \
&& echo "! Missing directory: $srv_uri" \
&& exit
if__writeable "$srv_uri"
domain_srv="$srv_uri/$domain_name"
# Installation: server or local
read -rp "- STL server installed (Y|N for local ; use wip only) ? " install
# ----------
read -rp "- STL server (Y|N for local = no WWW, WIP only) ? " install
case "$install" in
Y|y) stl_install="server" ;;
N|n) stl_install="local" ;;
*) echo "# Maybe later..." ;;
esac
# Domain TITLE
# ----------
read -rp "- Domain Title ? " domain_title
is__set "$domain_title"
[[ "$domain_title" =~ \" ]] \
&& domain_title=`sed -e 's^"^\\\\"^g' <<<"$domain_title"`
# Domain ABOUT
# ----------
read -rp "- Domain About ? " domain_about
is__set "$domain_about"
[[ "$domain_about" =~ \" ]] \
&& domain_about=`sed -e 's^"^\\\\"^g' <<<"$domain_about"`
# Domain LANG
read -rp "- Domain lang (i.e. fr) ? " domain_lang
# ----------
read -rp "- Domain lang (i.e. fr ; 2 characters) ? " domain_lang
is__set "$domain_lang"
! (( ${#domain_lang} == 2 )) \
&& echo "! Lang must be 2 characters (i.e. fr, gb, en...)" \
&& exit
# Domain MAIL
# ----------
read -rp "- Domain mail ? " domain_mail
is__set "$domain_mail"
! [[ "$domain_mail" =~ @ ]] \
&& echo "! Mail must contain @..." \
&& exit
# Domain TAGS
read -rp "- Domain tags (comma separated) ? " domain_tags
# ----------
read -rp "- Domain MAIN tags (comma separated) ? " domain_tags
is__set "$domain_tags"
# Domain TAGS
read -rp "- Domain copyright ? " domain_cr
# Domain Copyright
# ----------
read -rp "- Domain copyright (i.e. CC BY-NC-SA) ? " domain_cr
is__set "$domain_cr"
[[ "$domain_cr" =~ \" ]] \
&& domain_cr=`sed -e 's^"^\\\\"^g' <<<"$domain_cr"`
# Domain SIDEBAR TITLE
read -rp "- Domain sidebar title ? " domain_sidebar_title
# ----------
read -rp "- Domain sidebar title (i.e. last news) ? " domain_sidebar_title
is__set "$domain_sidebar_title"
# Replace " with \" if exists
[[ "$domain_sidebar_title" =~ \" ]] \
&& domain_sidebar_title=`sed -e 's^"^\\\\"^g' <<<"$domain_sidebar_title"`
# Domain SIDEBAR TITLE
read -rp "- Domain sidebar items (1-24) ? " domain_sidebar_items
# Domain SIDEBAR title NUMBERS
# ----------
read -rp "- Domain sidebar items max number (1-24) ? " domain_sidebar_items
is__set "$domain_sidebar_items"
! [[ $domain_sidebar_items =~ ^[0-9]+$ ]] \
&& echo "! $domain_sidebar_items is not digits between 1-24" \
@ -202,45 +240,63 @@ is__set "$domain_sidebar_items"
&& echo "! $domain_sidebar_items is not between 1-24" \
&& exit
# Domain CSS PREFIX
read -rp "- Domain CSS prefix (alnum,-) ? " domain_css
# ----------
read -rp "- Domain CSS prefix (alpha numeric and -) ? " domain_css
is__set "$domain_css"
! [[ $domain_css =~ ^[a-zA-Z0-9_-]+$ ]] \
&& echo "! '$domain_css' is not alpha numeric. '-' is authorized" \
&& exit
domain_css=${domain_css,,}
case "${domain_css: -1}" in
"_"|"-") domain_css=${domain_css::-1} ;;
esac
domain_css=${domain_css,,}
# Domain LOGO
read -rp "- Domain logo filename ? " domain_logo
# ----------
read -rp "- Domain logo filename (i.e. mylogo.png) ? " domain_logo
# External URL Profile
read -rp "- Domain external URL Profile ? " domain_ext_url
# ----------
read -rp "- Domain external URL Profile (empty if unknown) ? " domain_ext_url
# Statoolinfos
read -rp "- Generate file stats (Statoolinfos) ? " domain_stats
# ----------
read -rp "- Generate file stats for Statoolinfos (Y|N) ? " domain_stats
case "$domain_stats" in
Y|y) domain_stats="yes" ;;
N|n) domain_stats="no" ;;
*) echo "# Maybe later..." ;;
esac
# ----------
# Resume before writing conf
# ------
# ----------
clear
echo -e "# Resume configuration...\n"
cat <<EODOMAINCONF
STL Inslallation : $stl_install
STL stats generator : $domain_stats
Domain Directory : $PWD
Domain Directory : $PWD/
Domain Articles : $PWD/articles/
Domain Generic files : $PWD/articles/files (for PDF, scripts...)
Domain Generic images: $PWD/articles/images (for png, jpg, svg...)
Domain : $domain_name
URL : $domain_protocol$domain_name
Server URI : $domain_srv
Server WIP : $domain_srv/wip/
$(
if [[ $stl_install == "server" ]];then
echo "Server WWW : $domain_srv/www/"
fi
)
Title : $domain_title
About : $domain_about
@ -250,17 +306,25 @@ Tags : $domain_tags
Copyright : $domain_cr
Sidebar Name : $domain_sidebar_title
Sidebar Items : $domain_sidebar_items
CSS prefix : $domain_css
Logo filename : $domain_logo
CSS prefix : $domain_css (configuree your own style.css)
$(
if ! [[ $domain_logo ]];then
echo "Logo filename : To add one, type stl domain edit and put it in $domain_srv/wip/template/"
else
echo "Logo filename : $domain_logo (put it in $domain_srv/wip/template/)"
fi
)
External URL Profile : $domain_ext_url
EODOMAINCONF
echo -e "! Use $domain_name only in $PWD"
read -rp "- Write to $PWD/.stl.conf ? " set_conf
read -rp "- Write to $PWD/.stl.conf (Y|*) ? " set_conf
case "$set_conf" in
Y) true ;;
*) echo "Maybe later...";exit ;;
Y|y) true ;;
*) echo "# Maybe later...";exit ;;
esac