You are not logged in.

#1 2012-12-17 22:08:36

keatts
Member
Registered: 2012-10-07
Posts: 11

[SOLVED] Systemd screen service

There's a systemd screen service file on Arch wiki.  I've saved it to /etc/systemd/system/screen@.service, and I can run systemctl start screen@keatts.service without error, but screen doesn't actually successfully start.

Here's the output of systemctl status screen@keatts.service:

screen@keatts.service - screen
          Loaded: loaded (/etc/systemd/system/screen@.service; enabled)
          Active: failed (Result: exit-code) since Mon, 2012-12-17 01:05:46 EST; 12h ago
         Process: 1237 ExecStop=/usr/bin/screen -S autoscreen -X quit (code=exited, status=1/FAILURE)
         Process: 1233 ExecStart=/usr/bin/screen -dmS autoscreen (code=exited, status=0/SUCCESS)
        Main PID: 1234 (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/screen@.service/keatts

Dec 17 01:05:46 Colossus systemd[1]: Starting screen...
Dec 17 01:05:46 Colossus systemd[1]: Started screen.
Dec 17 01:05:46 Colossus screen[1237]: No screen session found.
Dec 17 01:05:46 Colossus systemd[1]: Unit screen@keatts.service entered failed state

Can anyone help me determine why it's not working?

Last edited by keatts (2012-12-19 02:55:45)

Offline

#2 2012-12-18 18:25:57

keatts
Member
Registered: 2012-10-07
Posts: 11

Re: [SOLVED] Systemd screen service

Bump.  I've asked #archlinux three separate times throughout the day and I've received no responses yet.

Offline

#3 2012-12-19 02:55:18

keatts
Member
Registered: 2012-10-07
Posts: 11

Re: [SOLVED] Systemd screen service

I finally figured it out, mostly on my own, but I'll post my results here for others.  The correct solution is to use systemd user session management.  This is a relatively new feature, and not much organized information is written on it yet.  I mostly used the the Arch wiki page Systemd/User, and the user-session-units README on github as references.

First, add the following to /etc/pam.d/login or /etc/pam.d/systemd-auth:

session    required     pam_systemd.so

Next, add the following to ~/.config/systemd/screen.target (or /etc/systemd/user/screen.target, or /usr/lib/systemd/user/screen.target)::

[Unit]
Description=Screen
Requires=dbus.socket
AllowIsolate=true

[Install]
Alias=default.target

Then, link default.target to screen.target.  If you put screen.target in your home directory, you can do this by running 'ln -s ~/.config/systemd/screen.target ~/.config/systemd/default.target'.  If not, I'm sure you can figure it out.

Now make the actual screen.service file in one of the three directories.

[Unit]
Description=screen

[Service]
RemainAfterExit=yes
ExecStart=/usr/bin/screen -dmS autoscreen
ExecStop=/usr/bin/screen -S autoscreen -X quit

[Install]
WantedBy=screen.target

Finally, enable the user-service thing by typing 'ln -s /usr/lib/systemd/system/user-session@.service /etc/systemd/system/multi-user.target.wants/user-session@1000.service'.  Replace 1000 with your user id.

Offline

#4 2012-12-19 03:19:50

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

Re: [SOLVED] Systemd screen service

Awesome work keatts, maybe yuo should add to that wiki page you referenced.  You seemed to have discovered some information not included there.


Edit: BTW, I was looking into this a little.  You know that there is the user@.service, which appears to provide the same functionality as the user-session@.service file you mentioned/linked to.

Last edited by WonderWoofy (2012-12-19 05:21:12)

Offline

Board footer

Powered by FluxBB