Run without Network Manager

This commit is contained in:
Robin E. R. Davies
2025-02-23 21:31:08 -05:00
parent 94b6ad930b
commit d954c06dc1
4 changed files with 56 additions and 11 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IoT guitar effect pedal for Raspberry Pi"
set(CPACK_DEBIAN_PACKAGE_SECTION sound)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "lv2-dev, authbind, curl, gpg" )
set(CPACK_DEBIAN_PACKAGE_DEPENDS "lv2-dev, authbind, curl, gpg, alsa-base, alsa-utils" )
set(CPACK_PACKAGING_INSTALL_PREFIX /usr)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
+5 -8
View File
@@ -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
View File
@@ -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());
}
+6 -1
View File
@@ -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.