Inital commit
This commit is contained in:
175
InstallMonitModule.sh
Normal file
175
InstallMonitModule.sh
Normal file
@@ -0,0 +1,175 @@
|
||||
#############################
|
||||
# MonitModuleInstaller #
|
||||
#############################
|
||||
|
||||
|
||||
##-----------------##
|
||||
# Defining Vars #
|
||||
##-----------------##
|
||||
#Enforcing Legacy Mode
|
||||
APTMODE="apt"
|
||||
OUTPUT='/dev/tty'
|
||||
IMODE=l
|
||||
|
||||
|
||||
##-----------------##
|
||||
# Fetching Vars #
|
||||
##-----------------##
|
||||
|
||||
VarError () {
|
||||
while true; do
|
||||
echo ""
|
||||
read -p "Var list $1 not foud, continue without monit for $2? [Y/n]" yn
|
||||
case $yn in
|
||||
[Yy]* ) echo install; break;;
|
||||
[Nn]* ) echo exit;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ "/etc/ICTM/mainvar.list" ] ; then
|
||||
source /etc/ICTM/mainvar.list;
|
||||
else
|
||||
VarError mainvar "Webserver and php"
|
||||
#use if system is not setup using Web-V2
|
||||
##webserv=nginx
|
||||
fi
|
||||
|
||||
if [ ! -z "$webserv" ]; then
|
||||
if [ $webserv != nginx_nonphp ]; then
|
||||
if [ "/etc/ICTM/phpvar.list" ] ; then
|
||||
source /etc/ICTM/phpvar.list;
|
||||
else
|
||||
VarError phpvar apache
|
||||
#use if system is not setup using Web-V2
|
||||
##phpver=8.0
|
||||
##phpFPMService=php8.0-fpm
|
||||
fi
|
||||
source /etc/ICTM/phpvar.list
|
||||
fi
|
||||
if [ $webserv = apache ]; then
|
||||
if [ -f "/etc/ICTM/apachevar.list" ] && ; then
|
||||
source /etc/ICTM/apachevar.list
|
||||
else
|
||||
VarError apachevar apache
|
||||
#use if system is not setup using Web-V2
|
||||
##apacheService=apache2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#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
|
||||
echo "Ubuntu 18.04 Detected"
|
||||
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 Detected"
|
||||
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=el8
|
||||
else
|
||||
echo "This os in not supported"
|
||||
exit
|
||||
fi
|
||||
|
||||
unset dist_ver dist APTMODE
|
||||
|
||||
|
||||
#Repo Vars
|
||||
repo=https://git.ictmaatwerk.com/VPS-scripts/Monit
|
||||
branch=main
|
||||
branchtype=branch
|
||||
|
||||
#SelfBuilding Vars
|
||||
mtype=""$repo"/raw/"$branchtype"/"$branch""
|
||||
|
||||
|
||||
##---------------##
|
||||
# Functions #
|
||||
##---------------##
|
||||
|
||||
msg () {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
##--------------------------##
|
||||
# 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"/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
|
||||
|
||||
##--------------------##
|
||||
# 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
|
||||
|
||||
##-------------##
|
||||
# Installer #
|
||||
##-------------##
|
||||
|
||||
$PKGM update
|
||||
sed -i 's/PHPver/'$phpver'/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
|
||||
|
||||
##-------##
|
||||
# end #
|
||||
##-------##
|
||||
|
||||
msg " Done!"
|
||||
Reference in New Issue
Block a user