macOS: wait for the old launchd job before reloading the daemon
Re-running the installer on a Mac failed with "Bootstrap failed: 5: Input/output error". bootout returns while the old job is still stopping, and the bootstrap right after it fails. setup.sh now lints the plist, waits until launchctl print no longer finds the job, re-enables it (a disabled job also fails with error 5), retries the bootstrap once, and names the commands to check if it still fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
380243545c
commit
03604c8367
2 changed files with 19 additions and 1 deletions
|
|
@ -144,9 +144,19 @@ else
|
|||
PLIST
|
||||
as_root install -m 644 -o root -g wheel "$plist" "/Library/LaunchDaemons/$SERVICE.plist"
|
||||
rm -f "$plist"
|
||||
plutil -lint "/Library/LaunchDaemons/$SERVICE.plist" >/dev/null || native_die "the generated plist is invalid: plutil -lint /Library/LaunchDaemons/$SERVICE.plist"
|
||||
# Unload the old job and wait until it is really gone: bootout returns while the job is
|
||||
# still stopping, and bootstrapping then fails with "5: Input/output error".
|
||||
as_root launchctl bootout "system/$SERVICE" >/dev/null 2>&1 || true
|
||||
as_root launchctl bootstrap system "/Library/LaunchDaemons/$SERVICE.plist"
|
||||
i=0
|
||||
while as_root launchctl print "system/$SERVICE" >/dev/null 2>&1 && [ "$i" -lt 30 ]; do sleep 0.5; i=$((i + 1)); done
|
||||
# A job marked disabled (launchctl disable) can't be bootstrapped either.
|
||||
as_root launchctl enable "system/$SERVICE" >/dev/null 2>&1 || true
|
||||
if ! as_root launchctl bootstrap system "/Library/LaunchDaemons/$SERVICE.plist"; then
|
||||
sleep 2 # one retry, for a job that took longer to stop
|
||||
as_root launchctl bootstrap system "/Library/LaunchDaemons/$SERVICE.plist" \
|
||||
|| native_die "launchctl bootstrap failed. Check: sudo launchctl print system/$SERVICE; sudo launchctl print-disabled system | grep $NAME"
|
||||
fi
|
||||
fi
|
||||
if [ "$PLATFORM" = systemd ] && [ "$AVAHI" = 1 ]; then
|
||||
native_log "avahi: announcing $(hostname -s).local"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue