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