Run without Network Manager
This commit is contained in:
+5
-8
@@ -1055,7 +1055,11 @@ void Install(const fs::path &programPrefix, const std::string endpointAddress)
|
||||
|
||||
if (!UsingNetworkManager())
|
||||
{
|
||||
throw std::runtime_error("The current OS is not using NetworkManager. Services not configured.");
|
||||
cout << "Warning: The current OS is not using the NetworkManager network stack." << endl;
|
||||
cout << " The PiPedal Auto-Hotspot feature will be disabled." << endl << endl;
|
||||
cout << " Consult PiPedal documentation to find out how to correct this " << endl;
|
||||
cout << " issue on Ubuntu Server." << endl;
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -1763,28 +1767,23 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else if (stop)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
StopService();
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
StartService();
|
||||
}
|
||||
else if (restart)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
RestartService(excludeShutdownService);
|
||||
}
|
||||
else if (enable)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
EnableService();
|
||||
FileSystemSync();
|
||||
}
|
||||
else if (disable)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
DisableService();
|
||||
FileSystemSync();
|
||||
}
|
||||
@@ -1809,7 +1808,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else if (disable_p2p)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
WifiDirectConfigSettings settings;
|
||||
settings.Load();
|
||||
settings.enable_ = false;
|
||||
@@ -1854,7 +1852,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else if (disable_hotspot)
|
||||
{
|
||||
RequireNetworkManager();
|
||||
|
||||
WifiConfigSettings settings;
|
||||
settings.valid_ = true;
|
||||
|
||||
+44
-1
@@ -30,6 +30,7 @@
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
#include "SysExec.hpp"
|
||||
|
||||
using namespace pipedal;
|
||||
using namespace dbus::networkmanager;
|
||||
@@ -1101,9 +1102,51 @@ static std::vector<std::string> get_wireless_interfaces_sysfs()
|
||||
return wireless_interfaces;
|
||||
}
|
||||
|
||||
static bool gNetworkManagerTestExecuted = false;
|
||||
static bool gUsingNetworkManager = false;
|
||||
|
||||
static bool IsNetworkManagerRunning()
|
||||
{
|
||||
if (gNetworkManagerTestExecuted)
|
||||
{
|
||||
return gUsingNetworkManager;
|
||||
}
|
||||
bool bResult = false;
|
||||
auto result = sysExecForOutput("systemctl","is-active NetworkManager");
|
||||
if (result.exitCode == EXIT_SUCCESS)
|
||||
{
|
||||
std::string text = result.output.erase(result.output.find_last_not_of(" \n\r\t")+1);
|
||||
if (text == "active")
|
||||
{
|
||||
bResult = true;
|
||||
} else if (text == "inactive")
|
||||
{
|
||||
bResult = false;
|
||||
} else {
|
||||
throw std::runtime_error(SS("UsingNetworkManager: unexpected result (" << text << ")"));
|
||||
}
|
||||
gNetworkManagerTestExecuted = true;
|
||||
gUsingNetworkManager = bResult;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
// does the neworkManager service path exists?
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool HotspotManager::HasWifiDevice()
|
||||
{
|
||||
// use procfs to decide this, as NetworkManager may not be available yet.
|
||||
if ( !(get_wireless_interfaces_sysfs().empty()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsNetworkManagerRunning())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return !(get_wireless_interfaces_sysfs().empty());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,12 @@ void SignPackage()
|
||||
packagePath = fs::absolute(packagePath);
|
||||
if (!fs::exists(packagePath))
|
||||
{
|
||||
throw std::runtime_error(SS("File does not exist: " << packagePath));
|
||||
packagePath = SS("build/pipedal_" << PROJECT_VER << "_amd64.deb");
|
||||
packagePath = fs::absolute(packagePath);
|
||||
if (!fs::exists(packagePath)) {
|
||||
packagePath = SS("build/pipedal_" << PROJECT_VER << "_*.deb");
|
||||
throw std::runtime_error(SS("File does not exist: " << packagePath));
|
||||
}
|
||||
}
|
||||
|
||||
// sign the package.
|
||||
|
||||
Reference in New Issue
Block a user