Skip to content

Commit

Permalink
fix: retrieve MAC address from host (#1929)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomiguelino authored Jan 20, 2025
1 parent a92c462 commit c28bb7b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bin/upgrade_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if [[ ! "$MODE" =~ ^(pull|build)$ ]]; then
exit 1
fi

# The `getmac` module might exit with non-zero exit code if no MAC address is found.
set +e
export MAC_ADDRESS=`${HOME}/installer_venv/bin/python -m getmac`
set -e

if [ -z "$DOCKER_TAG" ]; then
export DOCKER_TAG="latest"
fi
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
dockerfile: docker/Dockerfile.server
environment:
- MY_IP=${MY_IP}
- MAC_ADDRESS=${MAC_ADDRESS}
- HOST_USER=${USER}
- HOME=/data
- LISTEN=0.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_node_mac_address():
return r.json()['mac_address']
return 'Unknown'

return 'Unable to retrieve MAC address.'
return os.getenv('MAC_ADDRESS', 'Unable to retrieve MAC address.')


def get_active_connections(bus, fields=None):
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements.host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ansible-core==2.15.9
docker==6.0.0
getmac==0.9.4
netifaces2==0.0.22
redis==4.3.4
requests[security]==2.32.3
Expand Down

0 comments on commit c28bb7b

Please sign in to comment.