From def851ff02e3d17667aa218bd1f5eef978654915 Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown Date: Fri, 11 Jun 2021 10:47:39 -0700 Subject: [PATCH] Rebase be39b6d - select yum or apt-get in systemd-resolved --- .../setup-systemd-resolved | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/setup-systemd-resolved/setup-systemd-resolved b/modules/setup-systemd-resolved/setup-systemd-resolved index 28670839..21fb7be5 100755 --- a/modules/setup-systemd-resolved/setup-systemd-resolved +++ b/modules/setup-systemd-resolved/setup-systemd-resolved @@ -67,14 +67,30 @@ function assert_not_empty { fi } +function has_yum { + [ -n "$(command -v yum)" ] +} + +function has_apt_get { + [ -n "$(command -v apt-get)" ] +} + function install_dependencies { local -r consul_ip="$1" log_info "Installing dependencies" - sudo apt-get update -y - echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections - echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections - sudo apt-get install -y iptables-persistent + if has_apt_get; then + sudo apt-get update -y + echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections + echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections + sudo apt-get install -y iptables-persistent + elif has_yum; then + sudo yum update -y + sudo yum install -y iptables-services + else + log_error "Could not find apt-get or yum. Cannot install dependencies on this OS." + exit 1 + fi } function configure_systemd_resolved {