From 3f9ef114b35d8d39a590cddf3ebeead673d2e7ea Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Thu, 2 Feb 2023 02:44:01 +0000 Subject: [PATCH] Update 3 files - /home/.chezmoiscripts/universal/run_onchange_before_05-install-vmware.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.tmpl - /docs/CHEZMOI-INTRO.md --- docs/CHEZMOI-INTRO.md | 6 ++- .../run_onchange_after_44-vmware-install.tmpl | 39 +++++++++++++++++++ ...run_onchange_before_05-install-vmware.tmpl | 27 ------------- 3 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.tmpl delete mode 100644 home/.chezmoiscripts/universal/run_onchange_before_05-install-vmware.tmpl diff --git a/docs/CHEZMOI-INTRO.md b/docs/CHEZMOI-INTRO.md index d00e12d9..182bf54c 100644 --- a/docs/CHEZMOI-INTRO.md +++ b/docs/CHEZMOI-INTRO.md @@ -151,4 +151,8 @@ in `.chezmoitemplates/secrets/key-surgesh-password` to leverage this functionali ### OpenVPN Password -* Environment Variable: `OVPN_PASSWORD` \ No newline at end of file +* Environment Variable: `OVPN_PASSWORD` + +### VMWare Workstation Key + +* Environment Variable: `VMWARE_WORKSTATION_LICENSE_KEY` \ No newline at end of file diff --git a/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.tmpl new file mode 100644 index 00000000..e24ac930 --- /dev/null +++ b/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.tmpl @@ -0,0 +1,39 @@ +{{- if eq .host.distro.family "linux" -}} +#!/usr/bin/env bash + +{{- if (stat (joinPath (.chezmoi.sourceDir ".chezmoitemplates" "secrets" "key-vmware-workstation"))) -}} +{{- $secretKey := (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (includeTemplate "secrets/key-vmware-workstation" | decrypt)) -}} +{{- else -}} +{{- $secretKey := (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (env "VMWARE_WORKSTATION_LICENSE_KEY")) -}} +{{- end }} + +# Source: https://gist.github.com/PurpleVibe32/30a802c3c8ec902e1487024cdea26251 +# key: {{- $secretKey }} + +{{ includeTemplate "universal/profile-before" }} +{{ includeTemplate "universal/logg-before" }} + +### Install VMware Workstation +if ! command -v vmware > /dev/null; then + ### Download VMWare Workstation + logg info 'VMware Workstation is not installed' + VMWARE_WORKSTATION_URL=https://www.vmware.com/go/getworkstation-linux + VMWARE_WORKSTATION_DIR=/tmp/workstation-downloads + mkdir -p $VMWARE_WORKSTATION_DIR + logg info 'Downloading VMware Workstation Installer' + curl -sSLA "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20220101 Firefox/102.0" "$VMWARE_WORKSTATION_URL" -o "$VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh" + + ### Register product key / license + VMWARE_WORKSTATION_LICENSE_KEY='{{- $secretKey -}}' + if [ -n "$VMWARE_WORKSTATION_LICENSE_KEY" ]; then + logg info 'Registering VMware Workstation Pro license with serial number' + sudo "$VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh" --eulas-agreed --console --required --set-setting vmware-workstation serialNumber "$VMWARE_WORKSTATION_LICENSE_KEY" + else + logg info 'Agreeing to VMWare Workstation Pro license (without serial number)' + sudo "$VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh" --eulas-agreed --console --required + fi + logg success 'VMware Workstation installed successfully' +else + logg info 'VMware Workstation is already installed' +fi +{{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_before_05-install-vmware.tmpl b/home/.chezmoiscripts/universal/run_onchange_before_05-install-vmware.tmpl deleted file mode 100644 index ed0f1721..00000000 --- a/home/.chezmoiscripts/universal/run_onchange_before_05-install-vmware.tmpl +++ /dev/null @@ -1,27 +0,0 @@ -{{- if eq .host.distro.family "linux" -}} -#!/usr/bin/env bash - -{{ includeTemplate "universal/profile-before" }} -{{ includeTemplate "universal/logg-before" }} - -### Install VMware Workstation -if [ ! command -v vmware > /dev/null ]; then - logg info 'VMware Workstation is not installed.' - VMWARE_WORKSTATION_URL=https://www.vmware.com/go/getworkstation-linux - VMWARE_WORKSTATION_DIR=/tmp/workstation-downloads - mkdir -p $VMWARE_WORKSTATION_DIR - logg info 'Downloading VMware Workstation Installer' - curl -sSLA "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20220101 Firefox/102.0" "$VMWARE_WORKSTATION_URL" \ - -o "$VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh" - logg info 'Installing VMware Workstation' - if [[ -v VMWARE_WORKSTATION_LICENSE_KEY && -n $VMWARE_WORKSTATION_LICENSE_KEY ]]; then - sudo $VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh --eulas-agreed --console --required \ - --set-setting vmware-workstation serialNumber $VMWARE_WORKSTATION_LICENSE_KEY - else - sudo $VMWARE_WORKSTATION_DIR/tryworkstation-linux-64.sh --eulas-agreed --console --required - fi - logg success 'VMware Workstation installed successfully' -else - logg info 'VMware Workstation is already installed' -fi -{{ end -}}