diff --git a/home/.chezmoiscripts/universal/run_after_01-pre-install.sh.tmpl b/home/.chezmoiscripts/universal/run_after_01-pre-install.sh.tmpl index cee09ad9..d75a771d 100644 --- a/home/.chezmoiscripts/universal/run_after_01-pre-install.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_after_01-pre-install.sh.tmpl @@ -445,28 +445,6 @@ emscriptenInstall() { fi } -# @description -# Adds auto-update feature to macOS that automatically downloads and installs updates. Also enables -# an auto-update feature for Homebrew on macOS. -enableAutoUpdateDarwin() { - if [ -d /Applications ] && [ -d /System ]; then - ### Enable automated system updates on macOS - if [ -f "$HOME/Library/LaunchDaemons/com.apple.automatedupdates.plist" ] && [ ! -f "/Library/LaunchDaemons/com.apple.automatedupdates.plist" ]; then - logg info 'Configuring macOS to automatically apply system updates' - sudo mkdir -p /Library/LaunchDaemons - sudo cp -f "$HOME/Library/LaunchDaemons/com.apple.automatedupdates.plist" "/Library/LaunchDaemons/com.apple.automatedupdates.plist" - logg info 'Loading /Library/LaunchDaemons/com.apple.automatedupdates.plist' - sudo launchctl load "/Library/LaunchDaemons/com.apple.automatedupdates.plist" && logg success 'launchctl load successful' - fi - - ### Enable Homebrew auto-update service - if brew autoupdate status | grep 'Autoupdate is not configured.' > /dev/null; then - logg info 'Enabling Homebrew auto-update service (every 24 hours)' - brew autoupdate start --cleanup --greedy --upgrade - fi - fi -} - ensurePipUpdated() { ### python3.10 pip update if command -v python3.10 > /dev/null; then @@ -1012,7 +990,6 @@ if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then dconfSettings decryptSSHKeys emscriptenInstall - enableAutoUpdateDarwin ensureQtStyleOverride ensurePipUpdated ensureSystemGemUpdated @@ -1039,7 +1016,6 @@ else dconfSettings & decryptSSHKeys & emscriptenInstall & - enableAutoUpdateDarwin & ensureQtStyleOverride & ensurePipUpdated & ensureSystemGemUpdated & diff --git a/home/.chezmoiscripts/universal/run_after_15-chezmoi-system.sh.tmpl b/home/.chezmoiscripts/universal/run_after_15-chezmoi-system.sh.tmpl new file mode 100644 index 00000000..c96498ef --- /dev/null +++ b/home/.chezmoiscripts/universal/run_after_15-chezmoi-system.sh.tmpl @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# @file Chezmoi System Apply +# @brief Applies the Chezmoi files defined in the `system/` directory of the Install Doctor project to the root of the system (for locations outside the user's home directory) +# @description +# This script applies the `system/` Chezmoi directory to the root of the system. + +logg info 'TODO - Implement system configuration apply' \ No newline at end of file diff --git a/home/.chezmoiscripts/universal/run_after_20-post-install.sh.tmpl b/home/.chezmoiscripts/universal/run_after_20-post-install.sh.tmpl index dbe310f5..5b54843e 100644 --- a/home/.chezmoiscripts/universal/run_after_20-post-install.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_after_20-post-install.sh.tmpl @@ -368,11 +368,39 @@ ubuntuDashToDockFix() { fi } +# @description +# Adds auto-update feature to macOS that automatically downloads and installs updates. Also enables +# an auto-update feature for Homebrew on macOS. +enableAutoUpdateDarwin() { + if [ -d /Applications ] && [ -d /System ]; then + ### Enable automated system updates on macOS + if [ -f "/Library/LaunchDaemons/com.apple.automatedupdates.plist" ]; then + logg info 'Configuring macOS to automatically apply system updates' + sudo mkdir -p /Library/LaunchDaemons + logg info 'Loading /Library/LaunchDaemons/com.apple.automatedupdates.plist' + if sudo launchctl list | grep 'com.apple.automatedupdates' > /dev/null; then + logg info 'Unloading previous com.apple.automatedupdates configuration' + sudo launchctl unload /Library/LaunchDaemons/clamdscan.plist + fi + sudo launchctl load -w /Library/LaunchDaemons/com.apple.automatedupdates.plist + else + logg warn '/Library/LaunchDaemons/com.apple.automatedupdates.plist is missing!' + fi + + ### Enable Homebrew auto-update service + if brew autoupdate status | grep 'Autoupdate is not configured.' > /dev/null; then + logg info 'Enabling Homebrew auto-update service (every 24 hours)' + brew autoupdate start --cleanup --greedy --upgrade + fi + fi +} + if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then logg info 'The DEBUG or DEBUG_MODE environment variable is set so the post-install tasks will be run synchronously' bashItPlugins candyIconTweaks configureVNC + enableAutoUpdateDarwin moveGnomeAppsToShare preloadZsh removeShortcutsLinux @@ -383,6 +411,7 @@ else bashItPlugins & candyIconTweaks & configureVNC & + enableAutoUpdateDarwin & moveGnomeAppsToShare & preloadZsh & removeShortcutsLinux & diff --git a/home/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl b/home/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl new file mode 100644 index 00000000..dcf77282 --- /dev/null +++ b/home/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl @@ -0,0 +1,29 @@ +{{- if (lookPath "cloudflared") -}} + + + + + Label + com.cloudflare.cloudflared + ProgramArguments + + {{ lookPath "cloudflared" }} + tunnel + run + + RunAtLoad + + StandardOutPath + /Library/Logs/com.cloudflare.cloudflared.out.log + StandardErrorPath + /Library/Logs/com.cloudflare.cloudflared.err.log + KeepAlive + + SuccessfulExit + + + ThrottleInterval + 5 + + +{{- end -}} diff --git a/home/dot_local/bin/post-installx/executable_post-cloudflared.sh b/home/dot_local/bin/post-installx/executable_post-cloudflared.sh index 84262bab..89f7ac0c 100644 --- a/home/dot_local/bin/post-installx/executable_post-cloudflared.sh +++ b/home/dot_local/bin/post-installx/executable_post-cloudflared.sh @@ -65,8 +65,13 @@ if command -v cloudflared > /dev/null; then logg info 'Running sudo cloudflared service install' sudo cloudflared service install fi + sudo cp -f "$HOME/Library/LaunchDaemons/com.cloudflare.cloudflared.plist" /Library/LaunchDaemons/com.cloudflare.cloudflared.plist logg info 'Ensuring cloudflared service is started' - sudo launchctl start com.cloudflare.cloudflared + if sudo launchctl list | grep 'com.cloudflare.cloudflared' > /dev/null; then + logg info 'Unloading previous com.cloudflare.cloudflared configuration' + sudo launchctl unload /Library/LaunchDaemons/com.cloudflare.cloudflared.plist + fi + sudo launchctl load -w /Library/LaunchDaemons/com.cloudflare.cloudflared.plist elif [ -f /etc/os-release ]; then ### Linux if systemctl --all --type service | grep -q "cloudflared" > /dev/null; then diff --git a/system/.chezmoiignore b/system/.chezmoiignore new file mode 100644 index 00000000..cd25a0cd --- /dev/null +++ b/system/.chezmoiignore @@ -0,0 +1,3 @@ +{{- if ne .host.distro.family "darwin" }} +Library +{{- end }} \ No newline at end of file diff --git a/home/Library/LaunchDaemons/com.apple.automatedupdates.plist b/system/Library/LaunchDaemons/com.apple.automatedupdates.plist similarity index 98% rename from home/Library/LaunchDaemons/com.apple.automatedupdates.plist rename to system/Library/LaunchDaemons/com.apple.automatedupdates.plist index f634d281..b63023d9 100644 --- a/home/Library/LaunchDaemons/com.apple.automatedupdates.plist +++ b/system/Library/LaunchDaemons/com.apple.automatedupdates.plist @@ -19,4 +19,4 @@ StandardOutPath /var/log/ccom.apple.automatedupdates.plist.debug.log - \ No newline at end of file + diff --git a/system/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl b/system/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl new file mode 100644 index 00000000..dcf77282 --- /dev/null +++ b/system/Library/LaunchDaemons/com.cloudflare.cloudflared.plist.tmpl @@ -0,0 +1,29 @@ +{{- if (lookPath "cloudflared") -}} + + + + + Label + com.cloudflare.cloudflared + ProgramArguments + + {{ lookPath "cloudflared" }} + tunnel + run + + RunAtLoad + + StandardOutPath + /Library/Logs/com.cloudflare.cloudflared.out.log + StandardErrorPath + /Library/Logs/com.cloudflare.cloudflared.err.log + KeepAlive + + SuccessfulExit + + + ThrottleInterval + 5 + + +{{- end -}} diff --git a/system/etc/logrotate.d/juicefs b/system/etc/logrotate.d/juicefs.tmpl similarity index 72% rename from system/etc/logrotate.d/juicefs rename to system/etc/logrotate.d/juicefs.tmpl index 594e2bb4..844c4541 100644 --- a/system/etc/logrotate.d/juicefs +++ b/system/etc/logrotate.d/juicefs.tmpl @@ -1,3 +1,4 @@ +{{- if (lookPath "juicefs") -}} /var/log/juicefs.log { daily rotate 7 @@ -6,4 +7,5 @@ missingok notifempty copytruncate -} \ No newline at end of file +} +{{- end -}} diff --git a/system/etc/wsl.conf b/system/etc/wsl.conf.tmpl similarity index 57% rename from system/etc/wsl.conf rename to system/etc/wsl.conf.tmpl index 10e043cc..dbf0d5e0 100644 --- a/system/etc/wsl.conf +++ b/system/etc/wsl.conf.tmpl @@ -1,5 +1,7 @@ +{{- if (stat "/proc/sys/fs/binfmt_misc/WSLInterop") -}} [wsl2] nestedVirtualization=true [boot] -command = /bin/bash -c 'chown -v root:kvm /dev/kvm && chmod 660 /dev/kvm' \ No newline at end of file +command = /bin/bash -c 'chown -v root:kvm /dev/kvm && chmod 660 /dev/kvm' +{{- end -}} diff --git a/system/etc/zshrc b/system/etc/zshrc.tmpl similarity index 98% rename from system/etc/zshrc rename to system/etc/zshrc.tmpl index fe2e736b..819db586 100644 --- a/system/etc/zshrc +++ b/system/etc/zshrc.tmpl @@ -1,3 +1,4 @@ +{{- if (lookPath "zsh") -}} # System-wide profile for interactive zsh(1) shells. # Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1) @@ -76,3 +77,4 @@ PS1="%n@%m %1~ %# " if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi +{{- end -}}