From 10c111f7800a4230d33b45384afc7641079b07e3 Mon Sep 17 00:00:00 2001 From: bprieshof Date: Fri, 13 Dec 2019 13:23:46 +0100 Subject: [PATCH] Add 'Scripts/SMI.sh' --- Scripts/SMI.sh | 132 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 Scripts/SMI.sh diff --git a/Scripts/SMI.sh b/Scripts/SMI.sh new file mode 100644 index 0000000..0b0d719 --- /dev/null +++ b/Scripts/SMI.sh @@ -0,0 +1,132 @@ +############################# +# SingelModuleInstaller # +############################# + + +##-----------------## +# Defining Vars # +##-----------------## + +#SMI specific Vars +SMI_config=no +SMI_ModuleName= + +#Enforcing Legacy Mode +PKGM="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 + +#Repo Vars +repo=https://git.ictmaatwerk.com/bprieshof/UBU-Web-V2 +branch=master + +###Select Module type +##Uncomment for CoreModules +mtype=""$repo"/raw/branch/"$branch"/CoreModules/"$SMI_ModuleName"" +##Uncomment for SubModules +#mtype=""$repo"/raw/branch/"$branch"/SubModules/"$SMI_ModuleName"" +##Uncomment for CMS +#mtype=""$repo"/raw/branch/"$branch"/CMS/"$SMI_ModuleName"" +##Uncomment for External Module +#mtype=""$repo"/raw/branch/"$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 # +##-------------------------## +#General aptList +if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/"$webserv"-apt.list; then + curl "$mtype"/"$webserv"-apt.list >>/tmp/apt.list +fi +#Webserver specific aptList +if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/apt.list; then + curl "$mtype"/apt.list >>/tmp/apt.list +fi + + +##--------------------## +# Pre-Requirements # +##--------------------## + +msg "Preconfiguring." +$PKGI software-properties-common gnupg > $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/PHPver/'$phpver'/g' /tmp/apt.list +cat /tmp/apt.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" +