diff --git a/rpm/harbour-batterybuddy.spec b/rpm/harbour-batterybuddy.spec index 6f96513..585a1c6 100644 --- a/rpm/harbour-batterybuddy.spec +++ b/rpm/harbour-batterybuddy.spec @@ -72,14 +72,16 @@ desktop-file-install --delete-original \ # << files %posttrans +export SFOSUSER=$(id -un 100000) + # Remove all service (new and old) systemctl stop %{name}-oneshot.service || true systemctl stop %{name}.service || true -su nemo -c "systemctl --user stop %{name}.service" || true +su $SFOSUSER -c "systemctl --user stop %{name}.service" || true systemctl disable %{name}-oneshot.service || true systemctl disable %{name}.service || true -su nemo -c "systemctl --user disable %{name}.service" || true +su $SFOSUSER -c "systemctl --user disable %{name}.service" || true rm %{_unitdir}/%{name}-oneshot.service || true rm %{_unitdir}/%{name}.service || true @@ -92,10 +94,10 @@ cp %{_datadir}/%{name}/service/%{name}-oneshot.service %{_unitdir}/%{name}-onesh systemctl start %{name}-oneshot.service systemctl enable %{name}-oneshot.service -# Install/update background daemon (nemo) +# Install/update background daemon (default user) cp %{_datadir}/%{name}/service/%{name}.service %{_userunitdir}/%{name}.service -su nemo -c "systemctl --user start %{name}.service" -su nemo -c "systemctl --user enable %{name}.service" +su $SFOSUSER -c "systemctl --user start %{name}.service" +su $SFOSUSER -c "systemctl --user enable %{name}.service" # Cleanup systemctl daemon-reload @@ -103,7 +105,10 @@ systemctl reset-failed %postun -su nemo -c "systemctl --user disable --now %{name}.service" || true +# Figure out the default user name +export SFOSUSER=$(id -un 100000) + +su $SFOSUSER -c "systemctl --user disable --now %{name}.service" || true systemctl disable --now %{name}-oneshot.service || true rm %{_unitdir}/%{name}-oneshot.service rm %{_userunitdir}/%{name}.service