mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: MacOS MDM based Deployment (#277)
* fix: MacOS MDM deployment script * fix: Handle shell alias for bash on macos * fix: Code review fixes * fix: Code review fixes * feat: Add support for global config file * feat: Add support for global config file * fix: Code review fixes * fix: Avoid blocking CLI for analytics flush
This commit is contained in:
+10
-7
@@ -2,7 +2,6 @@ package setup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/safedep/pmg/config"
|
||||
@@ -13,9 +12,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
setupRemoveConfigFile = false
|
||||
)
|
||||
var setupRemoveConfigFile = false
|
||||
|
||||
func NewSetupCommand() *cobra.Command {
|
||||
setupCmd := &cobra.Command{
|
||||
@@ -51,6 +48,11 @@ func install() error {
|
||||
return fmt.Errorf("failed to write template config: %w", err)
|
||||
}
|
||||
|
||||
if config.Get().IsManaged() {
|
||||
fmt.Printf("%s %s\n", ui.Colors.Dim("ℹ"),
|
||||
fmt.Sprintf("Using globally managed config: %s", config.Get().ConfigFilePath()))
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
fmt.Printf("%s %s\n", ui.Colors.Green("✓"), "PMG config written successfully")
|
||||
fmt.Printf(" %s\n", ui.Colors.Dim(fmt.Sprintf("Config: %s", config.Get().ConfigDir())))
|
||||
@@ -92,9 +94,10 @@ func NewRemoveCommand() *cobra.Command {
|
||||
fmt.Print(ui.GeneratePMGBanner(version.Version, version.Commit))
|
||||
|
||||
if setupRemoveConfigFile {
|
||||
config := config.Get()
|
||||
if err := os.Remove(config.ConfigFilePath()); err != nil && !os.IsNotExist(err) {
|
||||
return fmt.Errorf("failed to remove config file %q: %w", config.ConfigFilePath(), err)
|
||||
// Only ever remove the per-user file; the globally managed
|
||||
// config is not ours to delete from a per-user uninstall.
|
||||
if err := config.RemoveUserConfigFile(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user