Skip to content

Commit

Permalink
Merge pull request #29 from macadmins/development
Browse files Browse the repository at this point in the history
Outset 4.0.2
  • Loading branch information
bartreardon authored Jun 1, 2023
2 parents 573ae20 + 52b1dfd commit b095ec1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Outset.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0.1;
MARKETING_VERSION = 4.0.2;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -505,7 +505,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0.1;
MARKETING_VERSION = 4.0.2;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -543,7 +543,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0.1;
MARKETING_VERSION = 4.0.2;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -585,7 +585,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0.1;
MARKETING_VERSION = 4.0.2;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
44 changes: 26 additions & 18 deletions Outset/Functions/SystemUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ extension String {
}
}

enum Action {
case enable
case disable
}

func ensureRoot(_ reason: String) {
if !isRoot() {
writeLog("Must be root to \(reason)", logLevel: .error)
Expand All @@ -53,13 +58,13 @@ func getValueForKey(_ key: String, inArray array: [String: String]) -> String? {
}

func writeLog(_ message: String, logLevel: OSLogType = .info, log: OSLog = osLog) {
let logMessage = "\(message)"

os_log("%{public}@", log: log, type: logLevel, logMessage)
// write to the system logs
os_log("%{public}@", log: log, type: logLevel, message)
if logLevel == .error || logLevel == .info || (debugMode && logLevel == .debug) {
// print info, errors and debug to stdout
print("\(oslogTypeToString(logLevel).uppercased()): \(message)")
}
// also write to a log file for accessability of those that don't want to manage the system log
writeFileLog(message: message, logLevel: logLevel)
}

Expand Down Expand Up @@ -109,9 +114,12 @@ func oslogTypeToString(_ type: OSLogType) -> String {

func getConsoleUserInfo() -> (username: String, userID: String) {
// We need the console user, not the process owner so NSUserName() won't work for our needs when outset runs as root
let consoleUserName = runShellCommand("who | grep 'console' | awk '{print $1}'").output
let consoleUserID = runShellCommand("id -u \(consoleUserName)").output
return (consoleUserName.trimmingCharacters(in: .whitespacesAndNewlines), consoleUserID.trimmingCharacters(in: .whitespacesAndNewlines))
var uid: uid_t = 0
if let consoleUser = SCDynamicStoreCopyConsoleUser(nil, &uid, nil) as? String {
return (consoleUser, "\(uid)")
} else {
return ("", "")
}
}

func writePreferences(prefs: OutsetPreferences) {
Expand Down Expand Up @@ -246,18 +254,18 @@ func waitForNetworkUp(timeout: Double) -> Bool {
return networkUp
}

func loginWindowDisable() {
// Disables the loginwindow process
writeLog("Disabling loginwindow process", logLevel: .debug)
let cmd = "/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.loginwindow.plist"
_ = runShellCommand(cmd)
}

func loginWindowEnable() {
// Enables the loginwindow process
writeLog("Enabling loginwindow process", logLevel: .debug)
let cmd = "/bin/launchctl load /System/Library/LaunchDaemons/com.apple.loginwindow.plist"
_ = runShellCommand(cmd)
func loginWindowUpdateState(_ action: Action) {
var cmd : String
var loginWindowPlist : String = "/System/Library/LaunchDaemons/com.apple.loginwindow.plist"
switch action {
case .enable:
writeLog("Enabling loginwindow process", logLevel: .debug)
cmd = "/bin/launchctl load \(loginWindowPlist)"
case .disable:
writeLog("Disabling loginwindow process", logLevel: .debug)
cmd = "/bin/launchctl unload \(loginWindowPlist)"
}
_ = runShellCommand(cmd)
}

func getDeviceHardwareModel() -> String {
Expand Down
4 changes: 2 additions & 2 deletions Outset/Outset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct Outset: ParsableCommand {
if !folderContents(path: bootOnceDir).isEmpty {
if networkWait {
loginwindowState = false
loginWindowDisable()
loginWindowUpdateState(.disable)
continueFirstBoot = waitForNetworkUp(timeout: floor(Double(networkTimeout) / 10))
}
if continueFirstBoot {
Expand All @@ -155,7 +155,7 @@ struct Outset: ParsableCommand {
writeLog("Unable to connect to network. Skipping boot-once scripts...", logLevel: .error)
}
if !loginwindowState {
loginWindowEnable()
loginWindowUpdateState(.enable)
}
}

Expand Down

0 comments on commit b095ec1

Please sign in to comment.