Fix heredoc tab error
This commit is contained in:
committed by
T. R. Bernstein
parent
10b9b857b1
commit
d8d641c671
@@ -29,8 +29,8 @@ function ensureUserCanRunPasswordlessSudo() {
|
|||||||
local sudoersFile="/etc/sudoers.d/no-auth-sudo-for-${username}"
|
local sudoersFile="/etc/sudoers.d/no-auth-sudo-for-${username}"
|
||||||
[[ -f ${sudoersFile} ]] && return
|
[[ -f ${sudoersFile} ]] && return
|
||||||
cat <<- SUDOERS > "${sudoersFile}"
|
cat <<- SUDOERS > "${sudoersFile}"
|
||||||
Defaults:${username} !authenticate
|
Defaults:${username} !authenticate
|
||||||
SUDOERS
|
SUDOERS
|
||||||
chown root:wheel "${sudoersFile}" || return 10
|
chown root:wheel "${sudoersFile}" || return 10
|
||||||
chmod u=rw,g=r,o= "${sudoersFile}" || return 20
|
chmod u=rw,g=r,o= "${sudoersFile}" || return 20
|
||||||
}
|
}
|
||||||
@@ -157,21 +157,23 @@ function downloadHomebrew() {
|
|||||||
function createBrewCallerScript() {
|
function createBrewCallerScript() {
|
||||||
local username=${homebrew_username}
|
local username=${homebrew_username}
|
||||||
local brewCallerPath="${homebrew_prefix}/Homebrew/bin/brew_caller"
|
local brewCallerPath="${homebrew_prefix}/Homebrew/bin/brew_caller"
|
||||||
print -- "#!/usr/bin/env zsh
|
cat <<- BREWCALLER > ${brewCallerPath}
|
||||||
if [ \"\$(id -un)\" != \"${username}\" ]; then
|
#!/usr/bin/env zsh
|
||||||
echo 'brew will be run as ${username} user.' >&2
|
if [ \"\$(id -un)\" != \"${username}\" ]; then
|
||||||
sudo -E -u \"${username}\" \"\$0\" \"\$@\"
|
echo 'brew will be run as ${username} user.' >&2
|
||||||
exit \$?
|
sudo -E -u \"${username}\" \"\$0\" \"\$@\"
|
||||||
fi
|
exit \$?
|
||||||
export HOMEBREW_CACHE=\"${homebrew_cache}\"
|
fi
|
||||||
export HOMEBREW_LOGS=\"${homebrew_log}\"
|
export HOMEBREW_CACHE=\"${homebrew_cache}\"
|
||||||
export HOMEBREW_CASK_OPTS=\"--no-quarantine \${HOMEBREW_CASK_OPTS}\"
|
export HOMEBREW_LOGS=\"${homebrew_log}\"
|
||||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
export HOMEBREW_CASK_OPTS=\"--no-quarantine \${HOMEBREW_CASK_OPTS}\"
|
||||||
export HOMEBREW_NO_ANALYTICS=1
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||||
export HOMEBREW_NO_ANALYTICS_THIS_RUN=1
|
export HOMEBREW_NO_ANALYTICS=1
|
||||||
export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1
|
export HOMEBREW_NO_ANALYTICS_THIS_RUN=1
|
||||||
umask 002
|
export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1
|
||||||
\"${homebrew_prefix}/Homebrew/bin/brew\" \"\$@\"" > ${brewCallerPath}
|
umask 002
|
||||||
|
\"${homebrew_prefix}/Homebrew/bin/brew\" \"\$@\"
|
||||||
|
BREWCALLER
|
||||||
chown ${username}:admin ${brewCallerPath}
|
chown ${username}:admin ${brewCallerPath}
|
||||||
chmod u+x,go-x ${brewCallerPath}
|
chmod u+x,go-x ${brewCallerPath}
|
||||||
runAsHomebrewUser ln -sf ${homebrew_prefix}/Homebrew/bin/brew_caller "${homebrew_prefix}/bin/brew"
|
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"
|
local launcherPath="/Library/LaunchDaemons/${launcherName}.plist"
|
||||||
[[ -f $launcherPath ]] && return
|
[[ -f $launcherPath ]] && return
|
||||||
local brewCommand="$2"
|
local brewCommand="$2"
|
||||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
cat <<- LAUNCHDPLIST > ${launcherPath}
|
||||||
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
|
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||||
<plist version=\"1.0\">
|
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
|
||||||
<dict>
|
<plist version=\"1.0\">
|
||||||
<key>Label</key>
|
<dict>
|
||||||
<string>${launcherName}</string>
|
<key>Label</key>
|
||||||
<key>Program</key>
|
<string>${launcherName}</string>
|
||||||
<string>${homebrew_prefix}/bin/brew</string>
|
<key>Program</key>
|
||||||
<key>ProgramArguments</key>
|
<string>${homebrew_prefix}/bin/brew</string>
|
||||||
<array>
|
<key>ProgramArguments</key>
|
||||||
<string>${brewCommand}</string>
|
<array>
|
||||||
</array>
|
<string>${brewCommand}</string>
|
||||||
<key>StartInterval</key>
|
</array>
|
||||||
<integer>1800</integer>
|
<key>StartInterval</key>
|
||||||
<key>UserName</key>
|
<integer>1800</integer>
|
||||||
<string>${username}</string>
|
<key>UserName</key>
|
||||||
<key>GroupName</key>
|
<string>${username}</string>
|
||||||
<string>admin</string>
|
<key>GroupName</key>
|
||||||
<key>Umask</key>
|
<string>admin</string>
|
||||||
<integer>2</integer>
|
<key>Umask</key>
|
||||||
</dict>
|
<integer>2</integer>
|
||||||
</plist>" > "${launcherPath}"
|
</dict>
|
||||||
|
</plist>"
|
||||||
|
LAUNCHDPLIST
|
||||||
chown root:wheel ${launcherPath}
|
chown root:wheel ${launcherPath}
|
||||||
chmod u=rw,go=r ${launcherPath}
|
chmod u=rw,go=r ${launcherPath}
|
||||||
launchctl bootstrap system ${launcherPath}
|
launchctl bootstrap system ${launcherPath}
|
||||||
|
|||||||
Reference in New Issue
Block a user