[macOS] Fix automationmodetool and loginwindow issue for macOS14.7 (#10684)

This commit is contained in:
sarathrajsrinivasan
2024-10-02 07:38:03 -07:00
committed by GitHub
parent 0a7abf330f
commit fdbe51d78c
9 changed files with 29 additions and 15 deletions

View File

@@ -50,21 +50,18 @@ done
rm -f ./add-certificate
# enable-automationmode-without-authentication
brew install expect
retry=10
while [[ $retry -gt 0 ]]; do
{
osascript <<EOF
tell application "Terminal"
activate
do script "automationmodetool enable-automationmode-without-authentication"
delay 2
tell application "System Events"
keystroke "${PASSWORD}"
keystroke return
end tell
end tell
delay 5
/usr/bin/expect <<EOF
spawn automationmodetool enable-automationmode-without-authentication
expect "password"
send "${PASSWORD}\r"
expect {
"succeeded." { puts "Automation mode enabled successfully"; exit 0 }
eof
}
EOF
} && break
@@ -77,9 +74,15 @@ EOF
done
echo "Getting terminal windows"
term_service=$(launchctl list | grep -i terminal | cut -f3)
echo "Close terminal windows: gui/501/${term_service}"
launchctl bootout gui/501/${term_service} && sleep 5
launchctl_output=$(launchctl list | grep -i terminal || true)
if [ -n "$launchctl_output" ]; then
term_service=$(echo "$launchctl_output" | cut -f3)
echo "Close terminal windows: gui/501/${term_service}"
launchctl bootout gui/501/${term_service} && sleep 5
else
echo "No open terminal windows found."
fi
# test enable-automationmode-without-authentication
if [[ ! "$(automationmodetool)" =~ "DOES NOT REQUIRE" ]]; then