Compare commits

...

15 Commits

Author SHA1 Message Date
T. R. Bernstein
1e1ea39a90 Use HOME env variable in brew caller scripts 2025-10-20 14:02:31 +02:00
T. R. Bernstein
cd8f2b7c0d Fix missing function in setup-user script
Add missing getDefaultGitHomebrewURL.
2025-10-20 14:02:31 +02:00
T. R. Bernstein
48fe726f31 Make sudo-settings module executable 2025-10-20 14:02:31 +02:00
5d9b2d56e5 revert ea86be7b01
revert Use brew caller script without sudo
2025-10-18 23:27:06 +02:00
ea86be7b01 Use brew caller script without sudo 2025-10-18 23:22:59 +02:00
b7664ad8a7 Adapt UID of _homebrew depending on system version 2025-10-18 21:17:54 +02:00
37542773e3 Run homebrew as _homebrew user 2025-10-18 18:21:27 +02:00
7c8d81f080 Remove bun from installation 2025-10-18 18:08:42 +02:00
854c19f35f Use empty home variable for homebrew installation
Homebrew install script does not respect HOMEBREW_CACHE variable. Using an empty home variable ensures we get the result we want, but it is hacky.
2025-10-18 18:03:49 +02:00
87df4b6d7d Remove involuntary unicode char 2025-10-18 17:48:07 +02:00
8bca66a7bb Fix logical error regarding user id of _homebrew 2025-10-18 17:24:34 +02:00
T. R. Bernstein
8def65f683 Install f2 2025-10-18 15:40:16 +02:00
T. R. Bernstein
563a29aa58 Add Parallels to setup-host cmd 2025-10-18 15:30:36 +02:00
T. R. Bernstein
0fbcf46307 Allow proximitywake 2025-10-18 00:57:53 +02:00
T. R. Bernstein
59f627914d Symlink brew caller only on intel cpu 2025-10-18 00:54:21 +02:00
6 changed files with 30 additions and 16 deletions

View File

