From 206dbfa073c7bf13e456b5cdba6b92b41ec8b6aa Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Tue, 21 Apr 2026 17:57:18 +0200 Subject: [PATCH] build: install systemd service and PAM configuration --- CMakeLists.txt | 13 ++++++++++++- mars-nwe-webui.service.cmake | 25 +++++++++++++++++++++++++ smart.pamd | 4 ++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 mars-nwe-webui.service.cmake create mode 100644 smart.pamd diff --git a/CMakeLists.txt b/CMakeLists.txt index b4e33d2..360420a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,13 @@ configure_file( "${CMAKE_CURRENT_BINARY_DIR}/static/start.html" IMMEDIATE @ONLY) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/mars-nwe-webui.service.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mars-nwe-webui.service" + @ONLY +) + + ################################# # Compiler Switches ############## @@ -67,6 +74,7 @@ target_link_libraries(check_login install(FILES ${CMAKE_CURRENT_BINARY_DIR}/smart.conf DESTINATION ${MARS_NWE_INSTALL_FULL_CONFDIR}) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/smart DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}) +install(FILES smart.pamd DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/pam.d RENAME smart) install(PROGRAMS apply.pl DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}) install(PROGRAMS readconfig.pl DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}) @@ -79,8 +87,11 @@ install(FILES static/smart_icon.jpg DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECD install(FILES static/smart.jpg DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}/static) install(FILES static/favicon.ico DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}/static) - +if(WITH_SYSTEMD) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mars-nwe-webui.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}) +endif() install(TARGETS check_login DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}) install(TARGETS nwwebui DESTINATION ${CMAKE_INSTALL_SBINDIR}) + diff --git a/mars-nwe-webui.service.cmake b/mars-nwe-webui.service.cmake new file mode 100644 index 0000000..2005c46 --- /dev/null +++ b/mars-nwe-webui.service.cmake @@ -0,0 +1,25 @@ +[Unit] +Description=MARS NWE Web UI +After=network.target mars-nwe-serv.service +Wants=network.target +Documentation=man:systemd.service(5) + +[Service] +Type=simple +User=root +Group=root +WorkingDirectory=/ + +ExecStartPre=/bin/mkdir -p @MARS_NWE_LOG_DIR@ +ExecStartPre=/bin/mkdir -p @MARS_NWE_PID_DIR@ +ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/nwwebui -c @MARS_NWE_INSTALL_FULL_CONFDIR@/smart.conf +Restart=on-failure +RestartSec=2 + +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=full +ProtectHome=true + +[Install] +WantedBy=multi-user.target diff --git a/smart.pamd b/smart.pamd new file mode 100644 index 0000000..c118e79 --- /dev/null +++ b/smart.pamd @@ -0,0 +1,4 @@ +auth required pam_unix.so +account required pam_unix.so +password required pam_unix.so +session required pam_unix.so