2022-02-13 17:58:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# file: gsl__new_website
|
|
|
|
# Folder: /var/lib/gsl/scripts
|
|
|
|
# By echolib
|
|
|
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
|
|
|
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
#
|
|
|
|
# Configure new WEBSITE from DOMAIN
|
|
|
|
#
|
|
|
|
#=======================================================================
|
|
|
|
gsl__new_website() {
|
|
|
|
gsl__check_file "$gsl_dir_helps/gsl_infos_new_website" || return
|
|
|
|
|
|
|
|
clear
|
|
|
|
cat $gsl_dir_helps/gsl_infos_new_website
|
|
|
|
printf '\n%s\n%s\n%s\n' \
|
|
|
|
"# Configuration of a new website..." \
|
|
|
|
"# Cancel with empty field" \
|
|
|
|
"# You will be asked to confirm at the end"
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Webserver URI
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
echo -e "\n# Webserver: /var/www (Or maybe elsewhere...)"
|
2022-02-13 17:58:25 +01:00
|
|
|
read -erp \
|
|
|
|
": Webserver URI ? " \
|
|
|
|
gsl_set_server
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
[[ ${gsl_set_server: -1} == "/" ]] \
|
|
|
|
&& gsl_set_server=${gsl_set_server::-1}
|
|
|
|
|
|
|
|
gsl__check_settings $gsl_set_server || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Domain URL
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
printf '\n%s\n %s\n' \
|
|
|
|
"# URL: www.example.com" \
|
2022-02-13 17:58:25 +01:00
|
|
|
"(https:// will be added if missing or force with http://)"
|
|
|
|
read -rp \
|
|
|
|
": Website URL ? " \
|
|
|
|
gsl_set_url
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
[[ ${gsl_set_url: -1} == "/" ]] \
|
|
|
|
&& gsl_set_url=${gsl_set_url::-1}
|
|
|
|
|
|
|
|
gsl__check_settings $gsl_set_url || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
gsl_https='https://'
|
|
|
|
case "$gsl_set_url" in
|
|
|
|
"https://"*)
|
|
|
|
gsl_set_ndd=${gsl_set_url/$gsl_https/}
|
|
|
|
;;
|
|
|
|
"http://"*)
|
|
|
|
gsl_http="http://"
|
|
|
|
gsl_set_ndd=${gsl_set_url/$gsl_http/}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
gsl_set_ndd="$gsl_set_url"
|
|
|
|
gsl_https+=$gsl_set_url
|
|
|
|
gsl_set_url=$gsl_https
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Domain NAME
|
|
|
|
gsl_set_ndd=`awk -F"." '{print $(NF-1)"."$NF}' <<< $gsl_set_ndd`
|
|
|
|
gsl_set_file_ndd="$gsl_set_ndd.conf"
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
[[ -d "$gsl_dir_user_domains/$gsl_set_ndd" ]] \
|
|
|
|
&& gsl_profile="HOME: $gsl_dir_user_domains/$gsl_set_ndd" \
|
|
|
|
&& gsl_set_user_conf="Y"
|
|
|
|
|
|
|
|
[[ -d "$gsl_dir_global_domains/$gsl_set_ndd" ]] \
|
|
|
|
&& gsl_profile="System: $gsl_dir_global_domains/$gsl_set_ndd" \
|
|
|
|
&& gsl_set_user_conf="N"
|
|
|
|
|
|
|
|
if [[ "$gsl_profile" ]];then
|
|
|
|
echo "! A Profile exists in your $gsl_profile"
|
|
|
|
read -rp ": Continue (Y|*)" gsl_continue
|
|
|
|
case "$gsl_continue" in
|
|
|
|
Y|y) true ;;
|
|
|
|
*) gsl__check_settings $blank || return
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2022-02-13 17:58:25 +01:00
|
|
|
#=======================================================================
|
|
|
|
# Personal use or global use ?
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
if ! [[ "$gsl_set_user_conf" ]];then
|
|
|
|
echo -e "\n# Save Domain in Home or Global"
|
|
|
|
read -rp \
|
|
|
|
": Home Use (y/n) ? " \
|
|
|
|
gsl_set_user_conf
|
|
|
|
fi
|
2022-02-13 17:58:25 +01:00
|
|
|
case "$gsl_set_user_conf" in
|
|
|
|
y|Y)
|
|
|
|
gsl_save_dir_ndd="$gsl_dir_user_domains/$gsl_set_ndd"
|
|
|
|
gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd"
|
|
|
|
gsl_ask="# Save to $gsl_save_conf_ndd ? "
|
|
|
|
;;
|
|
|
|
n|N)
|
|
|
|
gsl_save_dir_ndd="$gsl_dir_global_domains/$gsl_set_ndd"
|
|
|
|
gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd"
|
|
|
|
gsl_ask="# Save to $gsl_save_conf_ndd ? "
|
|
|
|
;;
|
|
|
|
*) echo "! Abandon... Maybe next time" && return ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Website Title
|
|
|
|
#=======================================================================
|
|
|
|
echo -e "\n# Title: My Compagny (or My beautiful website)"
|
|
|
|
read -rp \
|
|
|
|
": Website Title ? " \
|
|
|
|
gsl_set_title
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_title || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Website Description
|
|
|
|
#=======================================================================
|
|
|
|
echo -e "\n# Description: writings about this website"
|
|
|
|
read -rp \
|
|
|
|
": Website Description ? " \
|
|
|
|
gsl_set_about
|
2022-02-16 14:11:41 +01:00
|
|
|
|
|
|
|
gsl__check_settings $gsl_set_about || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Contact Mail
|
|
|
|
#=======================================================================
|
|
|
|
echo -e "\n# Mail: contact@example.com"
|
|
|
|
read -rp \
|
|
|
|
": Contact Mail ? " \
|
|
|
|
gsl_set_mail
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_mail || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Website Keywords
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
echo -e "\n# GENERIC pages Keywords: geek stuff,free (comma separated)"
|
2022-02-13 17:58:25 +01:00
|
|
|
read -rp \
|
2022-02-16 14:11:41 +01:00
|
|
|
": Website Keywords for all Pages ? " \
|
2022-02-13 17:58:25 +01:00
|
|
|
gsl_set_keys
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_keys || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Language
|
|
|
|
#=======================================================================
|
|
|
|
echo -e "\n# Language: fr (or en-GB...)"
|
|
|
|
read -rp \
|
|
|
|
": Website Lang ? " \
|
|
|
|
gsl_set_lang
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_lang || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Copyright
|
|
|
|
#=======================================================================
|
|
|
|
echo -e "\n# Copyright: 2022 TITLE CC-BY-SA"
|
|
|
|
read -rp \
|
|
|
|
": Website Copyright ? " \
|
|
|
|
gsl_set_cr
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_cr || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Website Logo
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
printf '\n%s\n %s\n' \
|
2022-02-13 17:58:25 +01:00
|
|
|
"# logo: my-logo.png" \
|
|
|
|
"(Put it in $gsl_save_dir_ndd/templates/)"
|
|
|
|
read -rp \
|
|
|
|
": Website logo file NAME ? " \
|
|
|
|
gsl_set_logo
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_logo || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# CSS Acronym
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
printf '\n%s\n %s\n' \
|
2022-02-13 17:58:25 +01:00
|
|
|
"# CSS (short) Acronym: myweb !No need to end with _" \
|
|
|
|
"(Will create specific classes like myweb_paragraph)"
|
|
|
|
read -rp \
|
|
|
|
": CSS Acronym ? " \
|
|
|
|
gsl_set_css
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_css || return
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Author Reference
|
|
|
|
#=======================================================================
|
2022-02-16 14:11:41 +01:00
|
|
|
printf '\n%s\n %s\n' \
|
|
|
|
"# Author/Compagny URL Profile: https://..." \
|
2022-02-13 17:58:25 +01:00
|
|
|
"(Used for meta rel='me')"
|
|
|
|
read -rp \
|
|
|
|
": Author URL Profile ? " \
|
|
|
|
gsl_set_auth_url
|
|
|
|
|
2022-02-16 14:11:41 +01:00
|
|
|
gsl__check_settings $gsl_set_auth_url || return
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Folder for Posts
|
|
|
|
#=======================================================================
|
|
|
|
printf '\n%s\n %s\n %s\n' \
|
|
|
|
"# You can set here a folder for your writings' Posts"
|
|
|
|
"or manually do it later or add another one later"
|
|
|
|
"Autocompletion /NEWFOLDER (name of choice)"
|
|
|
|
read -erp ": Where will you add your files' Post ? " gsl_dir_user_posts
|
2022-02-13 17:58:25 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Show Resume
|
|
|
|
#=======================================================================
|
|
|
|
clear
|
2022-02-16 14:11:41 +01:00
|
|
|
printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \
|
2022-02-13 17:58:25 +01:00
|
|
|
"# New Website configurations..." \
|
|
|
|
": Webserver|$gsl_set_server" \
|
|
|
|
": URL|$gsl_set_url" \
|
|
|
|
": Domain|$gsl_set_ndd" \
|
|
|
|
": Title|$gsl_set_title" \
|
|
|
|
": Description|$gsl_set_about" \
|
|
|
|
": Contact|$gsl_set_mail" \
|
|
|
|
": Keywords|$gsl_set_keys" \
|
|
|
|
": Language|$gsl_set_lang" \
|
|
|
|
": Copyright|$gsl_set_cr" \
|
|
|
|
": Logo File|$gsl_set_logo" \
|
|
|
|
": CSS Acro|$gsl_set_css" \
|
|
|
|
": Author URL|$gsl_set_auth_url" \
|
2022-02-16 14:11:41 +01:00
|
|
|
": User folder writings' Posts|$gsl_dir_user_posts"
|
2022-02-13 17:58:25 +01:00
|
|
|
| column -t -s'|'
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Ask to Confirm
|
|
|
|
#=======================================================================
|
|
|
|
echo
|
|
|
|
if [[ -d "$gsl_save_dir_ndd" ]];then
|
|
|
|
printf '%s\n%s\n' \
|
|
|
|
"! A profile already exists in $gsl_save_dir_ndd" \
|
|
|
|
"- Remove (A)LL Directories: $gsl_save_dir_ndd" \
|
|
|
|
"- Remove (F)ile configurations : $gsl_save_conf_ndd" \
|
|
|
|
"- Any other key to cancel" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_w" \
|
|
|
|
"Found" \
|
|
|
|
"Profile" \
|
|
|
|
"Configuration from $gsl_set_ndd" \
|
|
|
|
"$gsl_save_conf_ndd"
|
|
|
|
|
|
|
|
read -rp "! Remove (A|F|*) ? " \
|
|
|
|
gsl_ask_remove
|
|
|
|
|
|
|
|
case "$gsl_ask_remove" in
|
|
|
|
A)
|
|
|
|
rm -rf "$gsl_save_dir_ndd" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Remove" \
|
|
|
|
"Folders" \
|
|
|
|
"Configuration from $gsl_set_ndd" \
|
|
|
|
"$gsl_save_dir_ndd"
|
|
|
|
;;
|
|
|
|
F)
|
|
|
|
rm -f "$gsl_save_conf_ndd" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Remove" \
|
|
|
|
"File" \
|
|
|
|
"Configuration from $gsl_set_ndd" \
|
|
|
|
"$gsl_save_conf_ndd"
|
|
|
|
gsl_set_confirm="Y"
|
|
|
|
;;
|
|
|
|
*) echo "# Canceled";return ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
! [[ "$gsl_set_confirm" ]] \
|
|
|
|
&& read -rp "$gsl_ask ?" gsl_set_confirm
|
|
|
|
|
|
|
|
case "$gsl_set_confirm" in
|
2022-02-16 14:11:41 +01:00
|
|
|
y|Y)
|
|
|
|
if ! [[ -d "$gsl_save_dir_ndd" ]];then
|
|
|
|
mkdir -p "$gsl_save_dir_ndd" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Create" \
|
|
|
|
"Folder" \
|
|
|
|
"Configuration from $gsl_set_ndd" \
|
|
|
|
"$gsl_save_dir_ndd/"
|
|
|
|
|
|
|
|
mkdir -p "$gsl_dir_user_posts" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Create" \
|
|
|
|
"Folder" \
|
|
|
|
"User Posts from $gsl_set_ndd" \
|
|
|
|
"$gsl_dir_user_posts/"
|
|
|
|
|
|
|
|
touch "$gsl_dir_user_posts/gsl.$gsl_set_ndd" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Create" \
|
|
|
|
"File" \
|
|
|
|
"gsl.$gsl_set_ndd" \
|
|
|
|
"$gsl_dir_user_posts/"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
gsl__new_website && return
|
|
|
|
;;
|
2022-02-13 17:58:25 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Save config
|
|
|
|
#=======================================================================
|
|
|
|
printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \
|
|
|
|
"gsl_site_server=\"$gsl_set_server\"" \
|
|
|
|
"gsl_site_url=\"$gsl_set_url\"" \
|
|
|
|
"gsl_site_ndd=\"$gsl_set_ndd\"" \
|
|
|
|
"gsl_site_title=\"$gsl_set_title\"" \
|
|
|
|
"gsl_site_about=\"$gsl_set_about\"" \
|
|
|
|
"gsl_site_mail=\"$gsl_set_mail\"" \
|
|
|
|
"gsl_site_keys=\"$gsl_set_keys\"" \
|
|
|
|
"gsl_site_lang=\"$gsl_set_lang\"" \
|
|
|
|
"gsl_site_cr=\"$gsl_set_cr\"" \
|
|
|
|
"gsl_site_logo=\"$gsl_set_logo\"" \
|
|
|
|
"gsl_site_css=\"$gsl_set_css\"" \
|
|
|
|
"gsl_site_auth_url=\"$gsl_set_auth_url\"" \
|
|
|
|
> "$gsl_save_conf_ndd"
|
|
|
|
|
|
|
|
if ! [[ `grep "$gsl_save_dir_ndd" "$gsl_file_db_domains"` ]];then
|
|
|
|
echo "$gsl_save_dir_ndd" >> "$gsl_file_db_domains" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Create" \
|
|
|
|
"File" \
|
|
|
|
"Configuration from $gsl_set_ndd" \
|
|
|
|
"$gsl_file_db_domains"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Check if no Response from $@
|
|
|
|
#=======================================================================
|
|
|
|
gsl__check_settings() {
|
2022-02-16 14:11:41 +01:00
|
|
|
[[ "$@" ]] && return
|
|
|
|
echo "! Abandon... Maybe next time"
|
|
|
|
return
|
2022-02-13 17:58:25 +01:00
|
|
|
}
|