diff --git a/data/development/systemd/clad-devel.service b/data/development/systemd/clad-devel.service index dae358b..097b4ef 100644 --- a/data/development/systemd/clad-devel.service +++ b/data/development/systemd/clad-devel.service @@ -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 diff --git a/data/release/com.redhat.lightspeed.conf b/data/release/dbus/com.redhat.lightspeed.conf similarity index 100% rename from data/release/com.redhat.lightspeed.conf rename to data/release/dbus/com.redhat.lightspeed.conf diff --git a/data/release/dbus/com.redhat.lightspeed.history.service b/data/release/dbus/com.redhat.lightspeed.history.service new file mode 100644 index 0000000..e39641a --- /dev/null +++ b/data/release/dbus/com.redhat.lightspeed.history.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=com.redhat.lightspeed.history +Exec=/bin/false +User=root +SystemdService=clad.service diff --git a/data/release/dbus/com.redhat.lightspeed.query.service b/data/release/dbus/com.redhat.lightspeed.query.service new file mode 100644 index 0000000..5295776 --- /dev/null +++ b/data/release/dbus/com.redhat.lightspeed.query.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=com.redhat.lightspeed.query +Exec=/bin/false +User=root +SystemdService=clad.service diff --git a/data/release/clad.service b/data/release/systemd/clad.service similarity index 63% rename from data/release/clad.service rename to data/release/systemd/clad.service index 2ddce8c..bb6014c 100644 --- a/data/release/clad.service +++ b/data/release/systemd/clad.service @@ -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 diff --git a/data/release/config.toml b/data/release/xdg/config.toml similarity index 100% rename from data/release/config.toml rename to data/release/xdg/config.toml diff --git a/data/release/history.json b/data/release/xdg/history.json similarity index 100% rename from data/release/history.json rename to data/release/xdg/history.json diff --git a/packaging/command-line-assistant.spec b/packaging/command-line-assistant.spec index e431634..9a8e00c 100644 --- a/packaging/command-line-assistant.spec +++ b/packaging/command-line-assistant.spec @@ -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 @@ -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