From a3004df675a6a423248c3557b37131be38312c81 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Wed, 12 Jul 2023 04:32:13 +0000 Subject: [PATCH] Latest --- home/.chezmoidata.yaml | 3 +- home/.chezmoiexternal.toml.tmpl | 2 +- .../run_onchange_after_32-gitomatic.sh.tmpl | 63 ++- .../run_onchange_after_39-vim-plugins.sh.tmpl | 11 +- .../run_onchange_after_40-chrome.sh.tmpl | 103 ++-- .../run_onchange_after_40-firefox.sh.tmpl | 508 +++++++++--------- ...ge_after_41-vagrant-vmware-utility.sh.tmpl | 44 -- ...n_onchange_after_44-vmware-install.sh.tmpl | 76 --- .../run_onchange_after_45-vmware.sh.tmpl | 264 ++++++--- .../run_onchange_after_94-bash-it.sh.tmpl | 36 +- .../run_onchange_after_97-cloudflare.sh.tmpl | 2 +- ...ore_10-install-darwin-dependencies.sh.tmpl | 10 + home/.chezmoitemplates/darwin/Brewfile | 1 + home/dot_bashrc | 2 +- .../img => assets}/icon-jest.png | Bin home/dot_local/share/vscode/package.json | 2 +- home/dot_zshrc | 12 +- software.yml | 15 +- 18 files changed, 593 insertions(+), 561 deletions(-) delete mode 100644 home/.chezmoiscripts/universal/run_onchange_after_41-vagrant-vmware-utility.sh.tmpl delete mode 100644 home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.sh.tmpl rename home/dot_local/{megabyte-labs/img => assets}/icon-jest.png (100%) diff --git a/home/.chezmoidata.yaml b/home/.chezmoidata.yaml index da32c020..9b81d72f 100644 --- a/home/.chezmoidata.yaml +++ b/home/.chezmoidata.yaml @@ -980,7 +980,6 @@ softwareGroups: Virtualization-Desktop: &Virtualization-Desktop - docker-desktop - gnome-boxes - - orbstack - parallels - quickgui - utm @@ -1412,6 +1411,8 @@ softwareGroups: note: Deprecated in favor of using ASDF. - pkg: nuclear note: Music app - UI is horrendous + - pkg: orbstack + note: Faster / better alternative to Docker Desktop on macOS. Deprecated because it does not support Docker Extensions and is only for macOS. - pkg: pip note: The `pip` installation is handled by the `install-software` program bundled with Install Doctor. - pkg: pipx diff --git a/home/.chezmoiexternal.toml.tmpl b/home/.chezmoiexternal.toml.tmpl index 529eb187..6a968379 100644 --- a/home/.chezmoiexternal.toml.tmpl +++ b/home/.chezmoiexternal.toml.tmpl @@ -66,7 +66,7 @@ type = "file" url = "https://gitlab.com/megabyte-labs/gas-station/-/raw/master/environments/prod/group_vars/all/helm.yml" refreshPeriod = "{{ $refreshPeriod }}" -[".local/bash_it"] +[".local/share/bash_it"] type = "git-repo" url = "https://github.com/Bash-it/bash-it.git" refreshPeriod = "{{ $refreshPeriod }}" diff --git a/home/.chezmoiscripts/universal/run_onchange_after_32-gitomatic.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_32-gitomatic.sh.tmpl index e688c1f5..4cae6cef 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_32-gitomatic.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_32-gitomatic.sh.tmpl @@ -24,34 +24,39 @@ {{ includeTemplate "universal/profile" }} {{ includeTemplate "universal/logg" }} -### Clone the repositories -logg info 'Cloning the repositories' -{{ range .user.gitomatic }} -if [ ! -d "{{ .path }}" ]; then - git clone "{{ .git }}" "{{ .path }}" -fi -{{ end -}} - -### Create Systemd service to run gitomatic -if command -v gitomatic > /dev/null; then - if [ -d /Applications ] && [ -d /System ]; then - ### macOS - logg info 'Copying `gitomatic` plist file to /Library/LaunchDaemons' - sudo cp -f "{{ .chezmoi.homeDir }}/.config/gitomatic/gitomatic.plist" /Library/LaunchDaemons/gitomatic.plist - logg info 'Running `sudo launchctl load com.gitomatic`' - sudo launchctl load com.gitomatic - logg info 'Running `sudo launchctl start com.gitomatic`' - sudo launchctl start com.gitomatic - else - ### Linux - logg info 'Copying `gitomatic` systemd unit file to /etc/systemd/system/' - sudo cp -f "{{ .chezmoi.homeDir }}/.config/gitomatic/gitomatic.service" /etc/systemd/system/gitomatic.service - logg info 'Reloading systemd daemon' - sudo systemctl daemon-reload - logg info 'Enabling and starting `gitomatic` service' - sudo systemctl enable --now gitomatic +function gitomaticSetup() { + ### Clone the repositories + logg info 'Cloning the repositories' + {{ range .user.gitomatic }} + logg info 'Checking for presence of {{ .path }}' + if [ ! -d "{{ .path }}" ]; then + logg info 'Cloning {{ .git }} to {{ .path }}' + git clone "{{ .git }}" "{{ .path }}" fi -else - logg info 'Git-o-matic is not installed or it is not available in PATH' -fi + {{ end -}} + + ### Create Systemd service to run gitomatic + if command -v gitomatic > /dev/null; then + if [ -d /Applications ] && [ -d /System ]; then + ### macOS + logg info 'Copying `gitomatic` plist file to /Library/LaunchDaemons' + sudo cp -f "{{ .chezmoi.homeDir }}/.config/gitomatic/gitomatic.plist" /Library/LaunchDaemons/gitomatic.plist + logg info 'Running `sudo launchctl load gitomatic`' + sudo launchctl load gitomatic + logg info 'Running `sudo launchctl start gitomatic`' + sudo launchctl start gitomatic + else + ### Linux + logg info 'Copying `gitomatic` systemd unit file to /etc/systemd/system/' + sudo cp -f "{{ .chezmoi.homeDir }}/.config/gitomatic/gitomatic.service" /etc/systemd/system/gitomatic.service + logg info 'Reloading systemd daemon' + sudo systemctl daemon-reload + logg info 'Enabling and starting `gitomatic` service' + sudo systemctl enable --now gitomatic + fi + else + logg info 'Git-o-matic is not installed or it is not available in PATH' + fi +} +gitomaticSetup {{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl index d2ffe2b2..f45ec615 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl @@ -6,8 +6,11 @@ # This script pre-installs the VIM plugins defined in [`.chezmoidata.yaml`](https://github.com/megabyte-labs/install.doctor/tree/master/home/.chezmoidata.yaml) # so that VIM does not have to do anything on its first launch. -### Run the VIM plugin install routine -if command -v vim > /dev/null; then - vim +PlugInstall +qall 2>/dev/null -fi +function vimSetup() { + ### Run the VIM plugin install routine + if command -v vim > /dev/null; then + vim +PlugInstall +qall 2>/dev/null && logg success 'Successfully ran `vim +PlugInstall +qall`' || logg error 'Failed to run `vim +PlugInstall +qll`' + fi +} +vimSetup {{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_40-chrome.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_40-chrome.sh.tmpl index 4847fb64..4e213ae9 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_40-chrome.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_40-chrome.sh.tmpl @@ -28,63 +28,66 @@ {{ includeTemplate "universal/profile" }} {{ includeTemplate "universal/logg" }} -### Ensure Chrome policies directory is present -for POLICY_DIR in "/opt/google/chrome/policies" "/etc/chromium/policies" "/etc/brave/policies"; do - if [ -d "$(dirname "$POLICY_DIR")" ]; then - ### Managed policies - if [ ! -f "$POLICY_DIR/managed/policies.json" ]; then - logg info "Ensuring directory $POLICY_DIR/managed exists" - sudo mkdir -p "$POLICY_DIR/managed" - logg info "Copying ${XDG_CONFIG_HOME:-$HOME/.config}/chrome/managed.json to $POLICY_DIR/managed/policies.json" - sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/managed.json" "$POLICY_DIR/managed/policies.json" - fi +function chromeSetUp() { + ### Ensure Chrome policies directory is present + for POLICY_DIR in "/opt/google/chrome/policies" "/etc/chromium/policies" "/etc/brave/policies"; do + if [ -d "$(dirname "$POLICY_DIR")" ]; then + ### Managed policies + if [ ! -f "$POLICY_DIR/managed/policies.json" ]; then + logg info "Ensuring directory $POLICY_DIR/managed exists" + sudo mkdir -p "$POLICY_DIR/managed" + logg info "Copying ${XDG_CONFIG_HOME:-$HOME/.config}/chrome/managed.json to $POLICY_DIR/managed/policies.json" + sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/managed.json" "$POLICY_DIR/managed/policies.json" + fi - ### Recommended policies - if [ ! -f "$POLICY_DIR/recommended/policies.json" ]; then - logg info "Ensuring directory $POLICY_DIR/recommended exists" - sudo mkdir -p "$POLICY_DIR/recommended" - logg info "Copying ${XDG_CONFIG_HOME:-$HOME/.config}/chrome/recommended.json to $POLICY_DIR/recommended/policies.json" - sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/recommended.json" "$POLICY_DIR/recommended/policies.json" - fi - else - logg info "Skipping extension injection into $POLICY_DIR - create these folders prior to running to create managed configs" - fi -done - -### Add Chrome extension JSON -for EXTENSION_DIR in "/opt/google/chrome/extensions" "/etc/chromium/extensions" "/etc/brave/extensions" "$HOME/Library/Application Support/Google/Chrome/External Extensions" "$HOME/Library/Application Support/Microsoft/Edge/External Extensions" "$HOME/Library/Application Support/BraveSoftware/Brave-Browser/External Extensions"; do - ### Ensure program-type is installed - if [ -d "$(dirname "$EXTENSION_DIR")" ]; then - ### Ensure extension directory exists - if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then - if [ ! -d "$EXTENSION_DIR" ]; then - logg info "Creating directory $EXTENSION_DIR" - sudo mkdir -p "$EXTENSION_DIR" + ### Recommended policies + if [ ! -f "$POLICY_DIR/recommended/policies.json" ]; then + logg info "Ensuring directory $POLICY_DIR/recommended exists" + sudo mkdir -p "$POLICY_DIR/recommended" + logg info "Copying ${XDG_CONFIG_HOME:-$HOME/.config}/chrome/recommended.json to $POLICY_DIR/recommended/policies.json" + sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/recommended.json" "$POLICY_DIR/recommended/policies.json" fi else - if [ ! -d "$EXTENSION_DIR" ]; then - logg info "Creating directory $EXTENSION_DIR" - mkdir -p "$EXTENSION_DIR" - fi + logg info "Skipping extension injection into $POLICY_DIR - create these folders prior to running to create managed configs" fi + done - ### Add extension JSON - logg info "Adding Chrome extensions to $EXTENSION_DIR" - for EXTENSION in {{ list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do - logg info "Adding Chrome extension manifest ($EXTENSION)" - if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then - EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION" - fi - EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')" + ### Add Chrome extension JSON + for EXTENSION_DIR in "/opt/google/chrome/extensions" "/etc/chromium/extensions" "/etc/brave/extensions" "$HOME/Library/Application Support/Google/Chrome/External Extensions" "$HOME/Library/Application Support/Microsoft/Edge/External Extensions" "$HOME/Library/Application Support/BraveSoftware/Brave-Browser/External Extensions"; do + ### Ensure program-type is installed + if [ -d "$(dirname "$EXTENSION_DIR")" ]; then + ### Ensure extension directory exists if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then - sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" + if [ ! -d "$EXTENSION_DIR" ]; then + logg info "Creating directory $EXTENSION_DIR" + sudo mkdir -p "$EXTENSION_DIR" + fi else - cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" + if [ ! -d "$EXTENSION_DIR" ]; then + logg info "Creating directory $EXTENSION_DIR" + mkdir -p "$EXTENSION_DIR" + fi fi - done - else - logg info "$EXTENSION_DIR does not exist" - fi -done + + ### Add extension JSON + logg info "Adding Chrome extensions to $EXTENSION_DIR" + for EXTENSION in {{ list (.chromeExtensions | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do + logg info "Adding Chrome extension manifest ($EXTENSION)" + if ! echo "$EXTENSION" | grep 'https://chrome.google.com/webstore/detail/' > /dev/null; then + EXTENSION="https://chrome.google.com/webstore/detail/$EXTENSION" + fi + EXTENSION_ID="$(echo "$EXTENSION" | sed 's/^.*\/\([^\/]*\)$/\1/')" + if [[ "$EXTENSION_DIR" == '/opt/'* ]] || [[ "$EXTENSION_DIR" == '/etc/'* ]]; then + sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" + else + cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/chrome/extension.json" "$EXTENSION_DIR/${EXTENSION_ID}.json" + fi + done + else + logg info "$EXTENSION_DIR does not exist" + fi + done +} +chromeSetUp {{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_40-firefox.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_40-firefox.sh.tmpl index 4e59d1e6..a3f6b3ec 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_40-firefox.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_40-firefox.sh.tmpl @@ -49,278 +49,280 @@ # Firefox plugins: {{ list (.firefoxAddOns | toString | replace "[" "" | replace "]" "") | uniq | join " " }} -### Installs the Firefox Profile Connector on Linux systems (Snap / Flatpak installs are not included in this function, but instead inline below) -function installFirefoxProfileConnector() { - logg info 'Installing the Firefox Profile Connector' - if command -v apt-get > /dev/null; then - sudo apt-get install -y https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb - elif command -v dnf > /dev/null; then - sudo dnf install -y https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.rpm - elif command -v yay > /dev/null; then - yay -Ss firefox-profile-switcher-connector - else - logg warn 'apt-get, dnf, and yay were all unavailable so the Firefox Profile Connector helper executable could not be installed' - fi - -} - -### Add Firefox enterprise profile -# TODO - figure out how to do this for other installations like Flatpak and macOS and Librewolf -for FIREFOX_DIR in '/usr/lib/firefox' '/usr/lib/firefox-esr' '/etc/firefox' '/etc/firefox-esr' '/Applications/Firefox.app/Contents/Resources' '/Applications/LibreWolf.app/Contents/Resources/'; do - if [ -d "$FIREFOX_DIR" ] && [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/firefox" ] && command -v rsync > /dev/null; then - sudo rsync -artvu "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$FIREFOX_DIR" - fi -done - -### Loop through various Firefox profile locations -for SETTINGS_DIR in "$HOME/snap/firefox/common/.mozilla/firefox" "$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox" "$HOME/.var/app/io.gitlab.librewolf-community/.librewolf" "$HOME/Library/Application Support/Firefox/Profiles" "$HOME/Library/Application Support/LibreWolf/Profiles" "$HOME/.mozilla/firefox"; do - ### Determine executable to use - logg info "Processing Firefox profile location $SETTINGS_DIR" - unset FIREFOX_EXE - if [ "$SETTINGS_DIR" == "$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox" ]; then - if ! command -v org.mozilla.firefox > /dev/null || [ ! -d "$HOME/.var/app/org.mozilla.firefox" ]; then - continue +function firefoxSetup() { + ### Installs the Firefox Profile Connector on Linux systems (Snap / Flatpak installs are not included in this function, but instead inline below) + function installFirefoxProfileConnector() { + logg info 'Installing the Firefox Profile Connector' + if command -v apt-get > /dev/null; then + sudo apt-get install -y https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb + elif command -v dnf > /dev/null; then + sudo dnf install -y https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.rpm + elif command -v yay > /dev/null; then + yay -Ss firefox-profile-switcher-connector else - FIREFOX_EXE="$(which org.mozilla.firefox)" - - ### Firefox Profile Switcher - BASE_DIR="$HOME/.var/app/org.mozilla.firefox" - BIN_INSTALL_DIR="$BASE_DIR/data/firefoxprofileswitcher-install" - MANIFEST_INSTALL_DIR="$BASE_DIR/.mozilla/native-messaging-hosts" - DOWNLOAD_URL="https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb" - - ### Ensure Firefox Profile Switcher is not already installed - if [ ! -f "$BIN_INSTALL_DIR/usr/bin/ff-pswitch-connector" ] || [ ! -f "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" ]; then - ### Download profile switcher - mkdir -p "$BIN_INSTALL_DIR" - TMP_FILE="$(mktemp)" - logg info 'Downloading Firefox Profile Switch connector' - curl -sSL "$DOWNLOAD_URL" -o "$TMP_FILE" - ar p "$TMP_FILE" data.tar.xz | tar xfJ - --strip-components=2 -C "$BIN_INSTALL_DIR" usr/bin/ff-pswitch-connector - rm -f "$TMP_FILE" - - ### Create manifest - logg info 'Copying profile switcher configuration to manifest directory' - mkdir -p "$MANIFEST_INSTALL_DIR" - cat "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profile-switcher.json" | sed 's/PATH_PLACEHOLDER/'"$BIN_INSTALL_DIR"'/' > "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" - fi + logg warn 'apt-get, dnf, and yay were all unavailable so the Firefox Profile Connector helper executable could not be installed' fi - elif [ "$SETTINGS_DIR" == "$HOME/.var/app/io.gitlab.librewolf-community/.librewolf" ]; then - if ! command -v io.gitlab.librewolf-community > /dev/null || [ ! -d "$HOME/.var/app/io.gitlab.librewolf-community" ]; then - continue - else - FIREFOX_EXE="$(which io.gitlab.librewolf-community)" - fi - elif [ "$SETTINGS_DIR" == "$HOME/Library/Application Support/Firefox/Profiles" ]; then - FIREFOX_EXE="/Applications/Firefox.app/Contents/MacOS/firefox" - if [ ! -f "$FIREFOX_EXE" ] || [ ! -d /Applications ]; then - continue - else - ### Download Firefox Profile Switcher - if [ ! -d /usr/local/Cellar/firefox-profile-switcher-connector ]; then - logg info 'Ensuring Firefox Profile Switcher is installed' - brew install null-dev/firefox-profile-switcher/firefox-profile-switcher-connector - fi - ### Ensure Firefox Profile Switcher configuration is symlinked - if [ ! -d "/Library/Application Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json" ]; then - logg info 'Ensuring Firefox Profile Switcher is configured' - sudo mkdir -p "/Library/Applcation Support/Mozilla/NativeMessagingHosts" - sudo ln -sf "$(brew ls -l firefox-profile-switcher-connector | grep -i ax.nd.profile_switcher_ff.json | head -n1)" "/Library/Application Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json" - fi - fi - elif [ "$SETTINGS_DIR" == "$HOME/Library/Application Support/LibreWolf/Profiles" ]; then - FIREFOX_EXE="/Applications/LibreWolf.app/Contents/MacOS/librewolf" - if [ ! -f "$FIREFOX_EXE" ] || [ ! -d /Applications ]; then - continue - fi - elif [ "$SETTINGS_DIR" == "$HOME/snap/firefox/common/.mozilla/firefox" ]; then - FIREFOX_EXE="/snap/bin/firefox" - if [ ! -f "$FIREFOX_EXE" ] || [ ! -d "$HOME/snap/firefox" ]; then - continue - else - ### Firefox Profile Switcher - BASE_DIR="$HOME/snap/firefox/common" - BIN_INSTALL_DIR="$BASE_DIR/firefoxprofileswitcher-install" - MANIFEST_INSTALL_DIR="$BASE_DIR/.mozilla/native-messaging-hosts" - DOWNLOAD_URL="https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb" + } - ### Ensure Firefox Profile Switcher is not already installed - if [ ! -f "$BIN_INSTALL_DIR/usr/bin/ff-pswitch-connector" ] || [ ! -f "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" ]; then - ### Download profile switcher - mkdir -p "$BIN_INSTALL_DIR" - TMP_FILE="$(mktemp)" - logg info 'Downloading Firefox Profile Switch connector' - curl -sSL "$DOWNLOAD_URL" -o "$TMP_FILE" - ar p "$TMP_FILE" data.tar.xz | tar xfJ - --strip-components=2 -C "$BIN_INSTALL_DIR" usr/bin/ff-pswitch-connector - rm -f "$TMP_FILE" - - ### Create manifest - logg info 'Copying profile switcher configuration to manifest directory' - mkdir -p "$MANIFEST_INSTALL_DIR" - cat "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profile-switcher.json" | sed 's/PATH_PLACEHOLDER/'"$BIN_INSTALL_DIR"'/' > "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" - fi + ### Add Firefox enterprise profile + # TODO - figure out how to do this for other installations like Flatpak and macOS and Librewolf + for FIREFOX_DIR in '/usr/lib/firefox' '/usr/lib/firefox-esr' '/etc/firefox' '/etc/firefox-esr' '/Applications/Firefox.app/Contents/Resources' '/Applications/LibreWolf.app/Contents/Resources/'; do + if [ -d "$FIREFOX_DIR" ] && [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/firefox" ] && command -v rsync > /dev/null; then + sudo rsync -artvu "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$FIREFOX_DIR" fi - elif [ "$SETTINGS_DIR" == "$HOME/.mozilla/firefox" ]; then - if command -v firefox-esr > /dev/null; then - FIREFOX_EXE="$(which firefox-esr)" - installFirefoxProfileConnector - elif command -v firefox > /dev/null && [ "$(which firefox)" != *'snap'* ] && [ "$(which firefox)" != *'flatpak'* ] && [ ! -d /Applications ] && [ ! -d /System ]; then - # Conditional check ensures Snap / Flatpak / macOS Firefox versions do not try to install to the wrong folder - FIREFOX_EXE="$(which firefox)" - installFirefoxProfileConnector - else - if [ -d /Applications ] && [ -d /System ]; then - # Continue on macOS without logging because profiles are not stored here on macOS + done + + ### Loop through various Firefox profile locations + for SETTINGS_DIR in "$HOME/snap/firefox/common/.mozilla/firefox" "$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox" "$HOME/.var/app/io.gitlab.librewolf-community/.librewolf" "$HOME/Library/Application Support/Firefox/Profiles" "$HOME/Library/Application Support/LibreWolf/Profiles" "$HOME/.mozilla/firefox"; do + ### Determine executable to use + logg info "Processing Firefox profile location $SETTINGS_DIR" + unset FIREFOX_EXE + if [ "$SETTINGS_DIR" == "$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox" ]; then + if ! command -v org.mozilla.firefox > /dev/null || [ ! -d "$HOME/.var/app/org.mozilla.firefox" ]; then continue else - logg warn 'Unable to register Firefox executable' - logg info "Settings directory: $SETTINGS_DIR" + FIREFOX_EXE="$(which org.mozilla.firefox)" + + ### Firefox Profile Switcher + BASE_DIR="$HOME/.var/app/org.mozilla.firefox" + BIN_INSTALL_DIR="$BASE_DIR/data/firefoxprofileswitcher-install" + MANIFEST_INSTALL_DIR="$BASE_DIR/.mozilla/native-messaging-hosts" + DOWNLOAD_URL="https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb" + + ### Ensure Firefox Profile Switcher is not already installed + if [ ! -f "$BIN_INSTALL_DIR/usr/bin/ff-pswitch-connector" ] || [ ! -f "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" ]; then + ### Download profile switcher + mkdir -p "$BIN_INSTALL_DIR" + TMP_FILE="$(mktemp)" + logg info 'Downloading Firefox Profile Switch connector' + curl -sSL "$DOWNLOAD_URL" -o "$TMP_FILE" + ar p "$TMP_FILE" data.tar.xz | tar xfJ - --strip-components=2 -C "$BIN_INSTALL_DIR" usr/bin/ff-pswitch-connector + rm -f "$TMP_FILE" + + ### Create manifest + logg info 'Copying profile switcher configuration to manifest directory' + mkdir -p "$MANIFEST_INSTALL_DIR" + cat "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profile-switcher.json" | sed 's/PATH_PLACEHOLDER/'"$BIN_INSTALL_DIR"'/' > "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" + fi + fi + elif [ "$SETTINGS_DIR" == "$HOME/.var/app/io.gitlab.librewolf-community/.librewolf" ]; then + if ! command -v io.gitlab.librewolf-community > /dev/null || [ ! -d "$HOME/.var/app/io.gitlab.librewolf-community" ]; then + continue + else + FIREFOX_EXE="$(which io.gitlab.librewolf-community)" + fi + elif [ "$SETTINGS_DIR" == "$HOME/Library/Application Support/Firefox/Profiles" ]; then + FIREFOX_EXE="/Applications/Firefox.app/Contents/MacOS/firefox" + if [ ! -f "$FIREFOX_EXE" ] || [ ! -d /Applications ]; then + continue + else + ### Download Firefox Profile Switcher + if [ ! -d /usr/local/Cellar/firefox-profile-switcher-connector ]; then + logg info 'Ensuring Firefox Profile Switcher is installed' + brew install null-dev/firefox-profile-switcher/firefox-profile-switcher-connector + fi + + ### Ensure Firefox Profile Switcher configuration is symlinked + if [ ! -d "/Library/Application Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json" ]; then + logg info 'Ensuring Firefox Profile Switcher is configured' + sudo mkdir -p "/Library/Applcation Support/Mozilla/NativeMessagingHosts" + sudo ln -sf "$(brew ls -l firefox-profile-switcher-connector | grep -i ax.nd.profile_switcher_ff.json | head -n1)" "/Library/Application Support/Mozilla/NativeMessagingHosts/ax.nd.profile_switcher_ff.json" + fi + fi + elif [ "$SETTINGS_DIR" == "$HOME/Library/Application Support/LibreWolf/Profiles" ]; then + FIREFOX_EXE="/Applications/LibreWolf.app/Contents/MacOS/librewolf" + if [ ! -f "$FIREFOX_EXE" ] || [ ! -d /Applications ]; then continue fi - fi - fi - ### Initiatize Firefox default profiles - if command -v "$FIREFOX_EXE" > /dev/null; then - ### Create default profile by launching Firefox headlessly - logg info "Firefox executable set to $FIREFOX_EXE" - if [ ! -d "$SETTINGS_DIR" ]; then - logg info 'Running Firefox headlessly to generate default profiles' - timeout 8 "$FIREFOX_EXE" --headless - logg info 'Finished running Firefox headlessly' - elif [ -d /Applications ] && [ -d /System ] && [ ! -f "$SETTINGS_DIR/../installs.ini" ]; then - logg info 'Running Firefox headlessly to generate default profiles because install.ini is not at the macOS default location.' - timeout 8 "$FIREFOX_EXE" --headless - logg info 'Finished running Firefox headlessly (while fixing the missing macOS installs.ini issue)' - fi + elif [ "$SETTINGS_DIR" == "$HOME/snap/firefox/common/.mozilla/firefox" ]; then + FIREFOX_EXE="/snap/bin/firefox" + if [ ! -f "$FIREFOX_EXE" ] || [ ! -d "$HOME/snap/firefox" ]; then + continue + else + ### Firefox Profile Switcher + BASE_DIR="$HOME/snap/firefox/common" + BIN_INSTALL_DIR="$BASE_DIR/firefoxprofileswitcher-install" + MANIFEST_INSTALL_DIR="$BASE_DIR/.mozilla/native-messaging-hosts" + DOWNLOAD_URL="https://github.com/null-dev/firefox-profile-switcher-connector/releases/latest/download/linux-x64.deb" - ### Add the populated profiles.ini - logg info "Copying "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" to profile directory" - if [ -d /Applications ] && [ -d /System ]; then - # macOS - logg info "Copying ~/.local/share/firefox/profiles.ini to $SETTINGS_DIR/../profiles.ini" - cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" "$SETTINGS_DIR/../profiles.ini" - SETTINGS_INI="$SETTINGS_DIR/../installs.ini" - else - # Linux - logg info "Copying ~/.local/share/firefox/profiles.ini to $SETTINGS_DIR/profiles.ini" - cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" "$SETTINGS_DIR/profiles.ini" - SETTINGS_INI="$SETTINGS_DIR/installs.ini" - fi + ### Ensure Firefox Profile Switcher is not already installed + if [ ! -f "$BIN_INSTALL_DIR/usr/bin/ff-pswitch-connector" ] || [ ! -f "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" ]; then + ### Download profile switcher + mkdir -p "$BIN_INSTALL_DIR" + TMP_FILE="$(mktemp)" + logg info 'Downloading Firefox Profile Switch connector' + curl -sSL "$DOWNLOAD_URL" -o "$TMP_FILE" + ar p "$TMP_FILE" data.tar.xz | tar xfJ - --strip-components=2 -C "$BIN_INSTALL_DIR" usr/bin/ff-pswitch-connector + rm -f "$TMP_FILE" - ### Default profile (created by launching Firefox headlessly) - # DEFAULT_RELEASE_PROFILE="$(find "$SETTINGS_DIR" -mindepth 1 -maxdepth 1 -name "*.default-*")" - if [ -f "$SETTINGS_INI" ]; then - DEFAULT_PROFILE_PROFILE="$SETTINGS_DIR/$(cat "$SETTINGS_INI" | grep 'Default=' | sed 's/.*Profiles\///')" - logg info 'Removing previous installs.ini file' - rm -f "$SETTINGS_INI" - # DEFAULT_PROFILE="$(find "$SETTINGS_DIR" -mindepth 1 -maxdepth 1 -name "*.default" -not -name "profile.default")" - if [ -n "$DEFAULT_RELEASE_PROFILE" ]; then - logg info "Syncing $DEFAULT_RELEASE_PROFILE to $SETTINGS_DIR/profile.default" - rsync -a "$DEFAULT_RELEASE_PROFILE/" "$SETTINGS_DIR/profile.default" + ### Create manifest + logg info 'Copying profile switcher configuration to manifest directory' + mkdir -p "$MANIFEST_INSTALL_DIR" + cat "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profile-switcher.json" | sed 's/PATH_PLACEHOLDER/'"$BIN_INSTALL_DIR"'/' > "$MANIFEST_INSTALL_DIR/ax.nd.profile_switcher_ff.json" + fi fi - else - logg error "The $SETTINGS_INI file is missing" - fi - - ### Miscellaneous default profiles - for NEW_PROFILE in "automation" "development" "miscellaneous"; do - if [ ! -d "$SETTINGS_DIR/profile.${NEW_PROFILE}" ] && [ -d "$SETTINGS_DIR/profile.default" ]; then - logg info "Cloning $NEW_PROFILE from profile.default" - rsync -a "$SETTINGS_DIR/profile.default/" "$SETTINGS_DIR/profile.${NEW_PROFILE}" - rsync -a "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$SETTINGS_DIR/profile.${NEW_PROFILE}" - cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.${NEW_PROFILE}" + elif [ "$SETTINGS_DIR" == "$HOME/.mozilla/firefox" ]; then + if command -v firefox-esr > /dev/null; then + FIREFOX_EXE="$(which firefox-esr)" + installFirefoxProfileConnector + elif command -v firefox > /dev/null && [ "$(which firefox)" != *'snap'* ] && [ "$(which firefox)" != *'flatpak'* ] && [ ! -d /Applications ] && [ ! -d /System ]; then + # Conditional check ensures Snap / Flatpak / macOS Firefox versions do not try to install to the wrong folder + FIREFOX_EXE="$(which firefox)" + installFirefoxProfileConnector + else + if [ -d /Applications ] && [ -d /System ]; then + # Continue on macOS without logging because profiles are not stored here on macOS + continue + else + logg warn 'Unable to register Firefox executable' + logg info "Settings directory: $SETTINGS_DIR" + continue + fi fi - done - - ### Public git profile - if [ -d "$SETTINGS_DIR/profile.git" ]; then - logg info 'Resetting the Firefox git profile' - cd "$SETTINGS_DIR/profile.git" - git reset --hard HEAD - git clean -fxd - logg info 'Pulling latest updates to the Firefox git profile' - git pull origin master - else - logg info 'Cloning the public Firefox git profile' - cd "$SETTINGS_DIR" && git clone {{ .firefoxPublicProfile }} profile.git fi + ### Initiatize Firefox default profiles + if command -v "$FIREFOX_EXE" > /dev/null; then + ### Create default profile by launching Firefox headlessly + logg info "Firefox executable set to $FIREFOX_EXE" + if [ ! -d "$SETTINGS_DIR" ]; then + logg info 'Running Firefox headlessly to generate default profiles' + timeout 8 "$FIREFOX_EXE" --headless + logg info 'Finished running Firefox headlessly' + elif [ -d /Applications ] && [ -d /System ] && [ ! -f "$SETTINGS_DIR/../installs.ini" ]; then + logg info 'Running Firefox headlessly to generate default profiles because install.ini is not at the macOS default location.' + timeout 8 "$FIREFOX_EXE" --headless + logg info 'Finished running Firefox headlessly (while fixing the missing macOS installs.ini issue)' + fi - ### Copy user.js to profile.git profile - cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.git" + ### Add the populated profiles.ini + logg info "Copying "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" to profile directory" + if [ -d /Applications ] && [ -d /System ]; then + # macOS + logg info "Copying ~/.local/share/firefox/profiles.ini to $SETTINGS_DIR/../profiles.ini" + cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" "$SETTINGS_DIR/../profiles.ini" + SETTINGS_INI="$SETTINGS_DIR/../installs.ini" + else + # Linux + logg info "Copying ~/.local/share/firefox/profiles.ini to $SETTINGS_DIR/profiles.ini" + cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/profiles.ini" "$SETTINGS_DIR/profiles.ini" + SETTINGS_INI="$SETTINGS_DIR/installs.ini" + fi - ### Git profile w/ plugins installed (installation happens below) - if [ ! -d "$SETTINGS_DIR/profile.plugins" ]; then - logg info "Syncing $SETTINGS_DIR/profile.git to $SETTINGS_DIR/profile.plugins" - rsync -a "$SETTINGS_DIR/profile.git/" "$SETTINGS_DIR/profile.plugins" - rsync -a "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$SETTINGS_DIR/profile.plugins" - cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.plugins" - fi + ### Default profile (created by launching Firefox headlessly) + # DEFAULT_RELEASE_PROFILE="$(find "$SETTINGS_DIR" -mindepth 1 -maxdepth 1 -name "*.default-*")" + if [ -f "$SETTINGS_INI" ]; then + DEFAULT_PROFILE_PROFILE="$SETTINGS_DIR/$(cat "$SETTINGS_INI" | grep 'Default=' | sed 's/.*Profiles\///')" + logg info 'Removing previous installs.ini file' + rm -f "$SETTINGS_INI" + # DEFAULT_PROFILE="$(find "$SETTINGS_DIR" -mindepth 1 -maxdepth 1 -name "*.default" -not -name "profile.default")" + if [ -n "$DEFAULT_RELEASE_PROFILE" ]; then + logg info "Syncing $DEFAULT_RELEASE_PROFILE to $SETTINGS_DIR/profile.default" + rsync -a "$DEFAULT_RELEASE_PROFILE/" "$SETTINGS_DIR/profile.default" + fi + else + logg error "The $SETTINGS_INI file is missing" + fi - {{- if stat (joinPath .host.home ".config" "age" "chezmoi.txt") }} - ### Private hosted profile - # Deprecated in favor of using the Restic profile tasks saved in `~/.config/task/Taskfile.yml` - # if [ ! -d "$SETTINGS_DIR/profile.private" ]; then - # logg info 'Downloading the encrypted Firefox private profile' - # cd "$SETTINGS_DIR" - # curl -sSL '{ { .firefoxPrivateProfile } }' -o profile.private.tar.gz.age - # logg info 'Decrypting the Firefox private profile' - # chezmoi decrypt profile.private.tar.gz.age > profile.private.tar.gz || EXIT_DECRYPT_CODE=$? - # if [ -z "$EXIT_DECRYPT_CODE" ]; then - # rm -f profile.private.tar.gz.age - # logg info 'Decompressing the Firefox private profile' - # tar -xzf profile.private.tar.gz - # logg success 'The Firefox private profile was successfully installed' - # cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.private" - # logg info 'Copied ~/.config/firefox/user.js to profile.private profile' - # else - # logg error 'Failed to decrypt the private Firefox profile' - # fi - # fi - {{- end }} - - ### Install Firefox addons (using list declared in .chezmoidata.yaml) - for SETTINGS_PROFILE in "profile.plugins" "profile.private"; do - if [ -d "$SETTINGS_DIR/$SETTINGS_PROFILE" ]; then - for FIREFOX_PLUGIN in {{ list (.firefoxAddOns | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do - logg info "Processing the $FIREFOX_PLUGIN Firefox add-on" - PLUGIN_HTML="$(mktemp)" - curl --silent "https://addons.mozilla.org/en-US/firefox/addon/$FIREFOX_PLUGIN/" > "$PLUGIN_HTML" - PLUGIN_TMP="$(mktemp)" - cat "$PLUGIN_HTML" | htmlq '#redux-store-state' | sed 's/^//' | sed 's/<\/script>$//' > "$PLUGIN_TMP" - PLUGIN_ID="$(jq '.addons.bySlug["'"$FIREFOX_PLUGIN"'"]' "$PLUGIN_TMP")" - if [ "$PLUGIN_ID" != 'null' ]; then - PLUGIN_FILE_ID="$(jq -r '.addons.byID["'"$PLUGIN_ID"'"].guid' "$PLUGIN_TMP")" - if [ "$PLUGIN_FILE_ID" != 'null' ]; then - PLUGIN_URL="$(cat "$PLUGIN_HTML" | htmlq '.InstallButtonWrapper-download-link' --attribute href)" - PLUGIN_FILENAME="${PLUGIN_FILE_ID}.xpi" - PLUGIN_FOLDER="$(echo "$PLUGIN_FILENAME" | sed 's/.xpi$//')" - if [ ! -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FOLDER" ]; then - logg info 'Downloading add-on XPI file for '"$PLUGIN_FILENAME"' ('"$FIREFOX_PLUGIN"')' - if [ ! -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions" ]; then - mkdir -p "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions" + ### Miscellaneous default profiles + for NEW_PROFILE in "automation" "development" "miscellaneous"; do + if [ ! -d "$SETTINGS_DIR/profile.${NEW_PROFILE}" ] && [ -d "$SETTINGS_DIR/profile.default" ]; then + logg info "Cloning $NEW_PROFILE from profile.default" + rsync -a "$SETTINGS_DIR/profile.default/" "$SETTINGS_DIR/profile.${NEW_PROFILE}" + rsync -a "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$SETTINGS_DIR/profile.${NEW_PROFILE}" + cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.${NEW_PROFILE}" + fi + done + + ### Public git profile + if [ -d "$SETTINGS_DIR/profile.git" ]; then + logg info 'Resetting the Firefox git profile' + cd "$SETTINGS_DIR/profile.git" + git reset --hard HEAD + git clean -fxd + logg info 'Pulling latest updates to the Firefox git profile' + git pull origin master + else + logg info 'Cloning the public Firefox git profile' + cd "$SETTINGS_DIR" && git clone {{ .firefoxPublicProfile }} profile.git + fi + + ### Copy user.js to profile.git profile + cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.git" + + ### Git profile w/ plugins installed (installation happens below) + if [ ! -d "$SETTINGS_DIR/profile.plugins" ]; then + logg info "Syncing $SETTINGS_DIR/profile.git to $SETTINGS_DIR/profile.plugins" + rsync -a "$SETTINGS_DIR/profile.git/" "$SETTINGS_DIR/profile.plugins" + rsync -a "${XDG_DATA_HOME:-$HOME/.local/share}/firefox/" "$SETTINGS_DIR/profile.plugins" + cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.plugins" + fi + + {{- if stat (joinPath .host.home ".config" "age" "chezmoi.txt") }} + ### Private hosted profile + # Deprecated in favor of using the Restic profile tasks saved in `~/.config/task/Taskfile.yml` + # if [ ! -d "$SETTINGS_DIR/profile.private" ]; then + # logg info 'Downloading the encrypted Firefox private profile' + # cd "$SETTINGS_DIR" + # curl -sSL '{ { .firefoxPrivateProfile } }' -o profile.private.tar.gz.age + # logg info 'Decrypting the Firefox private profile' + # chezmoi decrypt profile.private.tar.gz.age > profile.private.tar.gz || EXIT_DECRYPT_CODE=$? + # if [ -z "$EXIT_DECRYPT_CODE" ]; then + # rm -f profile.private.tar.gz.age + # logg info 'Decompressing the Firefox private profile' + # tar -xzf profile.private.tar.gz + # logg success 'The Firefox private profile was successfully installed' + # cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/user.js" "$SETTINGS_DIR/profile.private" + # logg info 'Copied ~/.config/firefox/user.js to profile.private profile' + # else + # logg error 'Failed to decrypt the private Firefox profile' + # fi + # fi + {{- end }} + + ### Install Firefox addons (using list declared in .chezmoidata.yaml) + for SETTINGS_PROFILE in "profile.plugins" "profile.private"; do + if [ -d "$SETTINGS_DIR/$SETTINGS_PROFILE" ]; then + for FIREFOX_PLUGIN in {{ list (.firefoxAddOns | toString | replace "[" "" | replace "]" "") | uniq | join " " }}; do + logg info "Processing the $FIREFOX_PLUGIN Firefox add-on" + PLUGIN_HTML="$(mktemp)" + curl --silent "https://addons.mozilla.org/en-US/firefox/addon/$FIREFOX_PLUGIN/" > "$PLUGIN_HTML" + PLUGIN_TMP="$(mktemp)" + cat "$PLUGIN_HTML" | htmlq '#redux-store-state' | sed 's/^//' | sed 's/<\/script>$//' > "$PLUGIN_TMP" + PLUGIN_ID="$(jq '.addons.bySlug["'"$FIREFOX_PLUGIN"'"]' "$PLUGIN_TMP")" + if [ "$PLUGIN_ID" != 'null' ]; then + PLUGIN_FILE_ID="$(jq -r '.addons.byID["'"$PLUGIN_ID"'"].guid' "$PLUGIN_TMP")" + if [ "$PLUGIN_FILE_ID" != 'null' ]; then + PLUGIN_URL="$(cat "$PLUGIN_HTML" | htmlq '.InstallButtonWrapper-download-link' --attribute href)" + PLUGIN_FILENAME="${PLUGIN_FILE_ID}.xpi" + PLUGIN_FOLDER="$(echo "$PLUGIN_FILENAME" | sed 's/.xpi$//')" + if [ ! -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FOLDER" ]; then + logg info 'Downloading add-on XPI file for '"$PLUGIN_FILENAME"' ('"$FIREFOX_PLUGIN"')' + if [ ! -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions" ]; then + mkdir -p "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions" + fi + curl -sSL "$PLUGIN_URL" -o "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FILENAME" + # Unzipping like this causes Firefox to complain about unsigned plugins + # TODO - figure out how to headlessly enable the extensions in such a way that is compatible with Flatpak / Snap + # using the /usr/lib/firefox/distribution/policies.json works but this is not compatible with Flatpak / Snap out of the box + # it seems since they do not have access to the file system by default. Also, using the policies.json approach forces + # all Firefox profiles to use the same extensions. Ideally, we should find a way to enable the extensions scoped + # to the user profile. + # logg info 'Unzipping '"$PLUGIN_FILENAME"' ('"$FIREFOX_PLUGIN"')' + # unzip "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FILENAME" -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FOLDER" + logg success 'Installed `'"$FIREFOX_PLUGIN"'`' fi - curl -sSL "$PLUGIN_URL" -o "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FILENAME" - # Unzipping like this causes Firefox to complain about unsigned plugins - # TODO - figure out how to headlessly enable the extensions in such a way that is compatible with Flatpak / Snap - # using the /usr/lib/firefox/distribution/policies.json works but this is not compatible with Flatpak / Snap out of the box - # it seems since they do not have access to the file system by default. Also, using the policies.json approach forces - # all Firefox profiles to use the same extensions. Ideally, we should find a way to enable the extensions scoped - # to the user profile. - # logg info 'Unzipping '"$PLUGIN_FILENAME"' ('"$FIREFOX_PLUGIN"')' - # unzip "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FILENAME" -d "$SETTINGS_DIR/$SETTINGS_PROFILE/extensions/$PLUGIN_FOLDER" - logg success 'Installed `'"$FIREFOX_PLUGIN"'`' + else + logg warn 'A null Firefox add-on filename was detected for `'"$FIREFOX_PLUGIN"'`' fi else - logg warn 'A null Firefox add-on filename was detected for `'"$FIREFOX_PLUGIN"'`' + logg warn 'A null Firefox add-on ID was detected for `'"$FIREFOX_PLUGIN"'`' fi - else - logg warn 'A null Firefox add-on ID was detected for `'"$FIREFOX_PLUGIN"'`' - fi - done - fi - done - fi -done - + done + fi + done + fi + done +} +firefoxSetup {{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_41-vagrant-vmware-utility.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_41-vagrant-vmware-utility.sh.tmpl deleted file mode 100644 index f35f5b85..00000000 --- a/home/.chezmoiscripts/universal/run_onchange_after_41-vagrant-vmware-utility.sh.tmpl +++ /dev/null @@ -1,44 +0,0 @@ -{{- if ne .host.distro.family "windows" -}} -#!/usr/bin/env bash -# @file Vagrant VMWare Utility -# @brief Installs the `vagrant-vmware-utility` if both Vagrant and VMWare are installed -# @description -# This script first checks if `vagrant`, `vmware`, and `vagrant-vmware-utility` are available in the `PATH`. If they are present, then the script -# configures the [`vagrant-vmware-utility`](https://developer.hashicorp.com/vagrant/docs/providers/vmware/vagrant-vmware-utility) by generating the required security certificates and enabling the service. -# This system package enables the capability of controlling both VMWare Workstation and VMWare Fusion with Vagrant. -# -# Since this script runs only when `vagrant`, `vmware`, and `vagrant-vmware-utility` are in the `PATH`, this means that it will run -# when you use an installation template that includes all three pieces of software in the software list defined in -# `home/.chezmoidata.yaml`. -# -# ## Links -# -# * [Vagrant VMWare Utility on GitHub](https://github.com/hashicorp/vagrant-vmware-desktop) -# * [`home/.chezmoidata.yaml`](https://github.com/megabyte-labs/install.doctor/blob/master/home/.chezmoidata.yaml) - -{{ includeTemplate "universal/profile" }} -{{ includeTemplate "universal/logg" }} - -# @description Only run logic if both Vagrant and VMWare are installed -if command -v vagrant > /dev/null && command -v vmware-id > /dev/null; then - # @description 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 info 'Vagrant is not installed so the Vagrant plugins will not be installed' - logg info 'Vagrant or VMWare is not installed so the Vagrant VMWare utility will not be configured' -fi - -{{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.sh.tmpl deleted file mode 100644 index 5be97efa..00000000 --- a/home/.chezmoiscripts/universal/run_onchange_after_44-vmware-install.sh.tmpl +++ /dev/null @@ -1,76 +0,0 @@ -{{- if eq .host.distro.family "linux" -}} -{{- $softwareGroup := nospace (cat "_" .host.softwareGroup) -}} -{{- $softwareList := list (index .softwareGroups $softwareGroup | toString | replace "[" "" | replace "]" "") | uniq | join " " -}} -{{- if (contains " vmware" $softwareList) -}} -#!/usr/bin/env bash -# @file Linux VMWare Workstation Install -# @brief Installs VMWare Workstation Pro on Linux devices, applies a "publicly-retrieved" license key (see disclaimer), and automatically accepts the terms and conditions -# @description -# This script ensures the user included `vmware` in their software installation list. It then checks for presence of the `vmware` utility. If it is not present, then the script: -# -# 1. Downloads the [VMWare Workstation Pro](https://www.vmware.com/content/vmware/vmware-published-sites/us/products/workstation-pro.html.html) Linux installer -# 2. Installs VMWare Workstation Pro -# 3. Passes options to the installation script that automatically apply a publicly retrived license key and accept the Terms & Conditions -# -# **DISCLAIMER:** If you plan on using VMWare Workstation for anything but evaluation purposes, then we highly suggest purchasing a copy -# of VMWare Workstation. The "publicly-retrived" license keys are scattered throughout GitHub and we are not exactly -# sure why they work. You can pass in your own key by utilizing the `VMWARE_WORKSTATION_LICENSE_KEY` environment variable. More details on -# using environment variables or repository-housed encrypted secrets can be found in our [Secrets documentation](https://install.doctor/docs/customization/secrets). -# -# ## VMWare on macOS -# -# This script only installs VMWare Workstation on Linux. The macOS-variant titled VMWare Fusion can be installed using a Homebrew -# cask so a "work-around" script does not have to be used. -# -# ## VMWare vs. Parallels vs. VirtualBox vs. KVM vs. Hyper-V -# -# There are a handful of VM virtualization providers you can choose from. VMWare is a nice compromise between OS compatibility and performance. -# Parallels, on the hand, might be better for macOS since it is designed specifically for macOS. Finally, VirtualBox is a truly free, -# open-source option that does not come with the same optimizations that VMWare and Parallels provide. -# -# Other virtualization options include KVM (Linux / macOS) and Hyper-V (Windows). These options are better used for headless -# systems. -# -# ## Links -# -# * [VMWare Workstation homepage](https://www.vmware.com/content/vmware/vmware-published-sites/us/products/workstation-pro.html.html) - - -{{- $secretKey := "" -}} -{{- if (stat (joinPath (.chezmoi.sourceDir ".chezmoitemplates" "secrets" "VMWARE_WORKSTATION_LICENSE_KEY"))) -}} -{{- $secretKey = (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (includeTemplate "secrets/VMWARE_WORKSTATION_LICENSE_KEY" | decrypt | trim)) -}} -{{- 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 -}} -{{ end -}} diff --git a/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl index 55f6bf5c..e0816b07 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl @@ -1,90 +1,202 @@ -{{- if eq .host.distro.family "linux" -}} #!/usr/bin/env bash +# @file Linux VMWare Workstation Install +# @brief Installs VMWare Workstation Pro on Linux devices, applies a "publicly-retrieved" license key (see disclaimer), and automatically accepts the terms and conditions +# @description +# This script ensures the user included `vmware` in their software installation list. It then checks for presence of the `vmware` utility. If it is not present, then the script: +# +# 1. Downloads the [VMWare Workstation Pro](https://www.vmware.com/content/vmware/vmware-published-sites/us/products/workstation-pro.html.html) Linux installer +# 2. Installs VMWare Workstation Pro +# 3. Passes options to the installation script that automatically apply a publicly retrived license key and accept the Terms & Conditions +# +# **DISCLAIMER:** If you plan on using VMWare Workstation for anything but evaluation purposes, then we highly suggest purchasing a copy +# of VMWare Workstation. The "publicly-retrived" license keys are scattered throughout GitHub and we are not exactly +# sure why they work. You can pass in your own key by utilizing the `VMWARE_WORKSTATION_LICENSE_KEY` environment variable. More details on +# using environment variables or repository-housed encrypted secrets can be found in our [Secrets documentation](https://install.doctor/docs/customization/secrets). +# +# ## VMWare on macOS +# +# This script only installs VMWare Workstation on Linux. The macOS-variant titled VMWare Fusion can be installed using a Homebrew +# cask so a "work-around" script does not have to be used. +# +# ## VMWare vs. Parallels vs. VirtualBox vs. KVM vs. Hyper-V +# +# There are a handful of VM virtualization providers you can choose from. VMWare is a nice compromise between OS compatibility and performance. +# Parallels, on the hand, might be better for macOS since it is designed specifically for macOS. Finally, VirtualBox is a truly free, +# open-source option that does not come with the same optimizations that VMWare and Parallels provide. +# +# Other virtualization options include KVM (Linux / macOS) and Hyper-V (Windows). These options are better used for headless +# systems. +# +# ## Links +# +# * [VMWare Workstation homepage](https://www.vmware.com/content/vmware/vmware-published-sites/us/products/workstation-pro.html.html) +# @file Vagrant VMWare Utility +# @brief Installs the `vagrant-vmware-utility` if both Vagrant and VMWare are installed +# @description +# This script first checks if `vagrant`, `vmware`, and `vagrant-vmware-utility` are available in the `PATH`. If they are present, then the script +# configures the [`vagrant-vmware-utility`](https://developer.hashicorp.com/vagrant/docs/providers/vmware/vagrant-vmware-utility) by generating the required security certificates and enabling the service. +# This system package enables the capability of controlling both VMWare Workstation and VMWare Fusion with Vagrant. +# +# Since this script runs only when `vagrant`, `vmware`, and `vagrant-vmware-utility` are in the `PATH`, this means that it will run +# when you use an installation template that includes all three pieces of software in the software list defined in +# `home/.chezmoidata.yaml`. +# +# ## Links +# +# * [Vagrant VMWare Utility on GitHub](https://github.com/hashicorp/vagrant-vmware-desktop) +# * [`home/.chezmoidata.yaml`](https://github.com/megabyte-labs/install.doctor/blob/master/home/.chezmoidata.yaml) # @file VMWare Configuration # @brief Patches VMWare to leverage kernel optimizations, support macOS, and work harmoniously with Secure Boot. It also enables optional services such as the USB service. # @description # This script performs various VMWare optimizations that allow VMWare to work optimally with all features enabled. +{{- $softwareGroup := nospace (cat "_" .host.softwareGroup) -}} +{{- $softwareList := list (index .softwareGroups $softwareGroup | toString | replace "[" "" | replace "]" "") | uniq | join " " -}} + +{{- $secretKey := "" -}} +{{- if (stat (joinPath (.chezmoi.sourceDir ".chezmoitemplates" "secrets" "VMWARE_WORKSTATION_LICENSE_KEY"))) -}} +{{- $secretKey = (default "4C21U-2KK9Q-M8130-4V2QH-CF810" (includeTemplate "secrets/VMWARE_WORKSTATION_LICENSE_KEY" | decrypt | trim)) -}} +{{- 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" }} {{ includeTemplate "universal/logg" }} -### Run logic if VMware is installed -if command -v vmware > /dev/null; then - ### Build kernel modules if they are not present - if [ ! -f "/lib/modules/$(uname -r)/misc/vmmon.ko" ] || [ ! -f "/lib/modules/$(uname -r)/misc/vmnet.ko" ]; then - ### Build VMWare host modules - logg info 'Building VMware host modules' - if sudo vmware-modconfig --console --install-all; then - logg success 'Built VMWare host modules successfully with `sudo vmware-modconfig --console --install-all`' - else - logg info 'Acquiring VMware version from CLI' - VMW_VERSION="$(vmware --version | cut -f 3 -d' ')" - mkdir -p /tmp/vmw_patch - cd /tmp/vmw_patch - logg info 'Downloading VMware host module patches' - curl -sSL "https://github.com/mkubecek/vmware-host-modules/archive/workstation-$VMW_VERSION.tar.gz" -o /tmp/vmw_patch/workstation.tar.gz - tar -xzf /tmp/vmw_patch/workstation.tar.gz - cd vmware* - logg info 'Running `sudo make` and `sudo make install`' - sudo make - sudo make install - logg success 'Successfully configured VMware host module patches' - fi +function vmwareSetup() { + ### Run on Linux only + if [ -f /etc/os-release ]; then + ### Run if vmware is to be installed + {{- if (contains " vmware" $softwareList) -}} + ### 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" - ### Sign VMware host modules if Secure Boot is enabled - if [ -f /sys/firmware/efi ]; then - logg info 'Signing host modules' - mkdir -p /tmp/vmware - cd /tmp/vmware - openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VMware/" - "/usr/src/linux-headers-$(uname -r)/scripts/sign-file" sha256 ./MOK.priv ./MOK.der "$(modinfo -n vmmon)" - "/usr/src/linux-headers-$(uname -r)/scripts/sign-file" sha256 ./MOK.priv ./MOK.der "$(modinfo -n vmnet)" - echo '' | mokutil --import MOK.der - logg success 'Successfully signed VMware host modules. Reboot the host before powering on VMs' - fi - - ### Patch VMware with Unlocker - if [ ! -f /usr/lib/vmware/isoimages/darwin.iso ]; then - logg info 'Acquiring VMware Unlocker latest release version' - UNLOCKER_URL="$(curl -sSL 'https://api.github.com/repos/DrDonk/unlocker/releases/latest' | jq -r '.assets[0].browser_download_url')" - mkdir -p /tmp/vmware-unlocker - cd /tmp/vmware-unlocker - logg info 'Downloading unlocker.zip' - curl -sSL "$UNLOCKER_URL" -o unlocker.zip - unzip unlocker.zip - cd linux - logg info 'Running the unlocker' - echo "y" | sudo ./unlock - logg success 'Successfully unlocked VMware for macOS compatibility' - else - logg info '/usr/lib/vmware/isoimages/darwin.iso is already present on the system so VMware macOS unlocking will not be performed' - fi - - if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then - ### Start / enable VMWare service - logg info 'Ensuring `vmware.service` is enabled and running' - sudo systemctl enable vmware.service - sudo systemctl restart vmware.service - - ### Start / enable VMWare Workstation Server service - logg info 'Ensuring `vmware-workstation-server.service` is enabled and running' - sudo systemctl enable vmware-workstation-server.service - sudo systemctl restart vmware-workstation-server.service - - ### Start / enable VMWare USB Arbitrator service - if command -v vmware-usbarbitrator.service > /dev/null; then - logg info 'Ensuring `vmware-usbarbitrator.service` is enabled and running' - sudo systemctl enable vmware-usbarbitrator.service - sudo systemctl restart vmware-usbarbitrator.service + ### 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 warn '`vmware-usbarbitrator` does not exist in the PATH' + 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 - else - logg info 'VMware host modules are present' - fi -else - logg warn 'VMware Workstation is not installed so the VMware Unlocker will not be installed' -fi + {{ end -}} -{{ end -}} + ### Run logic if VMware is installed + if command -v vmware > /dev/null; then + ### Build kernel modules if they are not present + if [ ! -f "/lib/modules/$(uname -r)/misc/vmmon.ko" ] || [ ! -f "/lib/modules/$(uname -r)/misc/vmnet.ko" ]; then + ### Build VMWare host modules + logg info 'Building VMware host modules' + if sudo vmware-modconfig --console --install-all; then + logg success 'Built VMWare host modules successfully with `sudo vmware-modconfig --console --install-all`' + else + logg info 'Acquiring VMware version from CLI' + VMW_VERSION="$(vmware --version | cut -f 3 -d' ')" + mkdir -p /tmp/vmw_patch + cd /tmp/vmw_patch + logg info 'Downloading VMware host module patches' + curl -sSL "https://github.com/mkubecek/vmware-host-modules/archive/workstation-$VMW_VERSION.tar.gz" -o /tmp/vmw_patch/workstation.tar.gz + tar -xzf /tmp/vmw_patch/workstation.tar.gz + cd vmware* + logg info 'Running `sudo make` and `sudo make install`' + sudo make + sudo make install + logg success 'Successfully configured VMware host module patches' + fi + + ### Sign VMware host modules if Secure Boot is enabled + if [ -f /sys/firmware/efi ]; then + logg info 'Signing host modules' + mkdir -p /tmp/vmware + cd /tmp/vmware + openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VMware/" + "/usr/src/linux-headers-$(uname -r)/scripts/sign-file" sha256 ./MOK.priv ./MOK.der "$(modinfo -n vmmon)" + "/usr/src/linux-headers-$(uname -r)/scripts/sign-file" sha256 ./MOK.priv ./MOK.der "$(modinfo -n vmnet)" + echo '' | mokutil --import MOK.der + logg success 'Successfully signed VMware host modules. Reboot the host before powering on VMs' + fi + + ### Patch VMware with Unlocker + if [ ! -f /usr/lib/vmware/isoimages/darwin.iso ]; then + logg info 'Acquiring VMware Unlocker latest release version' + UNLOCKER_URL="$(curl -sSL 'https://api.github.com/repos/DrDonk/unlocker/releases/latest' | jq -r '.assets[0].browser_download_url')" + mkdir -p /tmp/vmware-unlocker + cd /tmp/vmware-unlocker + logg info 'Downloading unlocker.zip' + curl -sSL "$UNLOCKER_URL" -o unlocker.zip + unzip unlocker.zip + cd linux + logg info 'Running the unlocker' + echo "y" | sudo ./unlock + logg success 'Successfully unlocked VMware for macOS compatibility' + else + logg info '/usr/lib/vmware/isoimages/darwin.iso is already present on the system so VMware macOS unlocking will not be performed' + fi + + if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]]; then + ### Start / enable VMWare service + logg info 'Ensuring `vmware.service` is enabled and running' + sudo systemctl enable vmware.service + sudo systemctl restart vmware.service + + ### Start / enable VMWare Workstation Server service + logg info 'Ensuring `vmware-workstation-server.service` is enabled and running' + sudo systemctl enable vmware-workstation-server.service + sudo systemctl restart vmware-workstation-server.service + + ### Start / enable VMWare USB Arbitrator service + if command -v vmware-usbarbitrator.service > /dev/null; then + logg info 'Ensuring `vmware-usbarbitrator.service` is enabled and running' + sudo systemctl enable vmware-usbarbitrator.service + sudo systemctl restart vmware-usbarbitrator.service + else + logg warn '`vmware-usbarbitrator` does not exist in the PATH' + fi + fi + else + logg info 'VMware host modules are present' + fi + else + logg warn 'VMware Workstation is not installed so the VMware Unlocker will not be installed' + fi + fi + + # @description Only run logic if both Vagrant and VMWare are installed + if command -v vagrant > /dev/null && command -v vmware-id > /dev/null; then + # @description 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 info 'Vagrant is not installed so the Vagrant plugins will not be installed' + logg info 'Vagrant or VMWare is not installed so the Vagrant VMWare utility will not be configured' + fi +} + +vmwareSetup diff --git a/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl index b8b4bdf8..edcf0790 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl @@ -21,19 +21,33 @@ if command -v powerline > /dev/null && [ -f "$HOME/.bashrc" ]; then # logg info 'Running `source ~/.bashrc`' # source ~/.bashrc # logg success 'Imported the `~/.bashrc` profile' - if command -v bash-it > /dev/null; then - if [ -n "$BASH_IT" ]; then - cd "$BASH_IT" || logg warn "The $BASH_IT directory does not exist" - logg info 'Enabling bash-it completions' - yes | bash-it enable completion defaults dirs docker docker-compose export git makefile ng npm ssh system vagrant - logg info 'Enabling bash-it plugins' - yes | bash-it enable plugin base blesh browser cht-sh dirs gitstatus powerline sudo xterm - logg info 'Finished enabling bash-it functions' - else - logg warn 'The BASH_IT variable needs to be defined' + if [ -d "$BASH_IT" ]; then + ### Ensure bash-it is installed + if ! command -v bash-it > /dev/null; then + logg info 'Installing `bash-it` since it is not available yet as a command' + bash "$BASH_IT/install.sh" --silent --no-modify-config fi + + ### Ensure completions are enabled + cd "$BASH_IT/enabled" + logg info 'Enabling bash-it completions' + # TODO: Move these plugins to the .chezmoidata.yaml + for COMPLETION in defaults dirs docker docker-compose export git makefile ng npm ssh system vagrant; do + if ! ls "$BASH_IT/enabled" | grep "$COMPLETION" > /dev/null; then + echo y | bash-it enable completion dirs > /dev/null && logg info "Enabled the bash-it $COMPLETION completion plugin" || logg error "Failed to install the $COMPLETION bash-it completion plugin" + fi + done + + ### Ensure plugins are enabled + logg info 'Enabling bash-it plugins' + # TODO: Move these plugins to the .chezmoidata.yaml + for PLUGIN in base blesh browser cht-sh dirs gitstatus powerline sudo xterm; do + if ls "$BASH_IT/enabled" | grep "$PLUGIN" > /dev/null; then + echo y | bash-it enable plugin "$PLUGIN" > /dev/null && logg info "Enabled the bash-it $PLUGIN plugin" || logg error "Failed to install the $PLUGIN bash-it plugin" + fi + done else - logg warn '`bash-it` is not available' + logg warn 'The path specified by BASH_IT does not exist yet' fi else if ! command -v powerline > /dev/null; then diff --git a/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl index cf05db1c..b6e49f71 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_97-cloudflare.sh.tmpl @@ -248,7 +248,7 @@ if command -v cloudflared > /dev/null && [ -d "$HOME/.local/etc/cloudflared" ]; fi TUNNEL_ID="$(cloudflared tunnel list | grep "host-{{ .host.hostname }}" | sed 's/ .*//')" logg info "Tunnel ID: $TUNNEL_ID" - if [ -f "/usr/local/etc/cloudflared/${TUNNEL_ID}.json" ] + if [ -f "/usr/local/etc/cloudflared/${TUNNEL_ID}.json" ]; then logg info 'Symlinking tunnel configuration to /usr/local/etc/cloudflared/credentials.json' rm -f /usr/local/etc/cloudflared/credentials.json sudo ln -s "/usr/local/etc/cloudflared/${TUNNEL_ID}.json" /usr/local/etc/cloudflared/credentials.json diff --git a/home/.chezmoiscripts/universal/run_onchange_before_10-install-darwin-dependencies.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_before_10-install-darwin-dependencies.sh.tmpl index 4ab59997..02a519c6 100644 --- a/home/.chezmoiscripts/universal/run_onchange_before_10-install-darwin-dependencies.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_before_10-install-darwin-dependencies.sh.tmpl @@ -19,6 +19,16 @@ if command -v brew > /dev/null; then brew bundle --verbose --no-lock --file=/dev/stdin < /dev/null && [ -f "$BASH_IT/bash_it.sh" ]; then . "$BASH_IT/bash_it.sh" diff --git a/home/dot_local/megabyte-labs/img/icon-jest.png b/home/dot_local/assets/icon-jest.png similarity index 100% rename from home/dot_local/megabyte-labs/img/icon-jest.png rename to home/dot_local/assets/icon-jest.png diff --git a/home/dot_local/share/vscode/package.json b/home/dot_local/share/vscode/package.json index ab963cff..7834f566 100644 --- a/home/dot_local/share/vscode/package.json +++ b/home/dot_local/share/vscode/package.json @@ -78,7 +78,7 @@ "jest-html-reporters", { "filename": "index.html", - "logoImgPath": "~/.local/megabyte-labs/assets/icon-jest.png", + "logoImgPath": "~/.local/assets/icon-jest.png", "openReport": true, "pageTitle": "Code Coverage Report", "publicPath": "./coverage" diff --git a/home/dot_zshrc b/home/dot_zshrc index c11b4a2a..0a78be01 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -1,11 +1,5 @@ # shellcheck disable=SC1090,SC1091,SC2034,SC2154,SC2296 -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - ### Language / Fonts export LANG="en_US" export LC_ALL="en_US.UTF-8" @@ -19,6 +13,12 @@ if [ -f "$HOME/.config/shell/profile.sh" ]; then . "$XDG_CONFIG_HOME/shell/profile.sh" fi +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + ### Misc. export HISTFILE="$XDG_STATE_HOME/zsh/history" export ZLE_RPROMPT_INDENT=0 diff --git a/software.yml b/software.yml index b6c9d663..45aef96d 100644 --- a/software.yml +++ b/software.yml @@ -10028,16 +10028,17 @@ softwarePlugins: docker: cmd: bash -c 'if ! docker extension list | grep "{PLUGIN}" > /dev/null; then echo y | docker extension install "{PLUGIN}"; fi' plugins: - - docker/disk-usage-extension - - docker/logs-explorer-extension + - ambassador/telepresence-docker-extension:1.0.13 + - docker/disk-usage-extension:0.2.7 + - docker/logs-explorer-extension:0.2.3 - docker/resource-usage-extension - - docker/volumes-backup-extension:main - - drone/drone-ci-docker-extension - - okteto/docker-desktop-extension - - portainer/portainer-docker-extension + - docker/volumes-backup-extension:main:1.1.4 + - drone/drone-ci-docker-extension:0.2.0 + - okteto/docker-desktop-extension:0.3.3 + - portainer/portainer-docker-extension:2.18.4 - redhatdeveloper/openshift-dd-ext - snyk/snyk-docker-desktop-extension - - tailscale/docker-extension + - tailscale/docker-extension:1.0.0 dockerImages: cmd: null plugins: