-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemd_manager.h
36 lines (29 loc) · 953 Bytes
/
systemd_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef SYSTEMD_MANAGER_H
#define SYSTEMD_MANAGER_H
#include <systemd/sd-daemon.h>
#include <systemd/sd-bus.h>
#include <stdbool.h>
#include <cstring>
#include <string>
#include <iostream>
#define SYSTEMD_SERVICE_NAME "org.freedesktop.systemd1"
#define SYSTEMD_OBJECT_PATH_NAME "/org/freedesktop/systemd1"
#define SYSTEMD_UNIT_INTERFACE_NAME "org.freedesktop.systemd1.Unit"
#define SYSTEMD_SERVICE_INTERFACE_NAME "org.freedesktop.systemd1.Service"
#define SYSTEMD_MANAGER_INTERFACE_NAME "org.freedesktop.systemd1.Manager"
#define SYSTEMD_START_METHOD "StartUnit"
#define SYSTEMD_STOP_METHOD "StopUnit"
#define SYSTEMD_LOAD_UNIT_METHOD "LoadUnit"
#define SYSTEMD_REBOOT_METHOD "Reboot"
class SystemdManager
{
public:
SystemdManager();
~SystemdManager();
int startService(std::string unit_name, bool stop);
bool isActive(std::string unit_name);
int reboot();
private:
sd_bus *m_bus = nullptr;
};
#endif // SYSTEMD_MANAGER_H