Skip to content
Open
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
11 changes: 10 additions & 1 deletion daemon/core/services/defaults/frrservices/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from core.nodes.physical import Rj45Node
from core.nodes.wireless import WirelessNode
from core.services.base import CoreService
from core.nodes.base import CoreNode

GROUP: str = "FRR"
FRR_STATE_DIR: str = "/var/run/frr"
Expand Down Expand Up @@ -92,6 +93,14 @@ class FRRZebra(CoreService):
startup: list[str] = ["bash frrboot.sh zebra"]
validate: list[str] = ["pidof zebra"]
shutdown: list[str] = ["pkill -f zebra"]
path: str = "/usr/local/sbin /usr/sbin /usr/lib/frr /usr/libexec/frr"

def __init__(self, node: CoreNode = None) -> None:
CoreService.__init__(self, node)
self.path = self.node.session.options.get(
"frr_sbin_search",
default=self.path,
).strip('"')

def data(self) -> dict[str, Any]:
frr_conf = self.files[0]
Expand All @@ -100,7 +109,7 @@ def data(self) -> dict[str, Any]:
).strip('"')
frr_sbin_search = self.node.session.options.get(
"frr_sbin_search",
default="/usr/local/sbin /usr/sbin /usr/lib/frr /usr/libexec/frr",
default=self.path,
).strip('"')

services = []
Expand Down
2 changes: 1 addition & 1 deletion daemon/core/services/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def add(self, service: type[CoreService]) -> None:
# validate dependent executables are present
for executable in service.executables:
try:
utils.which(executable, required=True)
utils.which(executable, required=True, path=hasattr(service, "path") and service.path or None)
except CoreError as e:
raise CoreError(f"service({service.name}): {e}")

Expand Down
4 changes: 2 additions & 2 deletions daemon/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def close_onexec(fd: int) -> None:
fcntl.fcntl(fd, fcntl.F_SETFD, fdflags | fcntl.FD_CLOEXEC)


def which(command: str, required: bool) -> str | None:
def which(command: str, required: bool, path: str | None = None) -> str | None:
"""
Find location of desired executable within current PATH.

Expand All @@ -155,7 +155,7 @@ def which(command: str, required: bool) -> str | None:
:return: command location or None
:raises ValueError: when not found and required
"""
found_path = shutil.which(command)
found_path = shutil.which(command, path=path and path.replace(" ", ":"))
if found_path is None and required:
raise CoreError(f"failed to find required executable({command}) in path")
return found_path
Expand Down