Skip to content

Commit

Permalink
Update systemd release units to be d-bus activable (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0d authored Dec 26, 2024
1 parent daf3eae commit 6370e0b
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
5 changes: 2 additions & 3 deletions data/development/systemd/clad-devel.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ After=network.service
PrivateTmp=yes
RemainAfterExit=no
ExecStart={{ EXEC_START }}
# The environment variables here are just workarounds for local development.
Environment="XDG_CONFIG_DIRS={{ CONFIG_FILE_PATH }}"
# This is a workaround for intended only for local development.
Environment="DBUS_SYSTEM_BUS_ADDRESS={{ DBUS_SESSION_ADDRESS }}"

[Install]
WantedBy=multi-user.target
Alias=clad.service
WantedBy=default.target
File renamed without changes.
5 changes: 5 additions & 0 deletions data/release/dbus/com.redhat.lightspeed.history.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[D-BUS Service]
Name=com.redhat.lightspeed.history
Exec=/bin/false
User=root
SystemdService=clad.service
5 changes: 5 additions & 0 deletions data/release/dbus/com.redhat.lightspeed.query.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[D-BUS Service]
Name=com.redhat.lightspeed.query
Exec=/bin/false
User=root
SystemdService=clad.service
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[Unit]
Description=Command Line Assistant Daemon Service
Documentation=https://github.com/rhel-lightspeed/command-line-assistant
After=network.service
After=network-online.service dbus.service
Requires=network-online.target

[Service]
Type=dbus
BusName=com.redhat.lightspeed
PrivateTmp=yes
RemainAfterExit=no
ExecStart=/usr/sbin/clad

[Install]
WantedBy=default.target
Alias=clad.service
File renamed without changes.
File renamed without changes.
33 changes: 22 additions & 11 deletions packaging/command-line-assistant.spec
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,30 @@ A simple wrapper to interact with RAG
%{__rm} %{buildroot}/%{_bindir}/%{daemon_binary_name}

# System units
%{__install} -D -m 0644 data/release/%{daemon_binary_name}.service %{buildroot}/%{_unitdir}/%{daemon_binary_name}.service
%{__install} -D -m 0644 data/release/com.redhat.lightspeed.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf
%{__install} -D -m 0644 data/release/systemd/%{daemon_binary_name}.service %{buildroot}/%{_unitdir}/%{daemon_binary_name}.service

# d-bus policy config
%{__install} -D -m 0644 data/release/dbus/com.redhat.lightspeed.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf
%{__install} -D -m 0644 data/release/dbus/com.redhat.lightspeed.query.service %{buildroot}/%{_datadir}/dbus-1/system-services/com.redhat.lightspeed.query.service
%{__install} -D -m 0644 data/release/dbus/com.redhat.lightspeed.history.service %{buildroot}/%{_datadir}/dbus-1/system-services/com.redhat.lightspeed.history.service

# Config file
%{__install} -D -m 0644 data/release/config.toml %{buildroot}/%{_sysconfdir}/xdg/%{python_package_src}/config.toml
%{__install} -D -m 0644 data/release/xdg/config.toml %{buildroot}/%{_sysconfdir}/xdg/%{python_package_src}/config.toml

# History file
## Create the folder under /var/lib/command-line-assistatnt
%{__install} -d %{buildroot}/%{_sharedstatedir}/%{name}
## Place the history file there
%{__install} -D -m 0644 data/release/history.json %{buildroot}/%{_sharedstatedir}/%{name}/history.json
%{__install} -D -m 0644 data/release/xdg/history.json %{buildroot}/%{_sharedstatedir}/%{name}/history.json

%post
%systemd_post %{daemon_binary_name}.service

%preun
%systemd_preun %{daemon_binary_name}.service

%postun
%systemd_postun_with_restart %{daemon_binary_name}.service

%files
%doc README.md
Expand All @@ -76,17 +89,15 @@ A simple wrapper to interact with RAG
# System units
%{_unitdir}/%{daemon_binary_name}.service

# d-bus policy config
%config %{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf
%{_datadir}/dbus-1/system-services/com.redhat.lightspeed.query.service
%{_datadir}/dbus-1/system-services/com.redhat.lightspeed.history.service

# Config file
%config %{_sysconfdir}/xdg/%{python_package_src}/config.toml
%config %{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf

# History file
%{_sharedstatedir}/%{name}/history.json

%preun
if [ "$1" -eq 0 ]; then
systemctl stop %{daemon_binary_name}.service || :
systemctl disable %{daemon_binary_name}.service || :
fi

%changelog

0 comments on commit 6370e0b

Please sign in to comment.