You are not logged in.

#1 2013-07-22 01:24:31

EvanPurkhiser
Member
From: Akron, Ohio
Registered: 2010-08-17
Posts: 225
Website

[Solved] Starting systemd --user as a systemd --system process?

Hey guys,

I would like to run systemd --user as a system service using this .service file I wrote:

$ cat systemd--user@.service
[Unit]
Description=Systemd --user instance for %I
Documentation=man:systemd

[Service]
User=%I
ExecStart=/usr/lib/systemd/systemd --user --log-level=debug

[Install]
WantedBy=multi-user.target

I enabled it for my user using `systemctl enable systemd-user@evan`, however, when starting it it fails with the following errors:

Jul 21 21:14:42 desktop systemd[12920]: systemd 204 running in user mode. (+PAM -LIBWRAP -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ)
Jul 21 21:14:42 desktop systemd[12920]: Using cgroup controller name=systemd. File system hierarchy is at /sys/fs/cgroup/systemd/system/systemd-user@.service/systemd-user@evan.service/systemd-12920.
Jul 21 21:14:42 desktop systemd[12920]: Failed to create root cgroup hierarchy: Permission denied
Jul 21 21:14:42 desktop systemd[12920]: Failed to allocate manager object: Permission denied

Is it possible to run systemd --user like this? Do I need to add something to my systemd-user@.service?

Last edited by EvanPurkhiser (2013-07-22 02:10:10)

Offline

#2 2013-07-22 02:09:57

EvanPurkhiser
Member
From: Akron, Ohio
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] Starting systemd --user as a systemd --system process?

I was able to fix this by adding the following line

ControlGroup=%R/user/%u/shared cpu:/ memory:/

Or more generally just copying this service file

Offline

#3 2013-07-22 02:17:17

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [Solved] Starting systemd --user as a systemd --system process?

Is there any reason why you don't just use the systemd-user-session-units package?

Offline

#4 2013-07-22 02:30:59

EvanPurkhiser
Member
From: Akron, Ohio
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] Starting systemd --user as a systemd --system process?

EDIT: I just realized that the systemd-user-session-units package will only include specific units at build-time weather I have have the programs or not. You're right, I should just use this package!

Well, to be honest, maybe I'm trying to hack around a problem that doesn't even really exist, but I don't think the systemd-user-sessions-units package meets my needs.

The way I would like to have my user sessions setup is something like this:

I would like to have an instance of systemd --user always running under my user so I can keep things like transmission-daemon always running, even when I don't have a user session open. When I do start my user session (via logging into getty) I want to bring my systemd instance up to a certain target. For example, logging in via tty1 should bring up graphical.target, which will start X11 and all that, while logging into any other tty will start console.target (for stuff like ssh-agent etc).

Thinking more about this I suppose there's really no reason I couldn't use the user-session@.service from systemd-user-session-units, but since I won't use most of the other user units included, I would rather just not use it.

Here's what my .profile looks like:

if systemctl -q is-active systemd-user@evan
then
	# Default systemd to the console target
	target="console"

	# If we're logging in from VT1 start the graphical target
	if [[ $XDG_VTNR == 1 ]] && ! systemctl --user -q is-active graphical.target &> /dev/null
	then
		export DISPLAY=:0
		target="graphical"
	fi
	
	# Set all environment variables in the systemd --user instance (still working on this)
	env | systemctl --user set-environment -

	# Bring up systemd --user to the specified target
	systemctl --user start ${target}.target
fi

source "$HOME/.bashrc"

Last edited by EvanPurkhiser (2013-07-22 03:56:13)

Offline

Board footer

Powered by FluxBB