Skip to content

Commit

Permalink
Add configure-agent.sh script
Browse files Browse the repository at this point in the history
Signed-off-by: Darko Draskovic <[email protected]>
  • Loading branch information
darkodraskovic committed Aug 18, 2023
1 parent ba2656d commit f3ab99b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 1 addition & 6 deletions systemd/cocos-agent.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ After=network.target
StandardOutput=file:/var/log/cocos/agent.stdout
StandardError=file:/var/log/cocos/agent.stderr

Environment=NETWORK_INTERFACE=enp0s3
Environment=AGENT_GRPC_ADDR=10.0.2.15:7002
Environment=AGENT_LOG_LEVEL=info

ExecStartPre=ip link set dev $NETWORK_INTERFACE up
ExecStartPre=dhclient $NETWORK_INTERFACE
ExecStartPre=mkdir -p /var/log/cocos
ExecStartPre=source /cocos/configure-agent.sh

ExecStart=/cocos/agent

Expand Down
11 changes: 11 additions & 0 deletions systemd/configure-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Determine the network interface's name
NETWORK_INTERFACE=$(ip addr | awk '/^2: /{sub(/:/, "", $2); print $2}')

# Determine the IP address of the network interface
AGENT_GRPC_ADDR=$(ip addr show dev "$NETWORK_INTERFACE" | awk '/inet / { print $2 }' | cut -d/ -f1):7002

# Set the environment variables
export NETWORK_INTERFACE
export AGENT_GRPC_ADDR

0 comments on commit f3ab99b

Please sign in to comment.