added pkg build for project
This commit is contained in:
parent
1e9a377c2a
commit
3d3264d8d6
@ -32,7 +32,7 @@ endforeach()
|
|||||||
# Use Crow from system include (installed via yay -S crow + asio)
|
# Use Crow from system include (installed via yay -S crow + asio)
|
||||||
include_directories(/usr/include)
|
include_directories(/usr/include)
|
||||||
|
|
||||||
add_executable(app src/main.cpp
|
add_executable(lf-server-admin-panel src/main.cpp
|
||||||
src/htmx/HtmxTable.cpp
|
src/htmx/HtmxTable.cpp
|
||||||
src/htmx/HtmxTable.h
|
src/htmx/HtmxTable.h
|
||||||
src/systemd.cpp
|
src/systemd.cpp
|
||||||
@ -48,7 +48,7 @@ add_executable(app src/main.cpp
|
|||||||
src/json_settings.h
|
src/json_settings.h
|
||||||
src/json.hpp)
|
src/json.hpp)
|
||||||
|
|
||||||
target_link_libraries(app pthread)
|
target_link_libraries(lf-server-admin-panel pthread)
|
||||||
|
|
||||||
# Optional: Print build type at configuration time
|
# Optional: Print build type at configuration time
|
||||||
message(STATUS "Configuring build type: ${CMAKE_BUILD_TYPE}")
|
message(STATUS "Configuring build type: ${CMAKE_BUILD_TYPE}")
|
||||||
26
PKGBUILD
Normal file
26
PKGBUILD
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 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"
|
||||||
|
}
|
||||||
15
README.md
15
README.md
@ -7,4 +7,17 @@ pacman -S crow asio gdb gcc cmake make
|
|||||||
### vscode
|
### vscode
|
||||||
|
|
||||||
build : Ctrl+Shift+P → "CMake: Configure"
|
build : Ctrl+Shift+P → "CMake: Configure"
|
||||||
run : F5 or Run → Start Debugging
|
run : F5 or Run → Start Debugging
|
||||||
|
|
||||||
|
## Make Package
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
2. create the package
|
||||||
|
|
||||||
|
```
|
||||||
|
makepkg -fL
|
||||||
|
```
|
||||||
13
lf-server-admin-panel.service
Normal file
13
lf-server-admin-panel.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=lf-server-admin-panel Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/usr/share/lf-server-admin-panel
|
||||||
|
ExecStart=/usr/bin/lf-server-admin-panel
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@ -1,18 +0,0 @@
|
|||||||
pkgname=service-viewer
|
|
||||||
pkgver=1.0.0
|
|
||||||
pkgrel=1
|
|
||||||
arch=('x86_64')
|
|
||||||
depends=('crow') # add any libraries you need
|
|
||||||
pkgdesc="A C++ Crow/HTMX web service"
|
|
||||||
license=('MIT')
|
|
||||||
source=('src/')
|
|
||||||
md5sums=('SKIP') # SKIP if local files
|
|
||||||
build() {
|
|
||||||
# No build needed if already compiled
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
package() {
|
|
||||||
install -Dm755 "$srcdir/src/yourapp" "$pkgdir/usr/bin/yourapp"
|
|
||||||
install -Dm644 "$srcdir/src/assets/index.html" "$pkgdir/usr/share/yourapp/index.html"
|
|
||||||
install -Dm644 "$srcdir/src/assets/style.css" "$pkgdir/usr/share/yourapp/style.css"
|
|
||||||
}
|
|
||||||
@ -44,7 +44,7 @@ expected<AppSettings, string> AppSettings::loadAppSettings() {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<const std::string&> AppSettings::getId(string_view name){
|
optional<std::string> AppSettings::getId(string_view name){
|
||||||
for (auto& service : services) {
|
for (auto& service : services) {
|
||||||
if(service.name == name) {
|
if(service.name == name) {
|
||||||
return service.service;
|
return service.service;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ struct Service {
|
|||||||
struct AppSettings {
|
struct AppSettings {
|
||||||
static std::expected<AppSettings, std::string> loadAppSettings();
|
static std::expected<AppSettings, std::string> loadAppSettings();
|
||||||
|
|
||||||
std::optional<const std::string&> getId(std::string_view name);
|
std::optional<std::string> getId(std::string_view name);
|
||||||
|
|
||||||
std::vector<Service> services;
|
std::vector<Service> services;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -21,6 +21,7 @@ namespace systemd {
|
|||||||
void toggle_service(string_view serviceName){
|
void toggle_service(string_view serviceName){
|
||||||
string_view toggle = is_service_active(serviceName) ? "stop" : "start";
|
string_view toggle = is_service_active(serviceName) ? "stop" : "start";
|
||||||
const string cmd = format("systemctl {} {}", toggle, serviceName);
|
const string cmd = format("systemctl {} {}", toggle, serviceName);
|
||||||
system(cmd.c_str());
|
// TODO: add error handling
|
||||||
|
(void)system(cmd.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user