Skip to content

Commit

Permalink
Quit nudge when MDM profile is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Aug 8, 2024
1 parent e19f199 commit f13a697
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Nudge/UI/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Globals {
static let snc = NSWorkspace.shared.notificationCenter
// Preferences
static let configJSON = ConfigurationManager().getConfigurationAsJSON()
static var configProfile = ConfigurationManager().getConfigurationAsProfile()
static let configProfile = ConfigurationManager().getConfigurationAsProfile()
static let nudgeDefaults = UserDefaults.standard
static let nudgeJSONPreferences = NetworkFileManager().getNudgeJSONPreferences()
// Device Properties
Expand Down
10 changes: 8 additions & 2 deletions Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Globals.nc.addObserver(
forName: UserDefaults.didChangeNotification,
object: nil,
queue: .main) { [weak self] _ in
Globals.configProfile = ConfigurationManager().getConfigurationAsProfile()
queue: .main) { _ in
if ConfigurationManager().getConfigurationAsProfile() == Globals.configProfile {
LogManager.debug("MDM Profile has been re-installed or updated but configuration is identical, no need to quit Nudge.", logger: sofaLog)
} else {
LogManager.info("MDM Profile has been re-installed or updated. Quitting Nudge to allow LaunchAgent to re-initalize with new settings.", logger: sofaLog)
nudgePrimaryState.shouldExit = true
exit(2)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ struct SMAppManager {
print(message)
if let code = exitCode { exit(Int32(code)) }
} else {
LogManager.info("\(message)", logger: uiLog)
LogManager.notice("\(message)", logger: uiLog)
}
}

Expand Down

0 comments on commit f13a697

Please sign in to comment.