From 93d64340c15e53b32792dcfccdd94da497741920 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Wed, 6 Dec 2023 07:44:44 +0000 Subject: [PATCH] Fixes gsed error --- .../universal/run_before_01-macos-privileges.sh.tmpl | 10 ++++++---- .../universal/run_before_01-system-homebrew.sh.tmpl | 10 ++++++---- .../run_onchange_after_03-macos-headless.sh.tmpl | 6 ++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_before_01-macos-privileges.sh.tmpl b/home/.chezmoiscripts/universal/run_before_01-macos-privileges.sh.tmpl index 7657c9e1..2d70705c 100644 --- a/home/.chezmoiscripts/universal/run_before_01-macos-privileges.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_01-macos-privileges.sh.tmpl @@ -36,10 +36,12 @@ ensureFullDiskAccess() { ensureFullDiskAccess else logg success 'Current terminal has full disk access' - if command -v gsed > /dev/null; then - sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" - else - sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + if [ -f "$HOME/.zshrc" ]; then + if command -v gsed > /dev/null; then + sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + else + sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + fi fi fi fi diff --git a/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl b/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl index 86afb0f0..452c11af 100644 --- a/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl @@ -46,10 +46,12 @@ if [ -d /Applications ] && [ -d /Library ] && [ -z "$NO_RESTART" ]; then logg info 'Reboot required - shutting down immediately' && sudo shutdown -r now # TODO - Automatically log in after reboot fi - if command -v gsed > /dev/null; then - sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" - else - sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + if [ -f "$HOME/.zshrc" ]; then + if command -v gsed > /dev/null; then + sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + else + sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + fi fi fi diff --git a/home/.chezmoiscripts/universal/run_onchange_after_03-macos-headless.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_03-macos-headless.sh.tmpl index c4239d3b..c56ce343 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_03-macos-headless.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_03-macos-headless.sh.tmpl @@ -18,8 +18,10 @@ if [ -n "$HEADLESS_INSTALL" ] && [ -z "$SSH_CONNECTION" ] && [ -d /System ] && [ # Source: https://developers.cloudflare.com/cloudflare-one/static/documentation/connections/Cloudflare_CA.pem ### Ensure certificate installed on macOS logg info '**macOS Manual Security Permission** Requesting security authorization for Cloudflare trusted certificate' - sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "$HOME/.local/etc/ssl/cloudflare/Cloudflare_CA.crt" - + CRT_TMP="$(mktemp)" + curl -sSL https://developers.cloudflare.com/cloudflare-one/static/documentation/connections/Cloudflare_CA.crt > "$CRT_TMP" + sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "$CRT_TMP" && logg success 'Successfully imported Cloudflare_CA.crt into System.keychain' + rm -f "$CRT_TMP" # Source: https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh # To disable, run: sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off # Only enable when computer is not a corporate / work computer