cask "netbird-ui" do arch arm: "arm64", intel: "amd64" version "0.82.1" sha256 arm: "9cd57d6f42997f18fffff0b41dfd658bb5c3e9f5581dd46ab3d6d4706e956412", intel: "4253db19181e4f37aeb2000dd6288f9aa351bc350fc126dfe4d44234dc9c0976" url "https://github.com/netbirdio/netbird/releases/download/v#{version}/netbird-ui_#{version}_darwin_#{arch}_signed.zip" name "Netbird UI" desc "Desktop client for the NetBird overlay network" homepage "https://www.netbird.io/" livecheck do url :url strategy :github_latest end depends_on formula: "vokhactri/tap/netbird" depends_on :macos app "netbird_ui_darwin", target: "Netbird UI.app" # Do what upstream's installer.sh does without running it. The script always # calls `netbird service stop` and `netbird service uninstall` and lets their # stderr through. On upgrade, uninstall_preflight_steps has already removed # the service, so both print launchctl errors even though nothing failed. postflight_steps do run "/usr/bin/osascript", args: ["-e", 'quit app "Netbird UI"'], sudo: true, must_succeed: false, print_stderr: false run "{{HOMEBREW_PREFIX}}/bin/netbird", args: ["service", "stop"], sudo: true, must_succeed: false, print_stderr: false run "{{HOMEBREW_PREFIX}}/bin/netbird", args: ["service", "uninstall"], sudo: true, must_succeed: false, print_stderr: false run "{{HOMEBREW_PREFIX}}/bin/netbird", args: ["service", "install"], sudo: true run "{{HOMEBREW_PREFIX}}/bin/netbird", args: ["service", "start"], sudo: true run "/usr/bin/open", args: ["{{appdir}}/Netbird UI.app"], sudo: true, must_succeed: false end # bootout returns before launchd has removed system/netbird. On upgrade the # new installer.sh then fails to load the service and the daemon stays down, # so wait for the old service to go away first. uninstall_preflight_steps do run "/bin/launchctl", args: ["bootout", "system/netbird"], sudo: true, must_succeed: false, print_stderr: false run "/bin/sh", args: ["-c", "i=0; while /bin/launchctl print system/netbird >/dev/null 2>&1 && [ $i -lt 30 ]; " \ "do sleep 0.5; i=$((i + 1)); done"], sudo: true, must_succeed: false run "/bin/launchctl", args: ["unload", "/Library/LaunchDaemons/netbird.plist"], sudo: true, must_succeed: false, print_stderr: false remove "/Library/LaunchDaemons/netbird.plist", sudo: true end end