Skip to content

Commit

Permalink
feat: update ingestion logic to close app in install script
Browse files Browse the repository at this point in the history
  • Loading branch information
jahzielv committed Jan 7, 2025
1 parent c682676 commit 697898a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/mdm/maintainedapps/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func installScriptForApp(app maintainedApp, cask *brewCask) (string, error) {

sb.AddVariable("TMPDIR", `$(dirname "$(realpath $INSTALLER_PATH)")`)
sb.AddVariable("APPDIR", `"/Applications/"`)
sb.AddFunction("quit_application", quitApplicationFunc)

formats := strings.Split(app.InstallerFormat, ":")
sb.Extract(formats[0])
Expand All @@ -23,7 +24,9 @@ func installScriptForApp(app maintainedApp, cask *brewCask) (string, error) {
switch {
case len(artifact.App) > 0:
sb.Write("# copy to the applications folder")
sb.Writef("quit_application '%s'", app.BundleIdentifier)
for _, appPath := range artifact.App {
sb.Writef(`sudo [ -d "$APPDIR/%[1]s" ] && sudo mv "$APPDIR/%[1]s" "$TMPDIR/%[1]s.bkp"`, appPath)
sb.Copy(appPath, "$APPDIR")
}

Expand Down Expand Up @@ -269,7 +272,6 @@ hdiutil detach "$MOUNT_POINT"`)
// Copy writes a command to copy a file from the temporary directory to a
// destination.
func (s *scriptBuilder) Copy(file, dest string) {
s.Writef(`sudo [ -f "$APPDIR/%s" ] && sudo mv "$APPDIR/%s" "$TMPDIR/%s.bkp"`, file, file, file)
s.Writef(`sudo cp -R "$TMPDIR/%s" "%s"`, file, dest)
}

Expand Down

0 comments on commit 697898a

Please sign in to comment.