diff --git a/manage_runner.sh b/manage_runner.sh index a9d0fb9..f33f8e1 100755 --- a/manage_runner.sh +++ b/manage_runner.sh @@ -494,12 +494,19 @@ remove_native_runner() { fi if launchctl list 2>/dev/null | grep -q "com.gitea.runner.${RUNNER_NAME}"; then - if $needs_sudo; then - sudo launchctl unload "$plist_path" 2>/dev/null || true + if [[ -n "$plist_path" ]]; then + if $needs_sudo; then + sudo launchctl unload "$plist_path" 2>/dev/null || true + else + launchctl unload "$plist_path" 2>/dev/null || true + fi + log_success "Launchd service unloaded" else - launchctl unload "${plist_path:-$HOME/Library/LaunchAgents/${plist_name}}" 2>/dev/null || true + # Plist file is gone but launchctl still shows the service — force-remove by label. + launchctl remove "com.gitea.runner.${RUNNER_NAME}" 2>/dev/null || \ + sudo launchctl remove "com.gitea.runner.${RUNNER_NAME}" 2>/dev/null || true + log_warn "Plist not found on disk — removed service by label" fi - log_success "Launchd service unloaded" fi if [[ -n "$plist_path" ]] && [[ -f "$plist_path" ]]; then