@@ -186,7 +186,7 @@ struct Outset: ParsableCommand {
186186 if loginPrivileged {
187187 writeLog ( " Processing scheduled runs for privileged login " , logLevel: . info)
188188 if checkFileExists ( path: Trigger . loginPrivileged. path) {
189- pathCleanup ( pathname : Trigger . loginPrivileged. path)
189+ pathCleanup ( Trigger . loginPrivileged. path)
190190 }
191191 if !prefs. ignoredUsers. contains ( consoleUser) {
192192 if !scriptPayloads. processPayloadScripts ( ofType: . loginPrivilegedOnce, runOnceData: prefs. overrideLoginOnce) &&
@@ -208,10 +208,8 @@ struct Outset: ParsableCommand {
208208 if ![ " root " , " loginwindow " ] . contains ( consoleUser) {
209209 let currentUser = NSUserName ( )
210210 if consoleUser == currentUser {
211- if !scriptPayloads. processPayloadScripts ( ofType: . onDemand) {
212- processItems ( . onDemand)
213- }
214- createTrigger ( Trigger . onDemand. path)
211+ processItems ( . onDemand)
212+ createTrigger ( Trigger . cleanup. path)
215213 } else {
216214 writeLog ( " User \( currentUser) is not the current console user. Skipping on-demand run. " )
217215 }
@@ -222,26 +220,16 @@ struct Outset: ParsableCommand {
222220 }
223221
224222 if onDemandPrivileged {
223+ ensureRoot ( " execute on-demand-privileged " )
225224 writeLog ( " Processing on-demand-privileged " , logLevel: . debug)
226- if !folderContents( path: PayloadType . onDemandPrivileged. directoryPath) . isEmpty {
227- if ![ " root " , " loginwindow " ] . contains ( consoleUser) {
228- let currentUser = NSUserName ( )
229- if consoleUser == currentUser {
230- if !scriptPayloads. processPayloadScripts ( ofType: . onDemandPrivileged) {
231- processItems ( . onDemandPrivileged)
232- }
233- } else {
234- writeLog ( " User \( currentUser) is not the current console user. Skipping on-demand-privileged run. " )
235- }
236- } else {
237- writeLog ( " No current user session. Skipping on-demand run. " )
238- }
239- FileManager . default. createFile ( atPath: Trigger . onDemand. path, contents: nil )
240- DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.5 ) {
241- if checkFileExists ( path: Trigger . onDemand. path) {
242- pathCleanup ( pathname: Trigger . onDemand. path)
243- }
225+ if ![ " loginwindow " ] . contains ( consoleUser) {
226+ if !folderContents( path: PayloadType . onDemandPrivileged. directoryPath) . isEmpty {
227+ processItems ( . onDemandPrivileged)
228+ pathCleanup ( Trigger . onDemandPrivileged. path)
229+ pathCleanup ( PayloadType . onDemandPrivileged. directoryPath)
244230 }
231+ } else {
232+ writeLog ( " No current user session. Skipping on-demand-privileged run. " )
245233 }
246234 }
247235
@@ -268,10 +256,12 @@ struct Outset: ParsableCommand {
268256 }
269257
270258 if cleanup {
271- writeLog ( " Cleaning up on-demand directory. " , logLevel: . info)
272- if checkFileExists ( path: Trigger . onDemand. path) { pathCleanup ( pathname: Trigger . onDemand. path) }
273- if checkFileExists ( path: Trigger . cleanup. path) { pathCleanup ( pathname: Trigger . cleanup. path) }
274- if !folderContents( path: PayloadType . onDemand. directoryPath) . isEmpty { pathCleanup ( pathname: PayloadType . onDemand. directoryPath) }
259+ writeLog ( " Cleaning up on-demand directories. " , logLevel: . info)
260+ pathCleanup ( Trigger . onDemand. path)
261+ pathCleanup ( Trigger . onDemandPrivileged. path)
262+ pathCleanup ( PayloadType . onDemand. directoryPath)
263+ pathCleanup ( PayloadType . onDemandPrivileged. directoryPath)
264+ pathCleanup ( Trigger . cleanup. path)
275265 }
276266
277267 if !addIgnoredUser. isEmpty {
0 commit comments