Updated install methode,

added support for centos/DNF
This commit is contained in:
2020-12-02 12:32:47 +01:00
parent 398f274355
commit 3137fd17a4
8 changed files with 225 additions and 35 deletions

View File

@@ -1,40 +1,123 @@
#!/bin/bash
###################################
# Unattended Security Updates #
###################################
###############################
# @author: Bram Prieshof #
# @author: Branco van de Waal #
###############################
##--------------##
# Pre-Config #
##--------------##
if [ -z "$PKGI" ] || [ -z "$PKGM" ]
then
PKGM="apt"
PKGI="${PKGM} install -y"
##-----------------##
# Defining Vars #
##-----------------##
#Enforcing Legacy Mode
APTMODE="apt"
OUTPUT='/dev/tty'
IMODE=l
#OS Detection
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
exit
else
echo "This OS is not supported"
exit
fi
unset dist_ver dist APTMODE
#Repo Vars
repo=https://git.ictmaatwerk.com/VPS-scripts/Unattended-Security-Updates
branch=master
branchtype=branch
mtype=""$repo"/raw/"$branchtype"/"$branch""
#SelfBuilding Vars
PKGI="${PKGM} install -y"
##---------------##
# 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"
$PKGM update
$PKGM upgrade -y
##-------------##
# Installer #
##-------------##
$PKGI unattended-upgrades
##----------------##
# OS Detection #
##----------------##
source /etc/os-release
if [ "$ID" = "debian" ]; then
LinVer=Debian
elif [ "$ID" = "ubuntu" ]; then
LinVer=Ubuntu
else
echo "this OS is not supported"
$PKGM update
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
##-----------##
# Configs #
##-----------##
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/Unattended-Security-Updates/raw/branch/master/config/Universal_20auto-upgrades -o /etc/apt/apt.conf.d/20auto-upgrades
curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/Unattended-Security-Updates/raw/branch/master/config/"$LinVer"_50unattended-upgrades -o /etc/apt/apt.conf.d/50unattended-upgrades
##-------##
# end #
##-------##
msg " Done!"