From d8d641c6713e20bb6626442efa5ebec9eb9e33c1 Mon Sep 17 00:00:00 2001 From: "T. R. Bernstein" <137705289+trbernstein@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:19:04 +0200 Subject: [PATCH] Fix heredoc tab error --- modules/03-install-brew.sh | 82 ++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/modules/03-install-brew.sh b/modules/03-install-brew.sh index 068589a..c1265d9 100755 --- a/modules/03-install-brew.sh +++ b/modules/03-install-brew.sh @@ -29,8 +29,8 @@ function ensureUserCanRunPasswordlessSudo() { local sudoersFile="/etc/sudoers.d/no-auth-sudo-for-${username}" [[ -f ${sudoersFile} ]] && return cat <<- SUDOERS > "${sudoersFile}" - Defaults:${username} !authenticate - SUDOERS + Defaults:${username} !authenticate + SUDOERS chown root:wheel "${sudoersFile}" || return 10 chmod u=rw,g=r,o= "${sudoersFile}" || return 20 } @@ -157,21 +157,23 @@ function downloadHomebrew() { function createBrewCallerScript() { local username=${homebrew_username} local brewCallerPath="${homebrew_prefix}/Homebrew/bin/brew_caller" - print -- "#!/usr/bin/env zsh - if [ \"\$(id -un)\" != \"${username}\" ]; then - echo 'brew will be run as ${username} user.' >&2 - sudo -E -u \"${username}\" \"\$0\" \"\$@\" - exit \$? - fi - export HOMEBREW_CACHE=\"${homebrew_cache}\" - export HOMEBREW_LOGS=\"${homebrew_log}\" - export HOMEBREW_CASK_OPTS=\"--no-quarantine \${HOMEBREW_CASK_OPTS}\" - export HOMEBREW_NO_AUTO_UPDATE=1 - export HOMEBREW_NO_ANALYTICS=1 - export HOMEBREW_NO_ANALYTICS_THIS_RUN=1 - export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1 - umask 002 - \"${homebrew_prefix}/Homebrew/bin/brew\" \"\$@\"" > ${brewCallerPath} + cat <<- BREWCALLER > ${brewCallerPath} + #!/usr/bin/env zsh + if [ \"\$(id -un)\" != \"${username}\" ]; then + echo 'brew will be run as ${username} user.' >&2 + sudo -E -u \"${username}\" \"\$0\" \"\$@\" + exit \$? + fi + export HOMEBREW_CACHE=\"${homebrew_cache}\" + export HOMEBREW_LOGS=\"${homebrew_log}\" + export HOMEBREW_CASK_OPTS=\"--no-quarantine \${HOMEBREW_CASK_OPTS}\" + export HOMEBREW_NO_AUTO_UPDATE=1 + export HOMEBREW_NO_ANALYTICS=1 + export HOMEBREW_NO_ANALYTICS_THIS_RUN=1 + export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1 + umask 002 + \"${homebrew_prefix}/Homebrew/bin/brew\" \"\$@\" + BREWCALLER chown ${username}:admin ${brewCallerPath} chmod u+x,go-x ${brewCallerPath} runAsHomebrewUser ln -sf ${homebrew_prefix}/Homebrew/bin/brew_caller "${homebrew_prefix}/bin/brew" @@ -196,28 +198,30 @@ function createLaunchDaemonsPlist() { local launcherPath="/Library/LaunchDaemons/${launcherName}.plist" [[ -f $launcherPath ]] && return local brewCommand="$2" - echo " - - - - Label - ${launcherName} - Program - ${homebrew_prefix}/bin/brew - ProgramArguments - - ${brewCommand} - - StartInterval - 1800 - UserName - ${username} - GroupName - admin - Umask - 2 - -" > "${launcherPath}" + cat <<- LAUNCHDPLIST > ${launcherPath} + + + + + Label + ${launcherName} + Program + ${homebrew_prefix}/bin/brew + ProgramArguments + + ${brewCommand} + + StartInterval + 1800 + UserName + ${username} + GroupName + admin + Umask + 2 + + " + LAUNCHDPLIST chown root:wheel ${launcherPath} chmod u=rw,go=r ${launcherPath} launchctl bootstrap system ${launcherPath}