1#!/bin/bash
2
3### Zoom audio device driver repair
4### 2021.01.15 JW - update Buck Crockett 05/15/2021 added cleaned up the function from jfilice_at_csumb
5
6### There is a packaging or broken script issue in recent Zoom installer(s?)
7### where /Library/Audio/Plug-Ins/HAL/ZoomAudioDevice.driver is either broken or failing to install.
8### Either way, users are being prompted for admin pass to install the audio driver when attempting to share desktop or videos 'with sound'
9### This should hopefully resolve, though resetting coreaudio sometimes seems hit or miss, take with a grain of salt.
10
11### more details found here (see dates 2021.01.11)
12### https://www.jamf.com/jamf-nation/discussions/27069/zoom-app-asks-for-admin-credentials-when-trying-to-share-computer-audio
13
14
15### if this is part of a re-install, let's give installer a few extra seconds to finish up
16sleep 10
17
18
19### concept below pulled from factory ZoomInstallerIT.pgk post-install script:
20### However an issue I see is coreaudiod was not reliably being reset,
21### I reworked Zoom's method for grabbing PID and it seems to work much better now! -JW
22### Note an easy clue as to whether this is working or not is to have open /Applications/Utilities/Audio MIDI Setup...
23### ...if the ZoomAudioDevice loads we're golden... otherwise back to the drawing board.
24
25function kill_coreaudiod()
26{
27# Set variable to all PIDs of /usr/sbin/coreaudiod
28# --invert-match to remove PID for the grep command itself
29 coreaudiod_pid=$( ps -ax -o pid -o command | grep "/usr/sbin/coreaudiod" | grep --invert-match grep | awk '{print $1}' )
30
31 for each_pid in $coreaudiod_pid
32 do
33 if [[ $each_pid -gt 0 ]]
34 then
35 kill -9 $each_pid
36 fi
37 done
38}
39AudioPluginPath=/Library/Audio/Plug-Ins/HAL
40audioPluginfile=/Applications/zoom.us.app/Contents/Plugins/ZoomAudioDevice.driver
41
42st=$(kextstat -b zoom.us.ZoomAudioDevice | grep zoom.us.ZoomAudioDevice 2>&1)
43
44if [[ $st = *zoom.us.ZoomAudioDevice* ]] ; then
45 echo "audio device is loaded, skipping"
46 exit 1
47else
48 #(re)install audio driver
49 if [[ -d "$AudioPluginPath/ZoomAudioDevice.driver" ]]; then
50 rm -rf "$AudioPluginPath/ZoomAudioDevice.driver"
51 fi
52
53 cp -rf "$audioPluginfile" "$AudioPluginPath"
54
55 ### reset coreaudiod ...see function & notes on Audio MIDI setup
56 kill_coreaudiod
57 sleep 5
58fi