Files

46 lines
1.7 KiB
Bash

#Set repo
mrepo=https://git.bprieshof.nl/Work_Archive/VPS-scripts_Unattended-Security-Updates
mbranch=main
#OS Detection if not provided by external installer
if [ -z ${shortdist+x} ]; then
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
shortdist=ubu1804
echo set
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
shortdist=ubu2004
echo set
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
shortdist=deb10
echo set
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"11"* ]]; then
shortdist=deb11
echo set
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
shortdist=el8
echo set
else
echo "This os in not supported"
fi
fi
#OS Handeler
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] || [ "$shortdist" = "deb11" ] ; then
##Setting Configname
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] ; then
LinVer=Ubuntu
elif [ "$shortdist" = "deb10" ] || [ "$shortdist" = "deb11" ]; then
LinVer=Debian
fi
##Fetching Confgs
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/apt/Universal_20auto-upgrades -o /etc/apt/apt.conf.d/20auto-upgrades > $OUTPUT 2>&1
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/apt/"$LinVer"_50unattended-upgrades -o /etc/apt/apt.conf.d/50unattended-upgrades > $OUTPUT 2>&1
elif [ "$shortdist" = "el8" ]; then
##Fetching Confgs
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/dnf/el8_automatic.conf -o /etc/dnf/automatic.conf > $OUTPUT 2>&1
fi