Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions agent/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
agentEnvFile = "/etc/shellhub-agent.env"
agentEnvFile = "/etc/shellhub-agent/shellhub-agent.env"
agentServiceFile = "/etc/systemd/system/shellhub-agent.service"
agentServiceName = "shellhub-agent"
)
Expand All @@ -26,7 +26,7 @@ Wants=network-online.target
Requires=local-fs.target

[Service]
EnvironmentFile=/etc/shellhub-agent.env
EnvironmentFile=/etc/shellhub-agent/shellhub-agent.env
ExecStart={{.BinaryPath}}
Restart=on-failure
RestartSec=5
Expand Down Expand Up @@ -83,12 +83,12 @@ func registerInstallerCommands(rootCmd *cobra.Command) {

installCmd.Flags().String("server-address", "", "ShellHub server address")
installCmd.Flags().String("tenant-id", "", "Namespace tenant ID")
installCmd.Flags().String("private-key", "/etc/shellhub.key", "Path to the agent private key file")
installCmd.Flags().String("private-key", "/etc/shellhub-agent/shellhub.key", "Path to the agent private key file")
installCmd.Flags().String("preferred-hostname", "", "Preferred device hostname")
installCmd.Flags().String("preferred-identity", "", "Preferred device identity")
installCmd.Flags().Uint("keepalive-interval", 30, "Keepalive interval in seconds")
installCmd.MarkFlagRequired("server-address") //nolint:errcheck
installCmd.MarkFlagRequired("tenant-id") //nolint:errcheck
installCmd.MarkFlagRequired("tenant-id") //nolint:errcheck

rootCmd.AddCommand(installCmd)

Expand Down Expand Up @@ -131,6 +131,10 @@ func agentInstall(cfg installerConfig) error {
return fmt.Errorf("failed to resolve symlinks: %w", err)
}

if err := os.MkdirAll(filepath.Dir(agentEnvFile), 0755); err != nil {
return fmt.Errorf("failed to create directory %s: %w", filepath.Dir(agentEnvFile), err)
}

if err := writeAgentEnvFile(cfg); err != nil {
return fmt.Errorf("failed to write env file: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/packaging/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"__PREFERRED_HOSTNAME__",
"__PREFERRED_IDENTITY__",
"__KEEPALIVE_INTERVAL__",
"SHELLHUB_PRIVATE_KEY=/host/etc/shellhub.key"
"SHELLHUB_PRIVATE_KEY=/host/etc/shellhub-agent/shellhub.key"
],
"cwd": "/",
"capabilities": {
Expand Down
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ podman_install() {
esac

if [ -z "$MODE" ]; then
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEY=${PRIVATE_KEY:-/host/etc/shellhub.key}"
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEY=${PRIVATE_KEY:-/host/etc/shellhub-agent/shellhub.key}"

echo "🚀 Starting ShellHub container in Agent mode..."
fi
Expand Down Expand Up @@ -106,7 +106,7 @@ docker_install() {
esac

if [ -z "$MODE" ]; then
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEY=${PRIVATE_KEY:-/host/etc/shellhub.key}"
ARGS="$ARGS -e SHELLHUB_PRIVATE_KEY=${PRIVATE_KEY:-/host/etc/shellhub-agent/shellhub.key}"

echo "🚀 Starting ShellHub container in Agent mode..."
fi
Expand Down Expand Up @@ -165,7 +165,7 @@ snap_install() {

sudo snap set shellhub server-address="$SERVER_ADDRESS"
sudo snap set shellhub tenant-id="$TENANT_ID"
sudo snap set shellhub private-key="${PRIVATE_KEY:-/etc/shellhub.key}"
sudo snap set shellhub private-key="${PRIVATE_KEY:-/etc/shellhub-agent/shellhub.key}"

sudo snap start shellhub
} || {
Expand Down
Loading