Always use username of UID 100000

This commit is contained in:
Matti Viljanen 2020-12-27 00:45:40 +02:00
parent 2be3247a5a
commit 4d58c55041

View file

@ -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