first release 0.1.1
This commit is contained in:
parent
3d3264d8d6
commit
71f771b428
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
cmake-build-debug
|
||||
cmake-build-release
|
||||
build
|
||||
pkg
|
||||
|
||||
# JetBrains IDEs
|
||||
.idea/
|
||||
|
||||
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -2,10 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Crow App",
|
||||
"name": "Debug Server Admin Panel",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/app",
|
||||
"program": "${workspaceFolder}/build/lf-server-admin-panel",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
||||
26
PKGBUILD
26
PKGBUILD
@ -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"
|
||||
}
|
||||
@ -13,11 +13,11 @@ run : F5 or Run → Start Debugging
|
||||
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
|
||||
|
||||
```
|
||||
makepkg -fL
|
||||
makepkg -f
|
||||
```
|
||||
@ -41,6 +41,12 @@ expected<AppSettings, string> AppSettings::loadAppSettings() {
|
||||
return unexpected("'services' array in JSON file is empty");
|
||||
}
|
||||
|
||||
if (j.contains("httpPort")) {
|
||||
settings.httpPort = j["httpPort"].get<int>();
|
||||
} else {
|
||||
settings.httpPort = {};
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <cstdint>
|
||||
|
||||
struct Service {
|
||||
std::string name;
|
||||
@ -17,6 +18,7 @@ struct AppSettings {
|
||||
std::optional<std::string> getId(std::string_view name);
|
||||
|
||||
std::vector<Service> services;
|
||||
std::optional<uint16_t> httpPort;
|
||||
};
|
||||
|
||||
#endif // JSON_SETTINGS_H
|
||||
17
src/main.cpp
17
src/main.cpp
@ -3,6 +3,7 @@
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <print>
|
||||
#include <optional>
|
||||
#include "json_settings.h"
|
||||
#include "htmx_helper.h"
|
||||
@ -68,5 +69,19 @@ int main() {
|
||||
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();
|
||||
}
|
||||
|
||||
11
static/server-settings.json
Normal file
11
static/server-settings.json
Normal 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"]
|
||||
]
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
{
|
||||
"httpPort" : 3010,
|
||||
"services": [
|
||||
["Cups", "cups.service"],
|
||||
["Waydriod", "waydroid-container.service"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user