Closed mattetti closed 7 years ago
The reason we use the Linux-standard hard-coded full paths is to avoid relying on $PATH, which could be missing or malformed or not include the route or ip commands.
Your suggestion roughly boils down to using PATH again, which is not what we want to do.
I would be willing to consider a patch that optionally used environment variables such as JACKPAL_GATEWAY_IP and JACKPAL_GATEWAY_ROUTE to let people override the default locations / program names.
:+1: for some kind of solution to the hard coding.
Perhaps a good solution would be use the path, and if not found then use the hard coded? Or vice versa?
I've hit this problem too.
How about trying a hard coded list of paths? There are unlikely to be more than about 4 possibilities.
If this sounds okay, I'd be happy to make the change and submit a PR.
Gave up on hard coding the paths to ip and bin.
ip
androutes
are in a different path on some of my machines and I modified the code to do the following ingateway_linux.go
.You'd probably want to memoize the paths and check on errors but I think the direction is something this pkg should consider.