Change Shutdown service name to PiPedalSupervisor

Fixes #17
This commit is contained in:
Robin Davies
2022-03-11 12:06:32 -05:00
parent f60c85070d
commit c3da75ba34
4 changed files with 49 additions and 22 deletions
+3 -3
View File
@@ -228,7 +228,7 @@ add_executable(pipedalconfig json.cpp json.hpp
target_link_libraries(pipedalconfig PRIVATE pthread atomic stdc++fs
)
add_executable(pipedalshutdownd ShutdownMain.cpp CommandLineParser.hpp
add_executable(pipedaladmind ShutdownMain.cpp CommandLineParser.hpp
JackServerSettings.hpp JackServerSettings.cpp
json.hpp json.cpp HtmlHelper.hpp HtmlHelper.cpp Lv2Log.hpp Lv2Log.cpp
Lv2SystemdLogger.hpp Lv2SystemdLogger.cpp
@@ -239,7 +239,7 @@ add_executable(pipedalshutdownd ShutdownMain.cpp CommandLineParser.hpp
CpuGovernor.cpp CpuGovernor.hpp
asan_options.cpp
)
target_link_libraries(pipedalshutdownd PRIVATE pthread atomic stdc++fs systemd)
target_link_libraries(pipedaladmind PRIVATE pthread atomic stdc++fs systemd)
add_executable(processcopyrights copyrightMain.cpp
@@ -283,7 +283,7 @@ add_custom_target (
)
install (TARGETS pipedalconfig pipedald pipedalshutdownd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
install (TARGETS pipedalconfig pipedald pipedaladmind DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
EXPORT pipedalTargets)
+29 -13
View File
@@ -53,9 +53,12 @@ using namespace pipedal;
#define SERVICE_PATH "/usr/lib/systemd/system"
#define NATIVE_SERVICE "pipedald"
#define SHUTDOWN_SERVICE "pipedalshutdownd"
#define ADMIN_SERVICE "pipedaladmind"
#define JACK_SERVICE "jack"
#define REMOVE_OLD_SERVICE 1 // Grandfathering: whether to remove the old shutdown service (now pipedaladmind)
#define OLD_SHUTDOWN_SERVICE "pipedalshutdownd"
std::filesystem::path GetServiceFileName(const std::string &serviceName)
{
return std::filesystem::path(SERVICE_PATH) / (serviceName + ".service");
@@ -92,9 +95,9 @@ void EnableService()
{
cout << "Error: Failed to enable the " NATIVE_SERVICE " service.";
}
if (sysExec(SYSTEMCTL_BIN " enable " SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
if (sysExec(SYSTEMCTL_BIN " enable " ADMIN_SERVICE ".service") != EXIT_SUCCESS)
{
cout << "Error: Failed to enable the " SHUTDOWN_SERVICE " service.";
cout << "Error: Failed to enable the " ADMIN_SERVICE " service.";
}
}
void DisableService()
@@ -103,10 +106,16 @@ void DisableService()
{
cout << "Error: Failed to disable the " NATIVE_SERVICE " service.";
}
if (sysExec(SYSTEMCTL_BIN " disable " SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
if (sysExec(SYSTEMCTL_BIN " disable " ADMIN_SERVICE ".service") != EXIT_SUCCESS)
{
cout << "Error: Failed to disable the " SHUTDOWN_SERVICE " service.";
cout << "Error: Failed to disable the " ADMIN_SERVICE " service.";
}
#if REMOVE_OLD_SERVICE
if (sysExec(SYSTEMCTL_BIN " disable " OLD_SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
{
cout << "Error: Failed to disable the " OLD_SHUTDOWN_SERVICE " service.";
}
#endif
}
void StopService(bool excludeShutdownService = false)
@@ -117,10 +126,16 @@ void StopService(bool excludeShutdownService = false)
}
if (!excludeShutdownService)
{
if (sysExec(SYSTEMCTL_BIN " stop " SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
if (sysExec(SYSTEMCTL_BIN " stop " ADMIN_SERVICE ".service") != EXIT_SUCCESS)
{
cout << "Error: Failed to stop the " SHUTDOWN_SERVICE " service.";
cout << "Error: Failed to stop the " ADMIN_SERVICE " service.";
}
#if REMOVE_OLD_SERVICE
if (sysExec(SYSTEMCTL_BIN " stop " OLD_SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
{
cout << "Error: Failed to stop the " OLD_SHUTDOWN_SERVICE " service.";
}
#endif
}
if (sysExec(SYSTEMCTL_BIN " stop " JACK_SERVICE ".service") != EXIT_SUCCESS)
{
@@ -134,9 +149,9 @@ void StartService(bool excludeShutdownService = false)
silentSysExec("/usr/bin/pulseaudio --kill"); // interferes with Jack audio service startup.
if (!excludeShutdownService)
{
if (sysExec(SYSTEMCTL_BIN " start " SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS)
if (sysExec(SYSTEMCTL_BIN " start " ADMIN_SERVICE ".service") != EXIT_SUCCESS)
{
throw PiPedalException("Failed to start the " SHUTDOWN_SERVICE " service.");
throw PiPedalException("Failed to start the " ADMIN_SERVICE " service.");
}
}
if (sysExec(SYSTEMCTL_BIN " start " NATIVE_SERVICE ".service") != EXIT_SUCCESS)
@@ -393,7 +408,8 @@ void Uninstall()
DisableService();
silentSysExec(SYSTEMCTL_BIN " stop jack");
silentSysExec(SYSTEMCTL_BIN " disable jack");
std::filesystem::remove("/usr/bin/systemd/system/" SHUTDOWN_SERVICE ".service");
std::filesystem::remove("/usr/bin/systemd/system/" OLD_SHUTDOWN_SERVICE ".service");
std::filesystem::remove("/usr/bin/systemd/system/" ADMIN_SERVICE ".service");
std::filesystem::remove("/usr/bin/systemd/system/" NATIVE_SERVICE ".service");
std::filesystem::remove("/usr/bin/systemd/system/" JACK_SERVICE ".service");
UninstallPamEnv();
@@ -533,7 +549,7 @@ void Install(const std::filesystem::path &programPrefix, const std::string endpo
s << findOnPath("authbind").string() << " --deep ";
}
s
<< (programPrefix / "bin/pipedald").string()
<< (programPrefix / "bin" / NATIVE_SERVICE).string()
<< " /etc/pipedal/config /etc/pipedal/react -port " << endpointAddress << " -systemd -shutdownPort " << shutdownPort;
map["COMMAND"] = s.str();
@@ -545,12 +561,12 @@ void Install(const std::filesystem::path &programPrefix, const std::string endpo
std::stringstream s;
s
<< (programPrefix / "bin/pipedalshutdownd").string()
<< (programPrefix / "bin" / ADMIN_SERVICE).string()
<< " -port " << shutdownPort;
map["COMMAND"] = s.str();
}
WriteTemplateFile(map, std::filesystem::path("/etc/pipedal/templateShutdown.service"), GetServiceFileName(SHUTDOWN_SERVICE));
WriteTemplateFile(map, std::filesystem::path("/etc/pipedal/templateShutdown.service"), GetServiceFileName(ADMIN_SERVICE));
sysExec(SYSTEMCTL_BIN " daemon-reload");
+1 -1
View File
@@ -14,7 +14,7 @@ ExecStart=/etc/jackdrc
User=jack
Group=audio
Restart=always
RestartSec=15
RestartSec=30
Environment=JACK_PROMISCUOUS_SERVER=audio
Environment=JACK_NO_AUDIO_RESERVATION=1