From 87b627ebcb939c3ecc6def3f79b3688471428ec1 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Tue, 13 Dec 2022 15:25:05 -0600 Subject: [PATCH] script cleanup --- packer/scripts/enable-vmware-customization.sh | 6 +++++- packer/scripts/persist-cloud-init-net.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packer/scripts/enable-vmware-customization.sh b/packer/scripts/enable-vmware-customization.sh index 4b6f2c0..fba2c01 100644 --- a/packer/scripts/enable-vmware-customization.sh +++ b/packer/scripts/enable-vmware-customization.sh @@ -1,4 +1,8 @@ #!/bin/bash -eu echo '>> Enabling legacy VMware Guest Customization...' -echo 'disable_vmware_customization: true' | sudo tee -a /etc/cloud/cloud.cfg +if grep -q 'disable_vmware_customization' /etc/cloud/cloud.cfg; then + sudo sed -i 's/^disable_vmware_customization:.*$/disable_vmware_customization: True/' /etc/cloud/cloud.cfg +else + echo 'disable_vmware_customization: true' | sudo tee -a /etc/cloud/cloud.cfg +fi sudo vmware-toolbox-cmd config set deployPkg enable-custom-scripts true diff --git a/packer/scripts/persist-cloud-init-net.sh b/packer/scripts/persist-cloud-init-net.sh index 005a6ad..9a50d4b 100644 --- a/packer/scripts/persist-cloud-init-net.sh +++ b/packer/scripts/persist-cloud-init-net.sh @@ -1,3 +1,7 @@ #!/bin/sh -eu echo '>> Preserving network settings...' -echo 'manual_cache_clean: True' | sudo tee -a /etc/cloud/cloud.cfg \ No newline at end of file +if grep -q 'manual_cache_clean' /etc/cloud/cloud.cfg; then + sudo sed -i 's/^manual_cache_clean.*$/manual_cache_clean: True/' /etc/cloud/cloud.cfg +else + echo 'manual_cache_clean: True' | sudo tee -a /etc/cloud/cloud.cfg +fi \ No newline at end of file