Skip to content

Commit

Permalink
add script for patching base OS's
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 committed Apr 10, 2024
1 parent 4b05568 commit 86649f1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions files/patch-os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

patch_debian() {
echo "Patching Debian"
apt-get update
apt-get upgrade -y
rm -rf /var/lib/apt/lists/*
}

patch_ubi_dnf() {
echo "Patching UBI dnf"
DNF=""
if [ -f /usr/bin/microdnf ]; then
DNF=/usr/bin/microdnf
else
DNF=/usr/bin/dnf
fi
${DNF} update -y
${DNF} clean all

}

patch_alpine() {
echo "Patching Alpine"
apk upgrade --no-cache -U
}

if [ ! -f /etc/os-release ]; then
echo "ERROR: cannot find /etc/os-release, cannot continue."
exit 1
fi

. /etc/os-release

case ${ID} in
"debian")
patch_debian
;;
"rhel")
patch_ubi_dnf
;;
"alpine")
patch_alpine
;;
*)
echo "ERROR: unsupported OS [${ID}]"
exit 1
;;
esac

0 comments on commit 86649f1

Please sign in to comment.