Run without Network Manager
This commit is contained in:
+1
-1
@@ -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_SECTION sound)
|
||||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
|
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_PACKAGING_INSTALL_PREFIX /usr)
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
|
|||||||
+5
-8
@@ -1055,7 +1055,11 @@ void Install(const fs::path &programPrefix, const std::string endpointAddress)
|
|||||||
|
|
||||||
if (!UsingNetworkManager())
|
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
|
try
|
||||||
{
|
{
|
||||||
@@ -1763,28 +1767,23 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (stop)
|
else if (stop)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
StopService();
|
StopService();
|
||||||
}
|
}
|
||||||
else if (start)
|
else if (start)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
StartService();
|
StartService();
|
||||||
}
|
}
|
||||||
else if (restart)
|
else if (restart)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
RestartService(excludeShutdownService);
|
RestartService(excludeShutdownService);
|
||||||
}
|
}
|
||||||
else if (enable)
|
else if (enable)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
EnableService();
|
EnableService();
|
||||||
FileSystemSync();
|
FileSystemSync();
|
||||||
}
|
}
|
||||||
else if (disable)
|
else if (disable)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
DisableService();
|
DisableService();
|
||||||
FileSystemSync();
|
FileSystemSync();
|
||||||
}
|
}
|
||||||
@@ -1809,7 +1808,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (disable_p2p)
|
else if (disable_p2p)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
WifiDirectConfigSettings settings;
|
WifiDirectConfigSettings settings;
|
||||||
settings.Load();
|
settings.Load();
|
||||||
settings.enable_ = false;
|
settings.enable_ = false;
|
||||||
@@ -1854,7 +1852,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (disable_hotspot)
|
else if (disable_hotspot)
|
||||||
{
|
{
|
||||||
RequireNetworkManager();
|
|
||||||
|
|
||||||
WifiConfigSettings settings;
|
WifiConfigSettings settings;
|
||||||
settings.valid_ = true;
|
settings.valid_ = true;
|
||||||
|
|||||||
+45
-2
@@ -30,6 +30,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "SysExec.hpp"
|
||||||
|
|
||||||
using namespace pipedal;
|
using namespace pipedal;
|
||||||
using namespace dbus::networkmanager;
|
using namespace dbus::networkmanager;
|
||||||
@@ -1101,9 +1102,51 @@ static std::vector<std::string> get_wireless_interfaces_sysfs()
|
|||||||
return wireless_interfaces;
|
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()
|
bool HotspotManager::HasWifiDevice()
|
||||||
{
|
{
|
||||||
// use procfs to decide this, as NetworkManager may not be available yet.
|
// use procfs to decide this, as NetworkManager may not be available yet.
|
||||||
|
if ( !(get_wireless_interfaces_sysfs().empty()) )
|
||||||
return !(get_wireless_interfaces_sysfs().empty());
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsNetworkManagerRunning())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,13 @@ void SignPackage()
|
|||||||
packagePath = fs::absolute(packagePath);
|
packagePath = fs::absolute(packagePath);
|
||||||
if (!fs::exists(packagePath))
|
if (!fs::exists(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));
|
throw std::runtime_error(SS("File does not exist: " << packagePath));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sign the package.
|
// sign the package.
|
||||||
// gpg --armor --output "$filename".asc -b "$filename"
|
// gpg --armor --output "$filename".asc -b "$filename"
|
||||||
|
|||||||
Reference in New Issue
Block a user