Hi All,
Hoping to get some help here.
One of the minor Catalina update broke my script. It was working until at least 10.15.1
I have an osascript running at login that is triggered by Launch Agents.
The script will display a dialog box.
The launch agent is definitely loaded. I can also see osascript running from Activity Monitor
launchctl list | grep acme 873 0 com.acme.WifiLoginPrompt
but the dialog box doesn't appear. If I unload and reload the plist then the dialog box will appear
launchctl unload ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist launchctl load ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist
Any suggestions?
Note: this only happens on the very first login attempt, subsequent login will be fine
Thanks for looking!
Launch agent plist below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.acme.WifiLoginPrompt</string>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/.Script/WifiLoginPrompt.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Script is to prompt user for their password and create a keychain entry
#!/usr/bin/osascript
-- REVIEW ACTIONS ASK FOR USER CONFIRMATION
display dialog "Welcome to ACME
Please have your computer login password ready before proceeding to connect to the Wi-Fi." buttons {"OK"} default button "OK" --with icon caution
set t to "" -- all purpose variable holds various types of data
set label to "STAFF WIFI" --e -- if omitted, service name is used as default label
set KeyKind to "802.1X Password" --e unless new type is "Internet password", then --n
set AcctName to do shell script "echo $LOGNAME"
set Acctpassword to text returned of (display dialog "Please enter your login password to connect to ACME Wi-Fi" default answer "" with hidden answer) -- n
set ServiceName to "com.apple.network.eap.user.item.wlan.ssid.STAFF WIFI" --n
set AcctComments to "Keychain Added via Apple Script." --e
set WifiPort to do shell script ("networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d ' ' -f 2")
-- CONFIGURE WI-FI CONNECTION
try
set t to do shell script "security add-generic-password -a " & QAcctName & " -s " & QServiceName & " -w " & QAcctpassword & " -l " & Qlabel & " -j " & QAcctComments & " -D " & QKeyKind & " -T '/System/Library/SystemConfiguration/EAPOLController.bundle/Contents/Resources/eapolclient' -T '/usr/bin/security' -T '/System/Library/CoreServices/SystemUIServer.app' -T '/System/Applications/System Preferences.app' -T 'group://AirPort'" & " -A " & "-U"
end try
-- TURN OFF AIRPORT
do shell script "`networksetup -setairportpower " & QWifiPort & " off`"
try
do shell script "`networksetup -setairportpower " & QWifiPort & " off `"
do shell script "sleep 2"
do shell script "`networksetup -setairportpower " & QWifiPort & " on `"
do shell script "`networksetup -addpreferredwirelessnetworkatindex " & QWifiPort & " " & Qlabel & " 0 WPA2E`"
end try
display dialog "All Done! Welcome to the ACME Network" buttons {"OK"} default button "OK"
-- REMOVE LAUNCH AGENT
do shell script "rm -rf ~/Library/LaunchAgents/com.acme.WifiLoginPrompt.plist"