Files
VPS-scripts_Web-V2/Scripts/SMI.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

180 lines
4.7 KiB
Bash

#############################
# SingleModuleInstaller #
#############################
##-----------------##
# Defining Vars #
##-----------------##
#SMI specific Vars
SMI_config=no
SMI_ModuleName=<ModuleName>
#Enforcing Legacy Mode
APTMODE="apt"
OUTPUT='/dev/tty'
IMODE=l
#Web-V2 Vars
domain=test.local
hostname=s1.test.local
sslenable=1
password=TestP@ssword123
email=test@mail.local
webserv=nginx
#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
echo "Ubuntu 20.04 is not yet fully tested, not recommended for production server"
PKGM="$APTMODE"
PKGI="${PKGM} install -y --no-install-recommends"
PKGLIST="apt"
shortdist=ubu2004
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
echo "Debian 10 Detected"
PKGM="$APTMODE"
PKGI="${PKGM} install -y --no-install-recommends"
PKGLIST="apt"
shortdist=deb10
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
echo "Centos 8 Detected"
PKGM="dnf"
PKGI="${PKGM} install --setopt=install_weak_deps=False --best -y"
PKGLIST="dnf"
shortdist=cent8
echo "This OS is not supported"
exit
else
echo "This OS is not supported"
exit
fi
unset dist_ver dist APTMODE
#Repo Vars
repo=https://git.ictmaatwerk.com/VPS-scripts/Web-V2
branch=master
branchtype=branch
###Select Module type
##Uncomment for CoreModules
mtype=""$repo"/raw/"$branchtype"/"$branch"/CoreModules/"$SMI_ModuleName""
##Uncomment for SubModules
#mtype=""$repo"/raw/"$branchtype"/"$branch"/SubModules/"$SMI_ModuleName""
##Uncomment for CMS
#mtype=""$repo"/raw/"$branchtype"/"$branch"/CMS/"$SMI_ModuleName""
##Uncomment for External Module
#mtype=""$repo"/raw/"$branchtype"/"$branch""
#SelfBuilding Vars
PKGI="${PKGM} install -y"
##---------------##
# Functions #
##---------------##
msg () {
echo "$1"
}
#Checking if Config var has been set
if [ $SMI_config = no ]; then
msg " Script is not configured"
exit
fi
##--------------------------##
# Installer-Requirements #
##--------------------------##
msg " Starting installer" 8 78
$PKGM update > $OUTPUT 2>&1
$PKGI curl > $OUTPUT 2>&1
##-------------------------##
# Generating APT list #
##-------------------------##
#Remove existing pkgList
rm -f /tmp/pkg.list
#General pkgList
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/generic.pkg.list; then
curl "$mtype"/generic.pkg.list >>/tmp/pkg.list
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/"$PKGLIST".pkg.list; then
curl "$mtype"/"$PKGLIST".pkg.list >>/tmp/pkg.list
fi
#Webserver specific pkgList
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/"$webserv"-generic.pkg.list; then
curl "$mtype"/"$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 "$mtype"/"$webserv"-"$PKGLIST".pkg.list; then
curl "$mtype"/"$webserv"-"$PKGLIST".pkg.list >>/tmp/pkg.list
printf " " >>/tmp/pkg.list
fi
##--------------------##
# Pre-Requirements #
##--------------------##
msg " Preconfiguring"
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=init osrel=$shortdist bash > $OUTPUT 2>&1
$PKGM update
$PKGM upgrade -y
##-------------------##
# Pre-configuring #
##-------------------##
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$mtype"/preconf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/"$webserv"-preconf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$mtype"/"$webserv"-preconf.sh)
fi
##-------------##
# Installer #
##-------------##
$PKGM update
sed -i 's/PHPprefix/'$phpPkgName'/g' /tmp/pkg.list
cat /tmp/pkg.list | xargs $PKGI
##---------------##
# Configuring #
##---------------##
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$mtype"/conf.sh)
fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/"$webserv"-conf.sh; then
source <(curl --retry 7 --retry-delay 5 -s "$mtype"/"$webserv"-conf.sh)
fi
##-------##
# end #
##-------##
msg " Done!"