@@ -30,6 +30,7 @@ function main() {
installMASApp 'Numbers' 409203825 installMASApp 'Numbers' 409203825
installMASApp 'Outbank' 1094255754 installMASApp 'Outbank' 1094255754
installMASApp 'Pages' 409201541 installMASApp 'Pages' 409201541
installMASApp 'Parallels Desktop' 1085114709
installMASApp 'Pixelmator Pro' 1289583905 installMASApp 'Pixelmator Pro' 1289583905
installMASApp 'SnippetsLab' 1006087419 installMASApp 'SnippetsLab' 1006087419
installMASApp 'Tim' 1449619230 installMASApp 'Tim' 1449619230

View File

@@ -55,9 +55,17 @@ function downloadHomebrew() {
popd -q popd -q
} }
function getCanonicalBrewPath() {
local brewPath=${homebrew_directory}/bin/brew
if [[ $brewPath == $HOME* ]]; then
brewPath="\${HOME}${brewPath#$HOME}"
fi
echo $brewPath
}
function createBrewCallerScript() { function createBrewCallerScript() {
local cmdPath=${HOME}/bin/brew local cmdPath=${HOME}/bin/brew
local brewPath=${homebrew_directory}/bin/brew local brewPath=`getCanonicalBrewPath`
[[ -f ${cmdPath} ]] && rm ${cmdPath} [[ -f ${cmdPath} ]] && rm ${cmdPath}
mkdir -p ${cmdPath:h} mkdir -p ${cmdPath:h}
cat <<- BREWCALLER > ${cmdPath} cat <<- BREWCALLER > ${cmdPath}
@@ -74,13 +82,13 @@ function createBrewCallerScript() {
} }
function createBrewPeriodicScript() { function createBrewPeriodicScript() {
local brewCallerPath=${HOME}/bin/brew local brewPath=`getCanonicalBrewPath`
local cmdPath=${HOME}/bin/brew-periodic local cmdPath=${HOME}/bin/brew-periodic
[[ -f ${cmdPath} ]] && rm ${cmdPath} [[ -f ${cmdPath} ]] && rm ${cmdPath}
mkdir -p ${cmdPath:h} mkdir -p ${cmdPath:h}
cat <<- BREWCALLER > ${cmdPath} cat <<- BREWCALLER > ${cmdPath}
#!/usr/bin/env zsh #!/usr/bin/env zsh
local brew='${brewCallerPath}' local brew='${brewPath}'
\$brew update \$brew update
\$brew upgrade --greedy \$brew upgrade --greedy
\$brew cleanup \$brew cleanup
@@ -138,6 +146,10 @@ function getHomebrewDirectoryPath() {
print -- ${homebrew_prefix:-$(getDefaultHomebrewPrefix)}/Homebrew print -- ${homebrew_prefix:-$(getDefaultHomebrewPrefix)}/Homebrew
} }
function getDefaultGitHomebrewURL() {
print -- ${HOMEBREW_BREW_GIT_REMOTE:-https://github.com/Homebrew/brew.git}
}
function configureFolders() { function configureFolders() {
local dirPath local dirPath
for dirPath in ${HOME}/bin ${HOME}/.vim/{backups,swaps}; do for dirPath in ${HOME}/bin ${HOME}/.vim/{backups,swaps}; do

0
modules/00a-sudo-settings.sh Normal file → Executable file
View File

View File

@@ -39,7 +39,7 @@ function configurePowerManagement() {
${cmd} sleep 0 ${cmd} sleep 0
${cmd} womp 0 ${cmd} womp 0
${cmd} acwake 0 ${cmd} acwake 0
${cmd} proximitywake 0 ${cmd} proximitywake 1
${cmd} destroyfvkeyonstandby 1 ${cmd} destroyfvkeyonstandby 1
pmset -b acwake 1 pmset -b acwake 1
${cmd} lidwake 1 ${cmd} lidwake 1

View File

@@ -42,12 +42,11 @@ function ensureUserCanNoLongerRunPasswordlessSudo() {
} }
function getFirstFreeRoleAccountID() { function getFirstFreeRoleAccountID() {
local minUserID=450 local minUserID=200
local maxUserID=499 local maxUserID=400
local uname_machine=$(/usr/bin/uname -m) if is-at-least 13.0 $(sw_vers -productVersion); then
if [[ ${uname_machine} == "arm64" ]]; then minUserID=450
minUserID=200 maxUserID=499
maxUserID=400
fi fi
dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=${minUserID} '$2>='${minUserID}' && $2<'${maxUserID}' {if(i < $2) { print i; nextfile} else i=$2+1;} END {if(i <= '${maxUserID}' && ($2 < '${minUserID}' || $2 > '${maxUserID}')) print i;}' dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=${minUserID} '$2>='${minUserID}' && $2<'${maxUserID}' {if(i < $2) { print i; nextfile} else i=$2+1;} END {if(i <= '${maxUserID}' && ($2 < '${minUserID}' || $2 > '${maxUserID}')) print i;}'
} }
@@ -102,12 +101,14 @@ function getHomebrewRepositoryPath() {
function createBrewCallerScript() { function createBrewCallerScript() {
ensureLocalBinFolder ensureLocalBinFolder
local uname_machine=$(/usr/bin/uname -m)
local username=${homebrew_username} local username=${homebrew_username}
local homebrewRepositoryPath="$(getHomebrewRepositoryPath)" local homebrewRepositoryPath="$(getHomebrewRepositoryPath)"
local brewCallerPath="${homebrewRepositoryPath}/bin/brew-caller" local brewCallerPath="${homebrewRepositoryPath}/bin/brew-caller"
local brewCallerSymlink="/usr/local/bin/brew" local brewCallerSymlink="/usr/local/bin/brew"
[[ -f "${brewCallerPath}" ]] && rm "${brewCallerPath}" [[ -f "${brewCallerPath}" ]] && rm "${brewCallerPath}"
[[ -f "${brewCallerSymlink}" || -h "${brewCallerSymlink}" ]] && rm "${brewCallerSymlink}" [[ -f "${brewCallerSymlink}" || -h "${brewCallerSymlink}" ]] && rm "${brewCallerSymlink}"
[[ ${uname_machine} == "arm64" ]] && brewCallerPath=${brewCallerSymlink}
cat <<- BREWCALLER | clang -x c -O2 -Wall -o "${brewCallerPath}" - cat <<- BREWCALLER | clang -x c -O2 -Wall -o "${brewCallerPath}" -
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
@@ -186,7 +187,7 @@ function createBrewCallerScript() {
BREWCALLER BREWCALLER
chown root:admin ${brewCallerPath} chown root:admin ${brewCallerPath}
chmod 4550 ${brewCallerPath} chmod 4550 ${brewCallerPath}
ln -s "${brewCallerPath}" "${brewCallerSymlink}" [[ ${uname_machine} == "arm64" ]] || ln -s "${brewCallerPath}" "${brewCallerSymlink}"
} }
function createBrewPeriodicScript() { function createBrewPeriodicScript() {
@@ -205,9 +206,8 @@ function createBrewPeriodicScript() {
} }
function installHomebrewCore() { function installHomebrewCore() {
export NONINTERACTIVE=1 [ ! -d $(getHomebrewRepositoryPath) ] || return
[ ! -d $(getHomebrewRepositoryPath) ] || return NONINTERACTIVE=1 HOME= sudo --preserve-env=NONINTERACTIVE,HOME -u "${homebrew_username}" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
sudo --preserve-env=NONINTERACTIVE -u "${homebrew_username}" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
[ -d $(getHomebrewRepositoryPath) ] [ -d $(getHomebrewRepositoryPath) ]
} }
@@ -355,6 +355,7 @@ function getUsage() {
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 } test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
autoload is-at-least
source "${ASTZWEIG_MACOS_SYSTEM_LIB}" source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
module_main $0 "$@" module_main $0 "$@"
fi fi

View File

@@ -4,7 +4,7 @@
function brewInstall() { function brewInstall() {
local identifier="$1" local identifier="$1"
local cask="${2:+--cask}" local cask="${2:+--cask}"
indicateActivity -- "Installing ${identifier}${cask:+ (Cask)}" ${homebrew_path} install -q ${cask} ${identifier} HOME=/Users/Shared indicateActivity -- "Installing ${identifier}${cask:+ (Cask)}" sudo -u _homebrew ${homebrew_path} install -q ${cask} ${identifier}
} }
function installCask() { function installCask() {
@@ -59,7 +59,6 @@ function installBrews() {
lop -y body:h1 -- -i 'Installing Homebrew formulas' lop -y body:h1 -- -i 'Installing Homebrew formulas'
installBrew mas installBrew mas
if ! isDebug; then if ! isDebug; then
installBrew bun
installBrew chezmoi installBrew chezmoi
installBrew cocogitto installBrew cocogitto
installBrew composer installBrew composer
@@ -67,6 +66,7 @@ function installBrews() {
installBrew docker installBrew docker
installBrew docker-buildx installBrew docker-buildx
installBrew exiftool installBrew exiftool
installBrew f2
installBrew ffmpeg installBrew ffmpeg
installBrew gnupg installBrew gnupg
installBrew go installBrew go