first release 0.1.1

This commit is contained in:
Lukas Forsberg 2025-05-30 16:44:39 +02:00
parent 3d3264d8d6
commit 71f771b428
9 changed files with 41 additions and 31 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
cmake-build-debug cmake-build-debug
cmake-build-release cmake-build-release
build build
pkg
# JetBrains IDEs # JetBrains IDEs
.idea/ .idea/

4
.vscode/launch.json vendored
View File

@ -2,10 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Debug Crow App", "name": "Debug Server Admin Panel",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/app", "program": "${workspaceFolder}/build/lf-server-admin-panel",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",

View File

@ -1,26 +0,0 @@
# Maintainer: Lukas Forsberg lukas96.forsberg@gmail.com
pkgname=lf-server-admin-panel
pkgver=0.1.0
pkgrel=1
arch=('x86_64')
depends=('crow' 'asio')
pkgdesc="A Linux C++ Crow/HTMX web service to list the status of user specified systemd services"
license=('MIT')
makedepends=('cmake' 'gcc')
source=(
${pkgname}-${pkgver}.tar.gz
)
md5sums=('SKIP') # SKIP if local files
build() {
cd "$srcdir"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
make
}
package() {
install -Dm755 "$srcdir/${pkgname}" "$pkgdir/usr/bin/${pkgname}"
install -Dm644 "$srcdir/templates/index.html" "$pkgdir/usr/share/${pkgname}/templates/index.html"
install -Dm644 "$srcdir/static/htmx.min.js" "$pkgdir/usr/share/${pkgname}/static/htmx.min.js"
install -Dm644 "$srcdir/static/settings.json" "$pkgdir/usr/share/${pkgname}/static/settings.json"
install -Dm644 "$srcdir/lf-server-admin-panel.service" "$pkgdir/usr/lib/systemd/system/lf-server-admin-panel.service"
}

View File

@ -13,11 +13,11 @@ run : F5 or Run → Start Debugging
1. tar the source files to make it cleaner 1. tar the source files to make it cleaner
``` ```
tar czf lf-server-admin-panel-0.1.0.tar.gz src/ static/ templates/ lf-server-admin-panel.service CMakeLists.txt tar czf pkg/lf-server-admin-panel-0.1.1.tar.gz src/ static/ templates/ lf-server-admin-panel.service CMakeLists.txt
``` ```
2. create the package 2. create the package
``` ```
makepkg -fL makepkg -f
``` ```

View File

@ -41,6 +41,12 @@ expected<AppSettings, string> AppSettings::loadAppSettings() {
return unexpected("'services' array in JSON file is empty"); return unexpected("'services' array in JSON file is empty");
} }
if (j.contains("httpPort")) {
settings.httpPort = j["httpPort"].get<int>();
} else {
settings.httpPort = {};
}
return settings; return settings;
} }

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
#include <expected> #include <expected>
#include <optional> #include <optional>
#include <cstdint>
struct Service { struct Service {
std::string name; std::string name;
@ -17,6 +18,7 @@ struct AppSettings {
std::optional<std::string> getId(std::string_view name); std::optional<std::string> getId(std::string_view name);
std::vector<Service> services; std::vector<Service> services;
std::optional<uint16_t> httpPort;
}; };
#endif // JSON_SETTINGS_H #endif // JSON_SETTINGS_H

View File

@ -3,6 +3,7 @@
#include <sstream> #include <sstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <print>
#include <optional> #include <optional>
#include "json_settings.h" #include "json_settings.h"
#include "htmx_helper.h" #include "htmx_helper.h"
@ -68,5 +69,19 @@ int main() {
return crow::response{row.htmx()}; return crow::response{row.htmx()};
}); });
app.port(8080).multithreaded().run(); const uint16_t defaultPort = 3010;
uint16_t httpPort = defaultPort;
{
auto opt_settings = AppSettings::loadAppSettings();
if (opt_settings.has_value()){
auto& settings = opt_settings.value();
httpPort = settings.httpPort.value_or(defaultPort);
} else {
CROW_LOG_ERROR << "failed to load settings : " << opt_settings.error();
}
}
app.loglevel(crow::LogLevel::INFO);
app.port(httpPort).multithreaded().run();
} }

View File

@ -0,0 +1,11 @@
{
"httpPort" : 3010,
"services": [
["Calibre", " calibre-server.service"],
["File Server", "file-server.service"],
["Jellyfin", "jellyfin.service"],
["DuckDNS", "duckdns.service"],
["Wiki.js", "wiki.service"],
["qBitTorrent", "qbittorrent-nox@lukas.service"]
]
}

View File

@ -1,4 +1,5 @@
{ {
"httpPort" : 3010,
"services": [ "services": [
["Cups", "cups.service"], ["Cups", "cups.service"],
["Waydriod", "waydroid-container.service"] ["Waydriod", "waydroid-container.service"]