diff --git a/.env.example b/.env.example index dc7f095..02f018d 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ # Published image to run. Use a different repository or tag if you are testing # a fork or a specific release. -PYMC_REPEATER_IMAGE=pymcdev/openhop-repeater:main +OPENHOP_REPEATER_IMAGE=openhop/openhop-repeater:main # Storage defaults to Docker named volumes. This is the safest option for # Portainer and fresh installs because Docker preserves the image ownership. @@ -12,8 +12,8 @@ PYMC_REPEATER_IMAGE=pymcdev/openhop-repeater:main # sudo mkdir -p /opt/openhop-repeater/config /opt/openhop-repeater/data # sudo chown -R 15888:15888 /opt/openhop-repeater/config /opt/openhop-repeater/data # Then uncomment and adjust these paths: -# PYMC_CONFIG_VOLUME=/opt/openhop-repeater/config -# PYMC_DATA_VOLUME=/opt/openhop-repeater/data +# OPENHOP_CONFIG_VOLUME=/opt/openhop-repeater/config +# OPENHOP_DATA_VOLUME=/opt/openhop-repeater/data # Serial/SPI/GPIO access uses the host's numeric group IDs. Check your host with: # getent group dialout @@ -29,6 +29,6 @@ GPIO_GID=986 SPI_GID=989 # Local build only. These are used by docker-compose.build.yml if you build the -# image yourself instead of pulling PYMC_REPEATER_IMAGE. +# image yourself instead of pulling OPENHOP_REPEATER_IMAGE. PUID=15888 PGID=15888 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b4cf957..56ded0e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -61,7 +61,7 @@ jobs: elif [ "${{ github.repository }}" = "yellowcooln/openhop_repeater" ]; then image_repository="yellowcooln/openhop-repeater" else - image_repository="pymcdev/openhop-repeater" + image_repository="openhop/openhop-repeater" fi echo "Using image repository: ${image_repository}" diff --git a/README.md b/README.md index aac75e9..4596958 100644 --- a/README.md +++ b/README.md @@ -418,7 +418,7 @@ that source as a directory, which breaks startup. ### Setup 1. Copy `.env.example` to `.env`. -2. Review `.env` and update `PYMC_REPEATER_IMAGE`, `DIALOUT_GID`, +2. Review `.env` and update `OPENHOP_REPEATER_IMAGE`, `DIALOUT_GID`, `GPIO_GID`, or `SPI_GID` if needed. 3. Configure `docker-compose.yml` for your hardware and device paths. 4. Uncomment the USB device mapping only if your host has that device path. @@ -433,7 +433,7 @@ docker compose up -d ```yaml services: openhop-repeater: - image: ${PYMC_REPEATER_IMAGE:-pymcdev/openhop-repeater:main} + image: ${OPENHOP_REPEATER_IMAGE:-${PYMC_REPEATER_IMAGE:-openhop/openhop-repeater:main}} container_name: openhop-repeater restart: unless-stopped ports: @@ -457,8 +457,8 @@ services: - plugdev volumes: - - ${PYMC_CONFIG_VOLUME:-openhop-repeater-config}:/etc/openhop_repeater - - ${PYMC_DATA_VOLUME:-openhop-repeater-data}:/var/lib/openhop_repeater + - ${OPENHOP_CONFIG_VOLUME:-${PYMC_CONFIG_VOLUME:-openhop-repeater-config}}:/etc/openhop_repeater + - ${OPENHOP_DATA_VOLUME:-${PYMC_DATA_VOLUME:-openhop-repeater-data}}:/var/lib/openhop_repeater volumes: openhop-repeater-config: diff --git a/buildroot-manage.sh b/buildroot-manage.sh index 0567723..f921a15 100644 --- a/buildroot-manage.sh +++ b/buildroot-manage.sh @@ -1247,12 +1247,12 @@ prepare_git_version() { git -C "$SCRIPT_DIR" fetch --tags 2>/dev/null || true git_version=$(python3 -m setuptools_scm 2>/dev/null || echo "1.0.5") export SETUPTOOLS_SCM_PRETEND_VERSION="$git_version" - export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER="$git_version" + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENHOP_REPEATER="$git_version" info "Using version: $git_version" else git_version="1.0.5" export SETUPTOOLS_SCM_PRETEND_VERSION="$git_version" - export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER="$git_version" + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENHOP_REPEATER="$git_version" info "Using fallback version: $git_version" fi diff --git a/docker-compose.yml b/docker-compose.yml index 504cbf7..5ada43e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: openhop-repeater: - image: ${PYMC_REPEATER_IMAGE:-pymcdev/openhop-repeater:main} + image: ${OPENHOP_REPEATER_IMAGE:-${PYMC_REPEATER_IMAGE:-openhop/openhop-repeater:main}} container_name: openhop-repeater restart: unless-stopped ports: @@ -21,8 +21,8 @@ services: - "${SPI_GID:-989}" - plugdev volumes: - - ${PYMC_CONFIG_VOLUME:-openhop-repeater-config}:/etc/openhop_repeater - - ${PYMC_DATA_VOLUME:-openhop-repeater-data}:/var/lib/openhop_repeater + - ${OPENHOP_CONFIG_VOLUME:-${PYMC_CONFIG_VOLUME:-openhop-repeater-config}}:/etc/openhop_repeater + - ${OPENHOP_DATA_VOLUME:-${PYMC_DATA_VOLUME:-openhop-repeater-data}}:/var/lib/openhop_repeater volumes: openhop-repeater-config: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 504447a..4c6f835 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,7 +3,7 @@ set -eu INSTALL_DIR="${INSTALL_DIR:-/opt/openhop_repeater}" CONFIG_DIR="${CONFIG_DIR:-/etc/openhop_repeater}" -CONFIG_PATH="${PYMC_REPEATER_CONFIG:-${CONFIG_DIR}/config.yaml}" +CONFIG_PATH="${OPENHOP_REPEATER_CONFIG:-${PYMC_REPEATER_CONFIG:-${CONFIG_DIR}/config.yaml}}" EXAMPLE_PATH="${CONFIG_DIR}/config.yaml.example" BUNDLED_EXAMPLE_PATH="${INSTALL_DIR}/config.yaml.example" RUNTIME_USER="${USER:-repeater}" diff --git a/dockerfile b/dockerfile index 0b201cd..cf528a1 100644 --- a/dockerfile +++ b/dockerfile @@ -17,7 +17,7 @@ ENV INSTALL_DIR=/opt/openhop_repeater \ HOME_DIR=/home/${USER} \ PATH=/home/${USER}/.local/bin:${PATH} \ PYTHONUNBUFFERED=1 \ - SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=${PACKAGE_VERSION} \ + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENHOP_REPEATER=${PACKAGE_VERSION} \ PUID=${PUID} \ PGID=${PGID} \ DIALOUT_GID=${DIALOUT_GID} \ diff --git a/env.example b/env.example index f63e0f4..c0a3d88 100644 --- a/env.example +++ b/env.example @@ -3,7 +3,7 @@ # Published image to run. Use a different repository or tag if you are testing # a fork or a specific release. -PYMC_REPEATER_IMAGE=pymcdev/openhop-repeater:main +OPENHOP_REPEATER_IMAGE=openhop/openhop-repeater:main # Storage defaults to Docker named volumes. This is the safest option for # Portainer and fresh installs because Docker preserves the image ownership. @@ -12,8 +12,8 @@ PYMC_REPEATER_IMAGE=pymcdev/openhop-repeater:main # sudo mkdir -p /opt/openhop-repeater/config /opt/openhop-repeater/data # sudo chown -R 15888:15888 /opt/openhop-repeater/config /opt/openhop-repeater/data # Then uncomment and adjust these paths: -# PYMC_CONFIG_VOLUME=/opt/openhop-repeater/config -# PYMC_DATA_VOLUME=/opt/openhop-repeater/data +# OPENHOP_CONFIG_VOLUME=/opt/openhop-repeater/config +# OPENHOP_DATA_VOLUME=/opt/openhop-repeater/data # SPI/GPIO access uses the host's numeric group IDs. Check your host with: # getent group gpio @@ -26,6 +26,6 @@ GPIO_GID=986 SPI_GID=989 # Local build only. These are used by docker-compose.build.yml if you build the -# image yourself instead of pulling PYMC_REPEATER_IMAGE. +# image yourself instead of pulling OPENHOP_REPEATER_IMAGE. PUID=15888 PGID=15888 diff --git a/repeater/config.py b/repeater/config.py index 36265bf..a108a1e 100644 --- a/repeater/config.py +++ b/repeater/config.py @@ -195,7 +195,10 @@ def get_node_info(config: Dict[str, Any]) -> Dict[str, Any]: def load_config(config_path: Optional[str] = None) -> Dict[str, Any]: if config_path is None: - config_path = os.getenv("PYMC_REPEATER_CONFIG", "/etc/openhop_repeater/config.yaml") + config_path = os.getenv( + "OPENHOP_REPEATER_CONFIG", + os.getenv("PYMC_REPEATER_CONFIG", "/etc/openhop_repeater/config.yaml"), + ) # Check if config file exists if not Path(config_path).exists(): @@ -301,10 +304,11 @@ def load_config(config_path: Optional[str] = None) -> Dict[str, Any]: else: config["repeater"]["identity_key"] = _load_or_create_identity_key() - if os.getenv("PYMC_REPEATER_LOG_LEVEL"): + env_log_level = os.getenv("OPENHOP_REPEATER_LOG_LEVEL", os.getenv("PYMC_REPEATER_LOG_LEVEL")) + if env_log_level: if "logging" not in config: config["logging"] = {} - config["logging"]["level"] = os.getenv("PYMC_REPEATER_LOG_LEVEL") + config["logging"]["level"] = env_log_level config = _load_policy_engine_config(config, config_path) @@ -323,7 +327,10 @@ def save_config(config_data: Dict[str, Any], config_path: Optional[str] = None) True if successful, False otherwise """ if config_path is None: - config_path = os.getenv("PYMC_REPEATER_CONFIG", "/etc/openhop_repeater/config.yaml") + config_path = os.getenv( + "OPENHOP_REPEATER_CONFIG", + os.getenv("PYMC_REPEATER_CONFIG", "/etc/openhop_repeater/config.yaml"), + ) try: # Create backup of existing config diff --git a/tests/test_config_radio.py b/tests/test_config_radio.py index 79a7ad3..0b75b9e 100644 --- a/tests/test_config_radio.py +++ b/tests/test_config_radio.py @@ -1,6 +1,6 @@ from types import SimpleNamespace -from repeater.config import BaselineCrcCounterRadio +from repeater.config import BaselineCrcCounterRadio, load_config def test_baseline_crc_counter_radio_reports_delta_from_initial_raw_count(): @@ -26,3 +26,20 @@ def test_baseline_crc_counter_radio_handles_delayed_modem_counter(): raw.crc_error_count = 148 assert radio.crc_error_count == 3 + + +def test_load_config_prefers_openhop_env_names(tmp_path, monkeypatch): + legacy_path = tmp_path / "legacy.yaml" + openhop_path = tmp_path / "openhop.yaml" + legacy_path.write_text("repeater:\n identity_key: legacy\n", encoding="utf-8") + openhop_path.write_text("repeater:\n identity_key: openhop\n", encoding="utf-8") + + monkeypatch.setenv("PYMC_REPEATER_CONFIG", str(legacy_path)) + monkeypatch.setenv("OPENHOP_REPEATER_CONFIG", str(openhop_path)) + monkeypatch.setenv("PYMC_REPEATER_LOG_LEVEL", "WARNING") + monkeypatch.setenv("OPENHOP_REPEATER_LOG_LEVEL", "DEBUG") + + config = load_config() + + assert config["repeater"]["identity_key"] == "openhop" + assert config["logging"]["level"] == "DEBUG"