Re: [systemd-devel] Multiple template parameters for one service
On Sat, 28.06.14 18:15, Moviuro (movi...@gmail.com) wrote: Hi all, I am at the moment trying to clean up my units to write some simple ones that I just have to link without hardcoding anything in them but am stuck at this issue: what to do if my unit requires multiple parameters? E.g. Using unison to sync files, the different variables I have to use are: local user and profile file (an optional variable would be the server). It is at the moment not possible to write a unit file that would understand so many things with just a simple '@'. I could use an extra configuration file in /etc/systemd/system every time I want to use unison, but it's not really nice and clean (one file per unison profile...). Some people would object that I can have a bash script do the job of translating what is behind the '@' into my many arguments: not really nice either. An idea would be to use units with many '@' or have systemd interpret the string between '@' and '.service' as '@'-separated values (e.g. unison@local_user@profile.service). The feature could also help by including some optional arguments (e.g. the server information in unison is not necessary for it to work but could help if I use a service to check if the server is online beforehand: unison@local_user@profile@server.service). Hummm... So far the instancing was strictly one-dimensional from systemd's PoV. And I think I would prefer it like that, since it makes so many things easier. I mean, as you notice, one can always parse this from shell or so, if you want, so we can actually get away with not supporting anything more complex with systemd. (Note that specifically using this for running things as unpriviliged normal users: I'd encourage you not to do this with system-level services, but instead run this as user services, from the systemd user instance. Of course, the work on thta isn't complete yet, but it definitely sounds like the more correct option for the long run). Sorry, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
On Mon, Jun 30, 2014 at 1:38 PM, Lennart Poettering lenn...@poettering.net wrote: On Sat, 28.06.14 18:15, Moviuro (movi...@gmail.com) wrote: Hi all, I am at the moment trying to clean up my units to write some simple ones that I just have to link without hardcoding anything in them but am stuck at this issue: what to do if my unit requires multiple parameters? E.g. Using unison to sync files, the different variables I have to use are: local user and profile file (an optional variable would be the server). It is at the moment not possible to write a unit file that would understand so many things with just a simple '@'. I could use an extra configuration file in /etc/systemd/system every time I want to use unison, but it's not really nice and clean (one file per unison profile...). Some people would object that I can have a bash script do the job of translating what is behind the '@' into my many arguments: not really nice either. An idea would be to use units with many '@' or have systemd interpret the string between '@' and '.service' as '@'-separated values (e.g. unison@local_user@profile.service). The feature could also help by including some optional arguments (e.g. the server information in unison is not necessary for it to work but could help if I use a service to check if the server is online beforehand: unison@local_user@profile@server.service). Hummm... So far the instancing was strictly one-dimensional from systemd's PoV. And I think I would prefer it like that, since it makes so many things easier. I mean, as you notice, one can always parse this from shell or so, if you want, so we can actually get away with not supporting anything more complex with systemd. (Note that specifically using this for running things as unpriviliged normal users: I'd encourage you not to do this with system-level services, but instead run this as user services, from the systemd user instance. Of course, the work on thta isn't complete yet, but it definitely sounds like the more correct option for the long run). User services work quite well for such things already, only the X11 and DBus session-bus access is still problematic. Should be fine for Unison. -- Mantas Mikulėnas graw...@gmail.com ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
On Mon, 2014-06-30 at 12:38 +0200, Lennart Poettering wrote: On Sat, 28.06.14 18:15, Moviuro (movi...@gmail.com) wrote: An idea would be to use units with many '@' or have systemd interpret the string between '@' and '.service' as '@'-separated values (e.g. unison@local_user@profile.service). Hummm... So far the instancing was strictly one-dimensional from systemd's PoV. And I think I would prefer it like that, since it makes so many things easier. I mean, as you notice, one can always parse this from shell or so, if you want, so we can actually get away with not supporting anything more complex with systemd. Shouldn't just another '%x' format specifier or two for unit files be enough to get most of the benefit, without changing any of the underlying architecture? As in something like %?5? meaning interpret the instance name as a whatever-delimited list, and place the 5th element of the list here. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
On Mon, 30.06.14 19:52, Uoti Urpala (uoti.urp...@pp1.inet.fi) wrote: On Mon, 2014-06-30 at 12:38 +0200, Lennart Poettering wrote: On Sat, 28.06.14 18:15, Moviuro (movi...@gmail.com) wrote: An idea would be to use units with many '@' or have systemd interpret the string between '@' and '.service' as '@'-separated values (e.g. unison@local_user@profile.service). Hummm... So far the instancing was strictly one-dimensional from systemd's PoV. And I think I would prefer it like that, since it makes so many things easier. I mean, as you notice, one can always parse this from shell or so, if you want, so we can actually get away with not supporting anything more complex with systemd. Shouldn't just another '%x' format specifier or two for unit files be enough to get most of the benefit, without changing any of the underlying architecture? As in something like %?5? meaning interpret the instance name as a whatever-delimited list, and place the 5th element of the list here. Well, I am not thrilled by that idea, but I'd probably accept a patch that does this if it uses a very convincing syntax and doesn't try to be too generic. For example, it should enforce one clear separator syntax, and clearly map to %i and %I. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
You could just use /etc/systemd/system/unison@instance.service.d/ directory to provide service environment variables, this seems to be much more convenient way to configure service. Best regards, Alexander 2014-06-29 0:15 GMT+08:00 Moviuro movi...@gmail.com: Hi all, I am at the moment trying to clean up my units to write some simple ones that I just have to link without hardcoding anything in them but am stuck at this issue: what to do if my unit requires multiple parameters? E.g. Using unison to sync files, the different variables I have to use are: local user and profile file (an optional variable would be the server). It is at the moment not possible to write a unit file that would understand so many things with just a simple '@'. I could use an extra configuration file in /etc/systemd/system every time I want to use unison, but it's not really nice and clean (one file per unison profile...). Some people would object that I can have a bash script do the job of translating what is behind the '@' into my many arguments: not really nice either. An idea would be to use units with many '@' or have systemd interpret the string between '@' and '.service' as '@'-separated values (e.g. unison@local_user@profile.service). The feature could also help by including some optional arguments (e.g. the server information in unison is not necessary for it to work but could help if I use a service to check if the server is online beforehand: unison@local_user@profile@server.service). Cheers, -- Moviuro ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
On Sunday 29 June 2014 00:21:33 you wrote: You could just use /etc/systemd/system/unison@instance.service.d/ directory to provide service environment variables, this seems to be much more convenient way to configure service. I can't do that because different users may have the same profile name (and thus the same configuration folder). (I wanted to avoid it but, here is the unit) [Unit] Description=Unison sync for profile PROFILE Requires=reachable-retry@SERVER.service After=reachable-retry@SERVER.service [Service] User=LOCAL_USER ExecStart=/usr/bin/unison -auto -silent PROFILE I can't put the full path to the PROFILE as unison@/path/to/profile.service because I can't put '/' in a file name. Cheers, -- Moviuro signature.asc Description: This is a digitally signed message part. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
On Sat, Jun 28, 2014 at 06:15:58PM +0200, Moviuro wrote: Hi all, I am at the moment trying to clean up my units to write some simple ones that I just have to link without hardcoding anything in them but am stuck at this issue: what to do if my unit requires multiple parameters? Hi, systemd is kind of built around the idea of a single instance parameter... Allowing multiple would be convenient, but would require much more complexity, and a rewriting of a lot of internals. I don't think this is going to happen. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Multiple template parameters for one service
%I specifier unescapes instance name, so unison@path-to-profile.service instance becomes path/to/profile Best regards, Alexander 2014-06-29 0:31 GMT+08:00 Moviuro movi...@gmail.com: On Sunday 29 June 2014 00:21:33 you wrote: You could just use /etc/systemd/system/unison@instance.service.d/ directory to provide service environment variables, this seems to be much more convenient way to configure service. I can't do that because different users may have the same profile name (and thus the same configuration folder). (I wanted to avoid it but, here is the unit) [Unit] Description=Unison sync for profile PROFILE Requires=reachable-retry@SERVER.service After=reachable-retry@SERVER.service [Service] User=LOCAL_USER ExecStart=/usr/bin/unison -auto -silent PROFILE I can't put the full path to the PROFILE as unison@/path/to/profile.service because I can't put '/' in a file name. Cheers, -- Moviuro ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel