From: Ben Weinstein-Raun <root@benwr.net>
To: help-guix@gnu.org
Subject: Re: Shepherd user services that run on startup?
Date: Mon, 01 Jan 2024 22:04:35 +0000 [thread overview]
Message-ID: <dbda6cf1-55dd-42a6-b54c-b793e7bb6dd1@benwr.net> (raw)
In-Reply-To: <532f5b62-c5c3-4aa5-867e-ebe2dbecc848@benwr.net>
[-- Attachment #1: Type: text/plain, Size: 2571 bytes --]
On 12/20/23 16:42, Ben Weinstein-Raun wrote:
> My guess is that this is at least possible, by defining a system-level
> service that starts a shepherd for each user. Would that work?
After struggling with this for a week, I've managed to get a user-level
`shepherd` starting! It fails to actually run, probably due to errors in
my init.scm, but I'm happy with the progress! I still have some fairly
important-feeling questions though:
* When I tried to use `sudo` via the actual package, I get an error
about it needing to be setuid-root. My workaround is to jut directly add
/run/setuid-programs to the PATH, but this is a pretty bad-feeling hack,
as it leaves an unspecified dependency. What's the right way to depend
on sudo? Force the user to pass it in as an argument, maybe?
* I still don't know how to "properly" ensure that the XDG_RUNTIME_DIR
is set, like it should be for a "proper" login shell. Right now, the
shell script just brute-creates the directory where I expec
t it on my
system (and exports that path to the environment). So, if anybody knows:
what's the right way to do this?
* Several times throughout this process, when I had errors in the shell
script that caused it to exit early, my system shepherd became
unresponsive and I had to roll-back, and then reboot using
/proc/sysrq-trigger. This was a little terrifying, since I'm currently
traveling and won't physically see my server again until February. It
was also surprising, since the script is running inside a shepherd
fork-exec constructor, and I'd have thought that this would deal
gracefully with failed starts. Is this a bug in shepherd, or am I
misusing it?
> Anyone have tips on how to go about building this, if so? Especially:
> What's the easiest way to ensure that a guix service knows the list of
> users-with-login-shells on the system?
I sidestepped this issue by forcing the user to specify usernames when
instantiating the service. This seems nicer anyway, as m
aybe you don't
want to start a shepherd for every user.
> And, of course, is there a simpler way?
This question still stands!
My code is on github if you're curious:
* service definition is here:
https://github.com/benwr/benwr_guix/blob/main/benwr/services/userherd.scm
* package definition is here:
https://github.com/benwr/benwr_guix/blob/main/benwr/packages/userherd.scm
* shell script is here: https://github.com/benwr/userherd
(This is probably obvious, but just in case: I'd strongly caution
against directly relying on my channel, as I break it constantly)
Thanks in advance for any help!
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
prev parent reply other threads:[~2024-01-01 22:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 21:42 Shepherd user services that run on startup? Ben Weinstein-Raun
2023-12-28 23:42 ` Csepp
2023-12-29 2:56 ` Hipólita Yarona
2024-01-01 22:04 ` Ben Weinstein-Raun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dbda6cf1-55dd-42a6-b54c-b793e7bb6dd1@benwr.net \
--to=root@benwr.net \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.