Is there a good solution to start, stop, enable or disable a systemd service directly from within my c++ application?
For example: I want to start the /etc/systemd/system/ntp.service if a specific event occurs that is registered by my c++ application.
A solution for this would be to use a bash/shell script that runs systemctl start ntp.service
. This script is called from my c++ application via syscall. But I think there should be a better solution for this.
I've searched the web for other questions like this but I only found hints to the sdbus libraries. But I haven't found any tutorial on how to start a .service via sdbus. Is it possible to start a service with sdbus? If yes, is there a good tutorial or manual for it?