Files
VPS-scripts_Web-V2/installer.sh
Bram Prieshof be8d75bcab Replaced references php With vars
Done because differences between distros is quite big,
and this was the beter solution then using alot of if statements

List of changes:
* Replaced service names php"$phpver"-fpm with $phpFPMService
* Replaced PHPver in package list with phpPkgName
* Replaced full php config path with $phpMainConf
* Replaced php pool path with $phpPoolDir
2020-12-03 17:10:47 +01:00

703 lines
24 KiB
Bash

#!/bin/bash
##--------------------##
# Legacy/Main Menu #
##--------------------##
sed -i -e 's/magenta/blue/g' /etc/newt/palette
if [ "$1" != "-l" ]; then
APTMODE="debconf-apt-progress -- apt"
OUTPUT='/dev/null'
IMODE=n
fi
if [ "$1" = "-l" ]; then
APTMODE="apt"
OUTPUT='/dev/tty'
IMODE=l
fi
##---------------##
# Static-Vars #
##---------------##
#Git-repo
repo=https://git.ictmaatwerk.com/VPS-scripts/Web-V2
branch=Centos-Testing
branchtype=branch #=branch for branch and =tag for release
#Installer-config
phpver=7.4
PHPMyadmin=1 #Overwriten by cms's without php
sqlver=8.0
TestMode=0
#PackageManager-config
dist_ver=$(grep --color=never -Po "^VERSION_ID=\K.*" "/etc/os-release")
dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release")
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
PKGM="$APTMODE"
PKGI="${PKGM} install -y --no-install-recommends"
PKGLIST="apt"
shortdist=ubu1804
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
PKGM="$APTMODE"
PKGI="${PKGM} install -y --no-install-recommends"
PKGLIST="apt"
shortdist=ubu2004
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
PKGM="$APTMODE"
PKGI="${PKGM} install -y --no-install-recommends"
PKGLIST="apt"
shortdist=deb10
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
PKGM="dnf"
PKGI="${PKGM} install --setopt=install_weak_deps=False --best -y"
PKGLIST="dnf"
shortdist=cent8
echo "The support for this os is being worked on"
else
echo "This os in not supported"
exit
fi
unset dist_ver dist APTMODE
##-------------##
# Test-Vars #
##-------------##
syscheckoff=0
if [ $TestMode = 1 ]; then
domain=ict-dagbesteding.nl
sitename=ict_DB_nl
email=b.prieshof@ictmaatwerk.com
password=MeiFerrieSekureTESTp@ssw0rd4213
hostname=vdh001.nxdi.nl
sslenable=0
domainwww=0
fi
##---------------------##
# Always-on modules #
##---------------------##
aonoption="/MySQL/"
aonoption="$aonoption /Unattended-Security-Updates/"
aonoption="$aonoption /Backup-Util/"
aonoption="$aonoption /AcmeSH/"
##---------------##
# Functions #
##---------------##
msg () {
if [ $IMODE = n ]; then
TERM=ansi whiptail --title "Info" --infobox "$1" 8 52
fi
if [ $IMODE = l ]; then
echo "$1"
fi
}
function PasswordQuest {
passdiaone=$(whiptail --nocancel --passwordbox "Please enter your password (Requires 8 chars, uper & lower case, special and numerical)" 11 91 --title "Config" 3>&1 1>&2 2>&3)
if [ -z $passdiaone ]; then PasswordQuest; fi
if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
PasswordCheck
else
whiptail --ok-button Done --msgbox " Password is invalid!" 10 30
unset passdiaone
PasswordQuest
fi
}
function PasswordCheck {
#Checking password
passdiatwo=$(whiptail --nocancel --passwordbox " Please re-enter your password" 11 82 --title "Config" 3>&1 1>&2 2>&3)
if [ -z $passdiatwo ]; then
PasswordCheck
else
if [ $passdiaone != $passdiatwo ]; then
whiptail --ok-button Done --msgbox " Password does not match!" 10 30
PasswordQuest
else
password="$passdiaone"
unset passdiaone passdiatwo
fi
fi
}
function LegacyPasswordQuest {
echo "Enter password (Requires: 8 chars, 1 capital and 1 num)"
read -s passdiaone
if [ -z $passdiaone ]; then LegacyPasswordQuest; fi
if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
LegacyPasswordCheck
else
echo "Password is invalid!"
unset passdiaone
LegacyPasswordQuest
fi
}
function LegacyPasswordCheck {
#Checking password
echo "Please re-enter your password"
read -s passdiatwo
if [ -z $passdiatwo ]; then
LegacyPasswordCheck
else
if [ $passdiaone != $passdiatwo ]; then
echo "Password does not match!"
LegacyPasswordQuest
else
password="$passdiaone"
unset passdiaone passdiatwo
fi
fi
}
function HostnameQuest {
if (whiptail --title "Config" --yesno " Hostname with nxdi.nl" 11 78); then
hostname=$(whiptail --nocancel --inputbox " SystemID (eg: VCH001) without ".nxdi.nl" " 11 82 --title "Config" 3>&1 1>&2 2>&3)
hostname=$hostname".nxdi.nl"
else
hostname=$(whiptail --nocancel --inputbox " Hostname" 11 78 --title "Config" 3>&1 1>&2 2>&3)
fi
}
function LegacyHostnameQuest {
while true; do
read -p "Hostname with nxdi.nl -> yes/no?" yn
case $yn in
[Nn]* )
echo 'Enter full hostname:'
read hostname
break;;
[Yy]* )
echo 'Hostname (eg: VCH001) without ".nxdi.nl":'
read hostname
hostname=$hostname".nxdi.nl"
break;;
* )echo "Choose yes or no.";;
esac
done
}
##----------------##
# System-Check #
##----------------##
if [[ "$syscheckoff" -ne 1 ]] && [[ -d /etc/ICTM ]]; then msg " This system has already been installed by Web-V2" && exit; fi
##Check for pkgs, not yet setup for Centos
# if [[ "$syscheckoff" -ne 1 ]] && [[ ! -z $(dpkg -l | cut -d " " -f 3 | grep "^mysql-server") || ! -z $(dpkg -l | cut -d " " -f 3 | grep "nginx") || ! -z $(dpkg -l | cut -d " " -f 3 | grep "apache") || ! -z $(dpkg -l | cut -d " " -f 3 | grep "php") ]] ; then msg " This system has installed packages, Web-V2 is designed for clean systems" && exit; fi
##--------------------------##
# Installer-Requirements #
##--------------------------##
msg " Starting installer" 8 78
$PKGM update -y > $OUTPUT 2>&1
$PKGI curl wget > $OUTPUT 2>&1
##--------##
# Menu #
##--------##
#Fetching Menu Entries
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/ModulesMenu.list)
if [ $IMODE = n ]; then
if [ $TestMode = 0 ]; then
domain=$(whiptail --nocancel --inputbox " Enter the domain without WWW " 11 82 --title "Config" 3>&1 1>&2 2>&3)
if (whiptail --title "Config" --yesno "Does www.${domain} exist in DNS?" 11 82 ); then
domainwww=1
else
domainwww=0
fi
if (whiptail --title "Config" --yesno "Set sitename to ${domain//./_} ?" 8 78 ); then
sitename=${domain//./_}
else
while true; do
sitename=$(whiptail --nocancel --inputbox "Enter sitename, Must NOT contain special characters, except: _" 8 66 --title "Config" 3>&1 1>&2 2>&3)
if [[ $sitename == *['!'@#\$%^\&*()+,.]* ]] || [ -z "$sitename" ]
then
whiptail --msgbox " Site can't be empty, or contain a special character except for: _" 11 76
else
break
fi
done
fi
while true; do
HostnameQuest
if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ]
then
whiptail --msgbox " Hostname can't be empty, or be the same as the domain" 11 63
else
break
fi
done
if (whiptail --title "Config" --yesno " Enable SSL on installation?" 11 78); then
sslenable=1
else
sslenable=0
fi
PasswordQuest
email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 78 --title "Config" 3>&1 1>&2 2>&3)
fi
webserv=$(whiptail --title "Select Webserver" --radiolist "WebServer" 11 74 5 "${webservers[@]}" 3>&1 1>&2 2>&3)
esws=$?
[[ "$esws" = 1 ]] && msg " Quiting installer" && exit;
fi
if [ $IMODE = l ]; then
echo "" >/dev/null
if [ $TestMode = 0 ]; then
echo "Enter the domain without WWW:"
read domain
while true; do
read -p "Does www.${domain} exist in DNS -> yes/no?" yn
case $yn in
[Yy]* ) domainwww=1
break;;
[Nn]* ) domainwww=0
break;;
* ) echo "Choose yes or no.";;
esac
done
read -p "Set sitename to ${domain//./_}? (y/n)" choice
case "$choice" in
y*|Y* ) sitename=${domain//./_};;
n*|N* ) echo "";
while true; do
echo "Please enter sitename, Must NOT contain special characters, except: _";read sitename
if [[ $sitename == *['!'@#\$%^\&*()+,.]* ]] || [ -z "$sitename" ]
then
echo "Site can't be empty, or contain a special character except for: _"
else
break
fi
done
;;
* ) echo "invalid";;
esac
while true; do
LegacyHostnameQuest
if [[ "$hostname" == "$domain" ]] || [ -z "$hostname" ]
then
echo "Hostname can't be empty, or be the same as the domain"
else
break
fi
done
while true; do
read -p "Enable SSL on installation? -> yes/no?" yn
case $yn in
[Yy]* ) sslenable=1
break;;
[Nn]* ) sslenable=0
break;;
* ) echo "Choose yes or no.";;
esac
done
LegacyPasswordQuest
echo "Administrator E-mail:"
read email
fi
echo "Select Webserver:"
select webserv in "${webservers[@]}"; do
case $webserv in
"Quit") exit ;;
"") echo 'Invalid choice' >&2 ;;
*) break
esac
done
fi
webserv="${webserv//:}" && webserv="${webserv,,}"
#Setting Menulist to webserver
declare -n CMSL="$webserv"CMSL
declare -n options="$webserv"Options
#Generating APT-List for webserver
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/generic.pkg.list; then
curl --silent --show-error "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/"$PKGLIST".pkg.list; then
curl --silent --show-error "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/generic.pkg.list; then
curl --silent --show-error "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/"$PKGLIST".pkg.list; then
curl --silent --show-error "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
##-----------------##
# Storeing vars #
##-----------------##
mkdir -p /etc/ICTM/sites
echo "InstDate=$(date "+%d-%B-%Y")" >> /etc/ICTM/mainvar.list
for storeme in PKGM PKGI PKGLIST OUTPUT IMODE shortdist repo branch branchtype webserv email shortdist hostname; do
declare -p $storeme | cut -d ' ' -f 3- >> /etc/ICTM/mainvar.list
done
touch /etc/ICTM/sites/"$sitename"
##----------##
# Addons #
##----------##
##DisableOPtionMenu
if [ $IMODE = n ]; then
option=$(whiptail --nocancel --title "Additional modules" --checklist "Features" 11 74 5 "${options[@]}" 3>&1 1>&2 2>&3)
fi
if [ $IMODE = l ]; then
choice () {
local choice=$1
if [[ ${opts[choice]} ]] # toggle
then
opts[choice]=
topt=${opt//+/}
topt="${topt%"${topt##*[![:space:]]}"}"
topt=\"$topt\"
option=${option//"$topt"/}
unset topt
else
opts[choice]=+
opt="${opt%"${opt##*[![:space:]]}"}"
option+="\"$opt\" "
fi
}
PS3='Which addons should be installed?'
while :
do
echo ""
unset options2
unset OPTcounter
for E in "${options[@]}"; do
((OPTcounter++))
options2+=("${E} ${opts["$OPTcounter"]}")
done
options2+=("Done")
select opt in "${options2[@]}"
do
case $opt in
"Done") break 2;;
"") printf '%s\n' 'invalid option';;
*) choice $REPLY
break
;;
esac
done
done
option="${option%"${option##*[![:space:]]}"}"
fi
#saving selected modules
echo 'SelectedOptions=('$option')' > /etc/ICTM/selopts.list
#Cleaning options from menu
option="${option,,}" && option="${option// /}" && option="${option//:/ }" && option="${option//'"'}"
#enableing modules wanted by webserver
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/reqmodules.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/reqmodules.sh)
fi
#Combining selected option with always-on options
option="$option""$aonoption"
#Generating APT-list options
for val1 in ${option[*]}; do
modListed=$(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/extModules.list|grep "$val1")
#Checking
if test -z "$modListed"
then
#Fetching from local repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/generic.pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-generic.pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$PKGLIST".pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-"$PKGLIST".pkg.list; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
else
#Fetching from remote repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed"generic.pkg.list; then
curl --retry 7 --retry-delay 5 -s "$modListed"generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed""$webserv"-generic.pkg.list; then
curl "$modListed""$webserv"-generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed""$PKGLIST".pkg.list; then
curl --retry 7 --retry-delay 5 -s "$modListed""$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed""$webserv"-"$PKGLIST".pkg.list; then
curl "$modListed""$webserv""$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
fi
done
##-------##
# CMS #
##-------##
if [ $IMODE = n ]; then
function CMSM {
CMS=$(whiptail --nocancel --title "What CMS should be installed?" --radiolist "Features" 11 118 5 "${CMSL[@]}" 3>&1 1>&2 2>&3)
if [ -z $CMS ]; then CMSM; fi
}
CMSM
fi
if [ $IMODE = l ]; then
echo "What CMS should be installed?"
#CMSPromt
select CMS in "${CMSL[@]}"; do
case CMS in
"") echo 'Invalid choice' >&2 ;;
*) break
esac
done
fi
CMS="${CMS//:}" && CMS="${CMS,,}"
#Generating APT-List CMS
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/generic.pkg.list; then
curl -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-generic.pkg.list; then
curl -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-generic.pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$PKGLIST".pkg.list; then
curl -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-"$PKGLIST".pkg.list; then
curl -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
##-------------------##
# Pre-configuring #
##-------------------##
msg " Pre-configuring"
#Generic Pre-Conf
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/preconf.sh)
#Generic WebServer
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/preconf.sh)
fi
#Preconfiguring for Modules
for val1 in ${option[*]}; do
msg "Pre-configuring $val1"
modListed=$(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/extModules.list|grep "$val1")
#Checking
if test -z "$modListed"
then
#Fetching from local repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/preconf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-preconf.sh)
fi
else
#Fetching from remote repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed"preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$modListed"preconf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed""$webserv"-preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$modListed""$webserv"-preconf.sh)
fi
fi
done
#Preconfiguring CMS
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/preconf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-preconf.sh)
fi
#Saving updated vars
for storeme in phpver sqlver PHPMyadmin; do
declare -p $storeme | cut -d ' ' -f 3- >> /etc/ICTM/mainvar.list
done
##-------------##
# Installer #
##-------------##
$PKGM update -y
sed -i 's/PHPprefix/'$phpPkgName'/g' /tmp/pkg.list
cat /tmp/pkg.list | xargs $PKGI
##---------------##
# Configuring #
##---------------##
msg " Configuring"
#Configuring Generic
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/generic/conf.sh)
#Configuring WebServer
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/conf.sh)
fi
#Configuring Options
for val1 in ${option[*]}; do
msg "Configuring $val1"
modListed=$(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/extModules.list|grep "$val1")
#Checking
if test -z "$modListed"
then
#Fetching from local repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/conf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/"$val1"/"$webserv"-conf.sh)
fi
else
#Fetching from remote repo
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed"conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$modListed"conf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$modListed""$webserv"-conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$modListed""$webserv"-conf.sh)
fi
fi
done
if [ $sslenable = 1 ]; then
msg " Setting up SSL" 8 78
if [ $webserv = nginx_nonphp ]; then
certwebserv=nginx
else
certwebserv=$webserv
fi
if [ $domainwww = 1 ]; then
/opt/acmesh/acme.sh --config-home '/etc/acmesh/data' --issue --"$certwebserv" --ocsp --keylength 'ec-384' -d "$domain" -d "www.$domain" > $OUTPUT 2>&1
certsatus=$?
elif [ $domainwww = 0 ]; then
/opt/acmesh/acme.sh --config-home '/etc/acmesh/data' --issue --"$certwebserv" --ocsp --keylength 'ec-384' -d "$domain" > $OUTPUT 2>&1
certsatus=$?
fi
if test $certsatus -eq 0
then
site_ext="ssl"
else
site_ext="nossl"
rm -rf /etc/acmesh/certs/$domain*
fi
unset certsatus
/opt/acmesh/acme.sh --config-home '/etc/acmesh/data' --issue --"$certwebserv" --ocsp --keylength 'ec-384' -d "$hostname" > $OUTPUT 2>&1
certsatusBackend=$?
if test $certsatusBackend -eq 0
then
siteBackend_ext="ssl"
else
siteBackend_ext="nossl"
rm -rf /etc/acmesh/certs/$hostname*
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/ssl-handler.sh; then
sslfr=1 source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$webserv"/ssl-handler.sh)
fi
elif [ $sslenable = 0 ]; then
site_ext=nossl
siteBackend_ext=nossl
fi
if [ $site_ext = nossl ]; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/EnableSSL.sh -o ~/activateSSL-$domain.sh
sed -i -e 's/DOMAINname/'$domain'/' -e 's/CONFname/'$sitename'/' -e 's/DomainWWW/'$domainwww'/' -e 's/Email/'$email'/' -e 's/WebServer/'$webserv'/' ~/activateSSL-$domain.sh
fi
if [ $siteBackend_ext = nossl ]; then
if [ -z $disbackendcms ]; then
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/Scripts/EnableSSL.sh -o ~/activateSSL-Backend.sh
sed -i -e 's/DOMAINname/'$hostname'/' -e 's/CONFname/'Backend'/' -e 's/DomainWWW/'0'/' -e 's/Email/'$email'/' -e 's/WebServer/'$webserv'/' ~/activateSSL-Backend.sh
fi
fi
msg " Configuring CMS"
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/conf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh)
fi
if [ -z $disbackendcms ]; then
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/Backend/conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/Backend/conf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/"$branchtype"/"$branch"/CMS/Backend/"$webserv"-conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/CMS/Backend/"$webserv"-conf.sh)
fi
fi
##------------##
# Services #
##------------##
systemctl reload sshd fail2ban
##-------##
# Done #
##-------##
msg " Done installing!"
if stat --printf='' /etc/update-motd.d/51* 2>/dev/null; then for f in /etc/update-motd.d/51*; do bash $f; done; fi