From ac36823be2f471866ef24e241919d46a707a7fcd Mon Sep 17 00:00:00 2001 From: Andrew Graham Date: Sun, 23 Jan 2022 22:37:48 +1030 Subject: [PATCH 1/2] Skip package update with args --- modules/install-consul/install-consul | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/install-consul/install-consul b/modules/install-consul/install-consul index f33c659c..d8200754 100755 --- a/modules/install-consul/install-consul +++ b/modules/install-consul/install-consul @@ -118,13 +118,18 @@ function has_apt_get { } function install_dependencies { + local -r skip_package_update="$1" log_info "Installing dependencies" if has_apt_get; then - sudo apt-get update -y + if [[ "$skip_package_update" == "false" ]]; then + sudo apt-get update -y + fi sudo apt-get install -y awscli curl unzip jq elif has_yum; then - sudo yum update -y + if [[ "$skip_package_update" == "false" ]]; then + sudo yum update -y + fi sudo yum install -y aws curl unzip jq else log_error "Could not find apt-get or yum. Cannot install dependencies on this OS." @@ -274,6 +279,7 @@ function install { local ca_file_path="" local cert_file_path="" local key_file_path="" + local skip_package_update="false" while [[ $# -gt 0 ]]; do local key="$1" @@ -310,6 +316,9 @@ function install { key_file_path="$2" shift ;; + --skip-package-update) + skip_package_update="true" + ;; --help) print_usage exit @@ -330,7 +339,7 @@ function install { log_info "Starting Consul install" - install_dependencies + install_dependencies "$skip_package_update" create_consul_user "$user" create_consul_install_paths "$path" "$user" From 8878ef27da1836c07a17b36aa5b392767ac968ae Mon Sep 17 00:00:00 2001 From: Andrew Graham Date: Mon, 24 Jan 2022 00:14:00 +1030 Subject: [PATCH 2/2] Add skip_package_update args to install-dnsmasq --- modules/install-dnsmasq/install-dnsmasq | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/install-dnsmasq/install-dnsmasq b/modules/install-dnsmasq/install-dnsmasq index 6ff5256c..d55fc8be 100755 --- a/modules/install-dnsmasq/install-dnsmasq +++ b/modules/install-dnsmasq/install-dnsmasq @@ -78,14 +78,19 @@ function has_apt_get { function install_dnsmasq { local -r consul_ip="$1" + local -r skip_package_update="$2" log_info "Installing Dnsmasq" if has_apt_get; then - sudo apt-get update -y + if [[ "$skip_package_update" == "false" ]]; then + sudo apt-get update -y + fi sudo apt-get install -y dnsmasq elif has_yum; then - sudo yum update -y + if [[ "$skip_package_update" == "false" ]]; then + sudo yum update -y + fi sudo yum install -y dnsmasq echo "prepend domain-name-servers $consul_ip;" | sudo tee -a "/etc/dhcp/dhclient.conf" > /dev/null echo "conf-dir=$DNS_MASQ_CONFIG_DIR" | sudo tee -a "/etc/dnsmasq.conf" > /dev/null @@ -119,6 +124,7 @@ function install { local consul_ip="$DEFAULT_CONSUL_IP" local consul_dns_port="$DEFAULT_CONSUL_DNS_PORT" local dnsmasq_listen_address="$DEFAULT_DNSMASQ_LISTEN_ADDRESS" + local skip_package_update="false" while [[ $# -gt 0 ]]; do local key="$1" @@ -144,6 +150,9 @@ function install { dnsmasq_listen_address="$2" shift ;; + --skip-package-update) + skip_package_update="true" + ;; --help) print_usage exit @@ -163,7 +172,7 @@ function install { fi log_info "Starting Dnsmasq install" - install_dnsmasq "$consul_ip" + install_dnsmasq "$consul_ip" "$skip_package_update" write_consul_config "$consul_domain" "$consul_ip" "$consul_dns_port" "$dnsmasq_listen_address" log_info "Dnsmasq install complete!" }