According to https://en.opensuse.org/openSUSE:Systemd_packaging_guidelines one is supposed to use the service_add_pre/service_add_post/service_del_preun/service_del_postun scripts in the spec file for rpmbuild. Well, this explains how to handle system service files. How do I do it for user service files? On a distro like Fedora or CentOS, one sees scripts for both system and user service file packaging (e.g. systemd_post vs systemd_user_post, etc.). So, ??
Hi
Interpretation springs to mind, if I (as a user 'root) manually add a systemd service I manually put it into /etc/systemd/ and normally system. If packaging in an rpm then they go into %{_unitdir} (/usr/lib/systemd/system).
The ‘user’ directory are in most cases softlinks target files back to the system directory, I consider anything installed by the package management a ‘system’ file and not ‘user’ related.
I have a kiosk-type use case, where I need the user’s systemd to run a graphical application after graphical login happens for a given user (there is a separate system-level service that handles updates and restarts that service using systemctl --user commands).
While I could use systemctl manually, instead of through wrapper scripts, I still don’t know where to put the files. The system service files go in %{_unitdir}. I see some distros have %{_userunitdir}, so I’m assuming that works on OpenSUSE. But I’m not finding any usage examples.
Hi
Yes, but they are softlinks back to %{_unitdir} and are targets rather than service files.
So you would install into %{_unitdir} and create softlinks back;
pushd %{buildroot}%{_unitdir}/user
ln -s ../system/your file .
popd
Then the macros should be happy since they exist in %{_unitdir}.
I’m running 12.3, and _unitdir is /usr/lib/systemd/system and there’s no user directory in there. There is, however, /usr/lib/systemd/user, which is what I’d guess _userunitdir would point to.
So I’m guessing the right way is not to use the predefined systemd scripts, but use systemctl directly, for a user service.
Since the installer is running as root, is there a recommended way to enable a service for another user, or should I just sudo -u theuser systemctl --user enable theservice ?
Before I changed anything, I did a quick check of systemctl --user status
I get this if running from a remote SSH session: Failed to get D-Bus connection: No such file or directory
After I went to the actual machine and init 5 to get a graphical session, then logged in: Failed to list units: Process org.freedesktop.systemd1 exited with status 1
systemd user doesn’t seem to be working. This looks like a bug with 12.3. I have a standard install. How do I get it running?
Hi
Ahh 12.3 is unsupported and was in the transition period for systemd. Why not 13.1 since it’s meant to go evergreen (longer community support).
It was a typo. It’s 13.2.
I just installed all updates and rebooted, but I’m still getting these errors.
On Fri 24 Apr 2015 10:56:01 PM CDT, Prune wrote:
I’m running 12.3, and _unitdir is /usr/lib/systemd/system and there’s no
user directory in there. There is, however, /usr/lib/systemd/user, which
is what I’d guess _userunitdir would point to.
So I’m guessing the right way is not to use the predefined systemd
scripts, but use systemctl directly, for a user service.
Since the installer is running as root, is there a recommended way to
enable a service for another user, or should I just sudo -u theuser
systemctl --user enable theservice ?
Hi
Yes, sorry for the confusion /usr/lib/systemd/user.
Did you enable the user with loginctl?
loginctl enable-linger username
I’m assuming your wrapper scripts are installed in /usr/bin and called
from the service file?
The other way is to install a desktop (shortcut) file to auto start on
login.
–
Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.39-47-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!
“Assuming”?
bor@opensuse:~/src/systemd> rpm --eval %_userunitdir
%_userunitdir
bor@opensuse:~/src/systemd> grep -w VERSION /etc/os-release
VERSION="13.2 (Harlequin)"
User systemd support is still pretty much non existent so I guess nobody bothered with it so far. If you want to install user unit, it should go into /usr/lib/systemd/user, but that’s it.
is there a recommended way to enable a service for another user
systemctl enable --global. But note that it probably does not reloads all running user services.