foreman/app/views/unattended/provisioning_templates/snippet/pkg_manager.erb @ bf03a259
55e2eef7 | Leos Stejskal | <%#
|
|
kind: snippet
|
|||
name: pkg_manager
|
|||
model: ProvisioningTemplate
|
|||
snippet: true
|
|||
description: |
|
|||
36eb18ec | Leos Stejskal | Select package manager for the OS. Snippet sets the package manager
|
|
in the PKG_MANAGER env variable so it can be used in templates like this:
|
|||
$PKG_MANAGER install -y pkg1 pkg2
|
|||
55e2eef7 | Leos Stejskal | -%>
|
|
if [ -f /etc/os-release ] ; then
|
|||
. /etc/os-release
|
|||
fi
|
|||
a7400aa4 | Bernhard Suttner | if [ "${NAME%.*}" = 'FreeBSD' ]; then
|
|
PKG_MANAGER='pkg'
|
|||
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
|
|||
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
|
|||
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
|
|||
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
|
|||
55e2eef7 | Leos Stejskal | PKG_MANAGER='dnf'
|
|
a7400aa4 | Bernhard Suttner | if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
|
|
PKG_MANAGER='yum'
|
|||
elif [ -f /etc/system-release ]; then
|
|||
55e2eef7 | Leos Stejskal | PKG_MANAGER='yum'
|
|
fi
|
|||
a7400aa4 | Bernhard Suttner | PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
|
|
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
|
|||
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
|
|||
55e2eef7 | Leos Stejskal | elif [ -f /etc/debian_version ]; then
|
|
PKG_MANAGER='apt-get'
|
|||
a7400aa4 | Bernhard Suttner | PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
|
|
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
|
|||
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
|
|||
55e2eef7 | Leos Stejskal | elif [ -f /etc/arch-release ]; then
|
|
PKG_MANAGER='pacman'
|
|||
a7400aa4 | Bernhard Suttner | PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
|
|
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
|
|||
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
|
|||
d94dcfec | Bernhard Suttner | elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
|
|
55e2eef7 | Leos Stejskal | PKG_MANAGER='zypper'
|
|
a7400aa4 | Bernhard Suttner | PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
|
|
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
|
|||
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
|
|||
55e2eef7 | Leos Stejskal | fi
|