@@ -14,7 +14,7 @@ import (
1414)
1515
1616const (
17- agentEnvFile = "/etc/shellhub-agent.env"
17+ agentEnvFile = "/etc/shellhub-agent/shellhub-agent .env"
1818 agentServiceFile = "/etc/systemd/system/shellhub-agent.service"
1919 agentServiceName = "shellhub-agent"
2020)
@@ -26,7 +26,7 @@ Wants=network-online.target
2626Requires=local-fs.target
2727
2828[Service]
29- EnvironmentFile=/etc/shellhub-agent.env
29+ EnvironmentFile=/etc/shellhub-agent/shellhub-agent .env
3030ExecStart={{.BinaryPath}}
3131Restart=on-failure
3232RestartSec=5
@@ -83,12 +83,12 @@ func registerInstallerCommands(rootCmd *cobra.Command) {
8383
8484 installCmd .Flags ().String ("server-address" , "" , "ShellHub server address" )
8585 installCmd .Flags ().String ("tenant-id" , "" , "Namespace tenant ID" )
86- installCmd .Flags ().String ("private-key" , "/etc/shellhub.key" , "Path to the agent private key file" )
86+ installCmd .Flags ().String ("private-key" , "/etc/shellhub-agent/shellhub .key" , "Path to the agent private key file" )
8787 installCmd .Flags ().String ("preferred-hostname" , "" , "Preferred device hostname" )
8888 installCmd .Flags ().String ("preferred-identity" , "" , "Preferred device identity" )
8989 installCmd .Flags ().Uint ("keepalive-interval" , 30 , "Keepalive interval in seconds" )
9090 installCmd .MarkFlagRequired ("server-address" ) //nolint:errcheck
91- installCmd .MarkFlagRequired ("tenant-id" ) //nolint:errcheck
91+ installCmd .MarkFlagRequired ("tenant-id" ) //nolint:errcheck
9292
9393 rootCmd .AddCommand (installCmd )
9494
@@ -131,6 +131,10 @@ func agentInstall(cfg installerConfig) error {
131131 return fmt .Errorf ("failed to resolve symlinks: %w" , err )
132132 }
133133
134+ if err := os .MkdirAll (filepath .Dir (agentEnvFile ), 0755 ); err != nil {
135+ return fmt .Errorf ("failed to create directory %s: %w" , filepath .Dir (agentEnvFile ), err )
136+ }
137+
134138 if err := writeAgentEnvFile (cfg ); err != nil {
135139 return fmt .Errorf ("failed to write env file: %w" , err )
136140 }
0 commit comments