2023-01-24 09:29:05 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-18 13:35:36 +01:00
|
|
|
detect_distro() {
|
|
|
|
if [ -f /etc/centos-release ]; then
|
|
|
|
DISTRO=centos
|
|
|
|
elif [ -f /etc/oracle-release ]; then
|
2023-01-24 09:29:05 +01:00
|
|
|
DISTRO=oracle
|
2023-01-25 05:27:10 +01:00
|
|
|
elif [ -f /etc/fedora-release ]; then
|
|
|
|
DISTRO=fedora
|
2023-01-18 13:35:36 +01:00
|
|
|
elif [ -f /usr/bin/zypper ]; then
|
|
|
|
DISTRO=opensuse
|
2023-03-13 20:57:24 +01:00
|
|
|
elif [ -f /etc/alpine-release ]; then
|
|
|
|
DISTRO=alpine
|
2023-01-18 13:35:36 +01:00
|
|
|
else
|
|
|
|
DISTRO=debian
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-01-24 10:15:03 +01:00
|
|
|
install_packages() {
|
|
|
|
local install_cmd=no-command-defined
|
|
|
|
|
|
|
|
case "$DISTRO" in
|
|
|
|
centos) install_cmd="yum install -y" ;;
|
|
|
|
oracle) install_cmd="dnf install -y" ;;
|
2023-01-25 05:27:10 +01:00
|
|
|
fedora) install_cmd="dnf install -y" ;;
|
2023-01-24 10:15:03 +01:00
|
|
|
opensuse) install_cmd="zypper install -y" ;;
|
2023-03-13 20:57:24 +01:00
|
|
|
alpine) install_cmd="apk add" ;;
|
2023-01-24 10:15:03 +01:00
|
|
|
*) install_cmd="apt-get update && apt-get install -y"
|
|
|
|
esac
|
|
|
|
|
|
|
|
eval "$install_cmd $*"
|
|
|
|
}
|
|
|
|
|
2023-01-18 13:35:36 +01:00
|
|
|
detect_distro
|