Skip to content

Commit

Permalink
Add Slack huddle check
Browse files Browse the repository at this point in the history
  • Loading branch information
grahampugh committed Feb 14, 2024
1 parent 311d0d2 commit f47e267
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ No date
No date

- Remove searches for cached DMG and sparseimages.
- Add experimental `--check-activity` option. This checks for an active Zoom meeting or Slack huddle when using `--reinstall` or `--erase` options, and quits silently if so.
- Add missing `--credentials=XYZ` option (previously only `--credentials XYZ` worked) (thanks @allanp81).
- Remove quotes from the value obtained from any inputted `--parameter="value"` option.
- Bump swiftDialog version to 2.4.0 except for systems running macOS 11 which still get 2.2.1.
- The installer package now includes both swiftDialog 2.4.0 and 2.2.1, and the postinstall script determines which version to install on the system based on the system OS.
- The installer package now includes both swiftDialog 2.4.0 and 2.2.1, and the postinstall script determines which version to install on the system based on the system OS.
- NOTE: This also limits the package installation to macOS 11 and newer. If you wish to use erase-install on macOS 10.15 or older, it is recommended to use v27.3.

## [32.0]
Expand Down Expand Up @@ -123,7 +124,7 @@ No date
28.01.2023

- `--cache-downloads` option. In 28.0, `mist` cached downloads into `/private/tmp/com.ninxsoft.mist`. This is now optional.
- New experimental `--set-securebootlevel` option (in `--erase` mode only) uses the command `bputil -f -u $current_user -p $account_password` to ensure that the OS is reset to a high secure boot level after reinstallation (thanks to @mvught).
- New experimental `--set-securebootlevel` option (in `--erase` mode only) uses the command `bputil -f -u $current_user -p $account_password` to ensure that the OS is reset to a high secure boot level after reinstallation (thanks to @mvught).
- New experimental `--clear-firmware` option (in `--erase` mode only) uses the command `nvram -c` to ensure that the OS is reset to a high secure boot level after reinstallation (thanks to @mvught).
- `erase-install` now reports a non-zero exit code (143 to be exact) when it is being abnormally terminated (e.g. by pressing CTRL+C or getting terminated by SIGTERM). Previously it would return the exit code of the last command being executed at time of termination, which could be non-zero or zero depending on the specific circumstances, which then could have been reported as successful execution in a Jamf policy. This change will make it easier to discover such errors. The exit code of the last executed command will be logged in addition to returning 143 to facilitate debugging (#318, thanks @cvgs).

Expand Down Expand Up @@ -163,7 +164,7 @@ No date

14.12.2022

- Better handling of replacing broken sparseimage files. If `--overwrite`, `--update`, or `--replace-invalid` are used and the version cannot be obtained from the sparseimage, the installer should be downloaded again. This also fixes `--overwrite` where an existing sparseimage is present.
- Better handling of replacing broken sparseimage files. If `--overwrite`, `--update`, or `--replace-invalid` are used and the version cannot be obtained from the sparseimage, the installer should be downloaded again. This also fixes `--overwrite` where an existing sparseimage is present.
- Add `--no-timeout` option which extends the timeout period to 24h.

## [27.1]
Expand Down
41 changes: 24 additions & 17 deletions erase-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,26 @@ check_fmm() {
}

# -----------------------------------------------------------------------------
# Checks for certain activities, currently only supports Zoom meetings.
# Checks for certain activities, currently only supports Zoom meetings and
# Slack huddles.
# Exits out if activity is detected.
# Called when --check-activty option is used.
# -----------------------------------------------------------------------------
check_for_activity() {
zoomInMeeting=$(lsof -i 4UDP | grep zoom | awk 'END{print NR}')
if [ "$zoomInMeeting" -gt 1 ]; then
writelog "[$script_name] Active Zoom meeting detected. Exiting."
check_for_presentation_activity() {
# zoom
zoom_meeting_active=$(/usr/sbin/lsof -i 4UDP | /usr/bin/grep zoom | /usr/bin/awk 'END{print NR}')
# slack
if /bin/ps -ax | /usr/bin/grep "Slack Helper (Plugin)" | /usr/bin/grep -v grep >/dev/null; then
slack_meeting_active=1
else
slack_meeting_active=0
fi

if [[ $zoom_meeting_active -gt 1 || $slack_meeting_active -eq 1 ]]; then
writelog "[$script_name] Active meeting detected. Exiting."
exit 0
else
writelog "[$script_name] No active Zoom meetings detected. Continuing."
writelog "[$script_name] No active meetings detected. Continuing."
fi
}

Expand Down Expand Up @@ -327,7 +336,7 @@ check_free_space() {
free_disk_space=$(osascript -l 'JavaScript' -e "ObjC.import('Foundation'); var freeSpaceBytesRef=Ref(); $.NSURL.fileURLWithPath('/').getResourceValueForKeyError(freeSpaceBytesRef, 'NSURLVolumeAvailableCapacityForImportantUsageKey', null); Math.round(ObjC.unwrap(freeSpaceBytesRef[0]) / 1000000000)")

if [[ ! "$free_disk_space" ]] || [[ "$free_disk_space" == 0 ]]; then
# fall back to df -h if the above fails
# fall back to df if the above fails
free_disk_space=$(df -Pk . | column -t | sed 1d | awk '{print $4}' | xargs -I{} expr {} / 1000000)
fi

Expand Down Expand Up @@ -2459,7 +2468,8 @@ show_help() {
--kc-service The name of the key containing the account and password
--silent Silent mode. No dialogs. Requires use of keychain (--kc mode) for Apple Silicon
to provide a password, or the --credentials/--very-insecure-mode mode.
--check-activty If certain activity is detected, the script exits. Currently only supports Zoom meetings.
--check-activity If certain activity is detected, the script exits. Currently only supports
Zoom meetings and Slack huddles.
--quiet Remove output from mist during installer download. Note that no progress
is shown.
--preservecontainer Preserves other volumes in your APFS container when using --erase
Expand Down Expand Up @@ -2795,9 +2805,6 @@ while test $# -gt 0 ; do
shift
credentials="$1"
;;
--check-activity)
shift
;;
--confirmation-icon)
shift
custom_icon="yes"
Expand Down Expand Up @@ -3000,11 +3007,6 @@ elif [[ ($overwrite == "yes" && $update_installer == "yes") || ($replace_invalid
exit 1
fi

# check for user activity
if [[ $check_for_activity == "yes" ]]; then
check_for_activity
fi

# different dialog icon for OS older than macOS 13
if [[ $(echo "$system_version_major < 13" | bc) == 1 ]]; then
dialog_confirmation_icon="/System/Applications/System Preferences.app"
Expand Down Expand Up @@ -3163,7 +3165,7 @@ fi
if [[ ! -d "$working_macos_app" && ! -f "$working_installer_pkg" ]]; then
if [[ ! $silent ]]; then
# if erasing or reinstalling, open a dialog to state that the download is taking place.
if [[ $erase == "yes" || $reinstall == "yes" || $dl_dialog == "yes" ]]; then
if [[ $erase == "yes" || $reinstall == "yes" || ($dl_dialog == "yes" && $check_for_activity != "yes") ]]; then
# if no_fs is set, show a utility window instead of the full screen display (for test purposes)
if [[ $fs == "yes" ]]; then
window_type="fullscreen"
Expand Down Expand Up @@ -3247,6 +3249,11 @@ check_free_space
# Steps beyond here are to run startosinstall
# -----------------------------------------------------------------------------

# check for user activity - will quit here if a meeting is open
if [[ $check_for_activity == "yes" ]]; then
check_for_presentation_activity
fi

echo
# if we still have a packege we need to move it before we can install it
if [[ -f "$working_installer_pkg" ]]; then
Expand Down

0 comments on commit f47e267

Please sign in to comment.