From 3d9be5098ba392389ecb9210bee0bdb42d01dd65 Mon Sep 17 00:00:00 2001 From: hakansa <43675540+hakansa@users.noreply.github.com> Date: Fri, 25 Jul 2025 18:43:48 +0300 Subject: [PATCH] [client]: deprecate config flag (#4224) --- client/cmd/login.go | 15 +++++---------- client/cmd/root.go | 1 + client/cmd/service_installer.go | 2 -- client/cmd/up.go | 14 ++++---------- release_files/systemd/netbird@.service | 2 +- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/client/cmd/login.go b/client/cmd/login.go index 482e004d1..d6381f6e2 100644 --- a/client/cmd/login.go +++ b/client/cmd/login.go @@ -26,7 +26,7 @@ import ( func init() { loginCmd.PersistentFlags().BoolVar(&noBrowser, noBrowserFlag, false, noBrowserDesc) loginCmd.PersistentFlags().StringVar(&profileName, profileNameFlag, "", profileNameDesc) - loginCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Netbird config file location") + loginCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "(DEPRECATED) Netbird config file location") } var loginCmd = &cobra.Command{ @@ -228,15 +228,10 @@ func doForegroundLogin(ctx context.Context, cmd *cobra.Command, setupKey string, // update host's static platform and system information system.UpdateStaticInfo() - var configFilePath string - if configPath != "" { - configFilePath = configPath - } else { - var err error - configFilePath, err = activeProf.FilePath() - if err != nil { - return fmt.Errorf("get active profile file path: %v", err) - } + configFilePath, err := activeProf.FilePath() + if err != nil { + return fmt.Errorf("get active profile file path: %v", err) + } config, err := profilemanager.ReadConfig(configFilePath) diff --git a/client/cmd/root.go b/client/cmd/root.go index b22b850ee..8e8ee3280 100644 --- a/client/cmd/root.go +++ b/client/cmd/root.go @@ -126,6 +126,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&preSharedKey, preSharedKeyFlag, "", "Sets Wireguard PreSharedKey property. If set, then only peers that have the same key can communicate.") rootCmd.PersistentFlags().StringVarP(&hostName, "hostname", "n", "", "Sets a custom hostname for the device") rootCmd.PersistentFlags().BoolVarP(&anonymizeFlag, "anonymize", "A", false, "anonymize IP addresses and non-netbird.io domains in logs and status output") + rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", defaultConfigPath, "(DEPRECATED) Netbird config file location") rootCmd.AddCommand(upCmd) rootCmd.AddCommand(downCmd) diff --git a/client/cmd/service_installer.go b/client/cmd/service_installer.go index c994801a6..be8a897dc 100644 --- a/client/cmd/service_installer.go +++ b/client/cmd/service_installer.go @@ -31,8 +31,6 @@ func buildServiceArguments() []string { args := []string{ "service", "run", - "--config", - configPath, "--log-level", logLevel, "--daemon-addr", diff --git a/client/cmd/up.go b/client/cmd/up.go index d1f8e67a1..98e1c02b3 100644 --- a/client/cmd/up.go +++ b/client/cmd/up.go @@ -78,7 +78,7 @@ func init() { upCmd.PersistentFlags().BoolVar(&noBrowser, noBrowserFlag, false, noBrowserDesc) upCmd.PersistentFlags().StringVar(&profileName, profileNameFlag, "", profileNameDesc) - upCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Netbird config file location") + upCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "(DEPRECATED) Netbird config file location") } @@ -155,15 +155,9 @@ func runInForegroundMode(ctx context.Context, cmd *cobra.Command, activeProf *pr return err } - var configFilePath string - if configPath != "" { - configFilePath = configPath - } else { - var err error - configFilePath, err = activeProf.FilePath() - if err != nil { - return fmt.Errorf("get active profile file path: %v", err) - } + configFilePath, err := activeProf.FilePath() + if err != nil { + return fmt.Errorf("get active profile file path: %v", err) } ic, err := setupConfig(customDNSAddressConverted, cmd, configFilePath) diff --git a/release_files/systemd/netbird@.service b/release_files/systemd/netbird@.service index 095c3142d..48e8cc29d 100644 --- a/release_files/systemd/netbird@.service +++ b/release_files/systemd/netbird@.service @@ -7,7 +7,7 @@ Wants=network-online.target [Service] Type=simple EnvironmentFile=-/etc/default/netbird -ExecStart=/usr/bin/netbird service run --log-file /var/log/netbird/client-%i.log --config /etc/netbird/%i.json --daemon-addr unix:///var/run/netbird/%i.sock $FLAGS +ExecStart=/usr/bin/netbird service run --log-file /var/log/netbird/client-%i.log --daemon-addr unix:///var/run/netbird/%i.sock $FLAGS Restart=on-failure RestartSec=5 TimeoutStopSec=10