我创建了一个新的 systemd 服务,我希望能够通过 dbus 调用来激活它。该服务只是执行一个 shell 脚本。
我在这里定义了服务:
/lib/systemd/system/testamundo.service
[Unit]
Description=Testamundo
[Service]
Type=dbus
BusName=org.freedesktop.testamundo
ExecStart=/home/test/systemd/testamundo.sh
我还在这里为它定义了一个 D-Bus 服务:
/usr/share/dbus-1/system-services
[D-BUS Service]
Name=org.freedesktop.testamundo
Exec=/usr/sbin/console-kit-daemon --no-daemon
User=root
SystemdService=testamundo.service
我正在尝试使用 gdbus 启动它,这是我尝试使用的命令:
sudo gdbus call --system --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 --method org.freedesktop.systemd1.StartUnit "org.freedesktop.testamundo"
如果我像上面那样使用 --system 命令返回一个未知方法错误,如果我使用 --session 它从子进程返回一个退出代码 1。当我用 --session 和 --system 查看 journalctl 时,我可以看到该命令,但除此之外没有其他信息。
感谢任何想法或建议,谢谢!