Skip to content

Commit

Permalink
Save docker group id
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Sep 11, 2024
1 parent 2fe74ca commit 50af5dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions node_cli/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,4 @@ def _get_env():

TELEGRAF_TEMPLATE_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'telegraf.conf.j2')
TELEGRAF_CONFIG_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'telegraf.conf')
NODE_DOCKER_CONFIG_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'docker.json')
17 changes: 16 additions & 1 deletion node_cli/core/docker_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import grp
import enum
import json
import logging
Expand All @@ -14,7 +15,8 @@
DOCKER_SERVICE_CONFIG_DIR,
DOCKER_SERVICE_CONFIG_PATH,
DOCKER_SOCKET_PATH,
SKALE_RUN_DIR
NODE_DOCKER_CONFIG_PATH,
SKALE_RUN_DIR,
)
from node_cli.utils.helper import run_cmd
from node_cli.utils.docker_utils import docker_client, get_containers
Expand All @@ -26,6 +28,15 @@
Path = typing.Union[str, pathlib.Path]


def get_docker_group_id() -> int:
return grp.getgrnam('docker').gr_gid


def save_docker_group_id(group_id: int, path: Optional[Path] = NODE_DOCKER_CONFIG_PATH) -> None:
with open(path, 'w') as node_docker_config:
json.dump({'docker_group_id': group_id}, node_docker_config)


def get_content(filename: Path) -> Optional[str]:
if not os.path.isfile(filename):
return None
Expand Down Expand Up @@ -189,4 +200,8 @@ def configure_docker() -> None:
restart_docker_service()
wait_for_socket_initialization()

logger.info('Saving docker group id')
group_id = get_docker_group_id()
save_docker_group_id(group_id)

logger.info('Docker configuration finished')

0 comments on commit 50af5dc

Please sign in to comment.