configure_network: remove hardcoded paths to ifup/ifdown

Origin commit data
------------------
Commit: a897aafb6e
Author: vanhofen <vanhofen@gmx.de>
Date: 2022-06-12 (Sun, 12 Jun 2022)

Origin message was:
------------------
- configure_network: remove hardcoded paths to ifup/ifdown
This commit is contained in:
vanhofen
2022-06-12 22:59:08 +02:00
parent 8a0108e505
commit 23586eb49f

View File

@@ -214,26 +214,37 @@ void CNetworkConfig::commitConfig(void)
void CNetworkConfig::startNetwork(void) void CNetworkConfig::startNetwork(void)
{ {
std::string cmd = "/sbin/ifup " + ifname; std::string ifup = find_executable("ifup");
if (ifup.empty())
{
printf("CNetworkConfig::startNetwork: ifup not found\n");
return;
}
std::string cmd = ifup + " " + ifname;
#ifdef DEBUG #ifdef DEBUG
printf("CNetworkConfig::startNetwork: %s\n", cmd.c_str()); printf("CNetworkConfig::startNetwork: %s\n", cmd.c_str());
#endif #endif
my_system(3, "/bin/sh", "-c", cmd.c_str()); my_system(3, "/bin/sh", "-c", cmd.c_str());
if (!inet_static) { if (!inet_static)
init_vars(); init_vars();
}
//mysystem((char *) "ifup", (char *) "-v", (char *) "eth0");
} }
void CNetworkConfig::stopNetwork(void) void CNetworkConfig::stopNetwork(void)
{ {
std::string cmd = "/sbin/ifdown " + ifname; std::string ifdown = find_executable("ifdown");
if (ifdown.empty())
{
printf("CNetworkConfig::stopNetwork: ifdown not found\n");
return;
}
std::string cmd = ifdown + " " + ifname;
#ifdef DEBUG #ifdef DEBUG
printf("CNetworkConfig::stopNetwork: %s\n", cmd.c_str()); printf("CNetworkConfig::stopNetwork: %s\n", cmd.c_str());
#endif #endif
my_system(3, "/bin/sh", "-c", cmd.c_str()); my_system(3, "/bin/sh", "-c", cmd.c_str());
} }
void CNetworkConfig::readWpaConfig() void CNetworkConfig::readWpaConfig()