{{- if ne .host.distro.family "windows" -}}
#!/usr/bin/env bash

{{- includeTemplate "universal/profile" }}
{{- includeTemplate "universal/logg" }}

### Only run logic if both Vagrant and VMWare are installed
if command -v vagrant > /dev/null && command -v vmware > /dev/null; then
    ### Vagrant VMWare Utility configuration
    if command -v vagrant-vmware-utility > /dev/null; then
        if [ -f /usr/local/bin/certificates/vagrant-utility.key ]; then
            logg info 'Assuming Vagrant VMWare Utility certificates have been properly generated since /usr/local/bin/certificates/vagrant-utility.key is present'
        else
            logg info 'Generating Vagrant VMWare Utility certificates'
            sudo vagrant-vmware-utility certificate generate
            logg success 'Generated Vagrant VMWare Utility certificates via `vagrant-vmware-utility certificate generate`'
        fi
        logg info 'Ensuring the Vagrant VMWare Utility service is enabled'
        sudo vagrant-vmware-utility service install || EXIT_CODE=$?
        if [ -n "$EXIT_CODE" ]; then
            logg info 'The Vagrant VMWare Utility command `vagrant-vmware-utility service install` failed. It is probably already setup.'
        fi
    fi
else
    logg warn 'Vagrant is not installed so the Vagrant plugins will not be installed'
    logg warn 'Vagrant or VMWare is not installed so the Vagrant VMWare utility will not be configured'
fi

{{ end -}}
