Re: [systemd-devel] macros in systemd unit files question
On Wed, Jul 31, 2013 at 06:59:18PM +0100, lux-integ wrote: On Wednesday 31 July 2013 14:22:35 Michal Vyskocil wrote: You can split the logic into two mount units with opposite Condition #mountpoint.mount [Unit] Description=mount mountpoint ConditionPathIsMountPoint=/mountpoint [Mount] What=/dev/something Where=/mountpoint #somewherelse.mount [Unit] Description=mount somewhereelse ConditionPathIsMountPoint=!/mountpoint [Mount] What=/dev/something Where=/somewhereelse very elegant many thanks for this now suppose my original file had more than mount in it say it was #-- IF mountpoint exists /bin/mount /dev/something $mountpoint /bin/mkdir $mountpoint/somedir /bin/cp something $mountpoint/somedir ELSE /bin/mount /dev/something somewherelse /bin/mkdir somewherelse/someotherdir /bin/cp somethingelse somewherelse/someotherdir/ ENDiF #-- How would I do this ? in otherWORDS:- a) can I add other non-mount commands to mount units? No, mount units are just more flexible replacenment of /etc/fstab. Please consult the man systemd.mount. OR b) can I call mount units in other types of units in say service units (i.e. with 'ExecStart= ) and if so how so ? Systemd units are not scripts, so can't be called. You can divide your functionality into independent units, but that'd be overkill. If you need more complex functionality, then simply call your script from one .service file and let script do his work. Regards Michal Vyskocil signature.asc Description: Digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wednesday 31 July 2013 14:36:25 Colin Guthrie wrote: Mount units have to be named specially after their mount points, so be careful there e.g. if the mount point is /mnt/mymountpoint then the unit should be called mnt-mymountpoint.mount thanks for your reply Now I have an init script to translate to systemd with this:- /bin/echo Remounting root file system in read-write mode... /bin/mount -n -o remount,rw / /dev/null which I translate to systemd-speak ( mount file ) as # [Unit] Description=Remounting root file system in read-write mode... #After=dev.mount #Before= [Mount] What=/ Where=/ Options=remount,rw #- what do I call this file? rootfs.mount ? (and if so would it not contradict with the What and Where in [Mount] ? or /.mount (which I doubt would be allowed) advice will be apreciated sincerely luxInteg ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
'Twas brillig, and lux-integ at 01/08/13 11:53 did gyre and gimble: On Wednesday 31 July 2013 14:36:25 Colin Guthrie wrote: Mount units have to be named specially after their mount points, so be careful there e.g. if the mount point is /mnt/mymountpoint then the unit should be called mnt-mymountpoint.mount thanks for your reply Now I have an init script to translate to systemd with this:- /bin/echo Remounting root file system in read-write mode... /bin/mount -n -o remount,rw / /dev/null which I translate to systemd-speak ( mount file ) as # [Unit] Description=Remounting root file system in read-write mode... #After=dev.mount #Before= [Mount] What=/ Where=/ Options=remount,rw #- You generally wouldn't set the description in such a mount unit Remount root file Just use Description=Root Filesystem or similar. The mount options themselves are an implementation detail. what do I call this file? rootfs.mount ? (and if so would it not contradict with the What and Where in [Mount] ? The rootfs mount is called -.mount (i.e. a leading -) To be honest with you tho', unless you are tailoring your system for a very specific case and disabling support for /etc/fstab completely, I'd just specify your mount options in /etc/fstab as before and systemd will just interpret it and generate your mount units for you. You don't need to do anything special to get your mount options applied as systemd will do that for you. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited http://www.tribalogic.net/ Open Source: Mageia Contributor http://www.mageia.org/ PulseAudio Hacker http://www.pulseaudio.org/ Trac Hacker http://trac.edgewall.org/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Thursday 01 August 2013 12:15:21 Colin Guthrie wrote: The rootfs mount is called -.mount (i.e. a leading -) many thanks for this To be honest with you tho', unless you are tailoring your system for a very specific case yes this is so, it is remounting / (RW) earlier in the boot process ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Thu, Aug 1, 2013 at 1:45 PM, lux-integ lux-in...@btconnect.com wrote: On Thursday 01 August 2013 12:15:21 Colin Guthrie wrote: The rootfs mount is called -.mount (i.e. a leading -) many thanks for this To be honest with you tho', unless you are tailoring your system for a very specific case yes this is so, it is remounting / (RW) earlier in the boot process I'm not following. Do you mean that systemd is already doing what you need, or do you need something different from what systemd does. For the record the standard behavior is: Your / will be first mounted according to the options on the kernel commandline (ro or rw), then systemd-remount-fs.service will remount it based on the options in /etc/fstab (which could be rw). Do you need anything different than this? -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Thursday 01 August 2013 12:58:46 Tom Gundersen wrote: 'm not following. Do you mean that systemd is already doing what you need, not sure as I am just learning ...but suppose I have already mounted proc, run and sys and I want just a read only root filesystem --a) how do I get systemd to mount a nonRW root filesystemand not bother with anything in fstab.? OR --b) could I have an fstab with / -o,ro? ( and if so what would systemd-remount-fs.service do ?) thanks in advance sincerely luxInteg ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
'Twas brillig, and lux-integ at 01/08/13 15:25 did gyre and gimble: On Thursday 01 August 2013 12:58:46 Tom Gundersen wrote: 'm not following. Do you mean that systemd is already doing what you need, not sure as I am just learning ...but suppose I have already mounted proc, run and sys and I want just a read only root filesystem --a) how do I get systemd to mount a nonRW root filesystemand not bother with anything in fstab.? OR --b) could I have an fstab with / -o,ro? ( and if so what would systemd-remount-fs.service do ?) Exactly the same as with sysvinit - just set the options in fstab. Or if you don't want an fstab then set the options in the -.mount unit instead. The systemd-remount-fs.service will then basically be a no-op if the options don't change. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited http://www.tribalogic.net/ Open Source: Mageia Contributor http://www.mageia.org/ PulseAudio Hacker http://www.pulseaudio.org/ Trac Hacker http://trac.edgewall.org/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Thu, Aug 1, 2013 at 4:25 PM, lux-integ lux-in...@btconnect.com wrote: On Thursday 01 August 2013 12:58:46 Tom Gundersen wrote: 'm not following. Do you mean that systemd is already doing what you need, not sure as I am just learning ...but suppose I have already mounted proc, run and sys and I want just a read only root filesystem --a) how do I get systemd to mount a nonRW root filesystemand not bother with anything in fstab.? OR --b) could I have an fstab with / -o,ro? ( and if so what would systemd-remount-fs.service do ?) If all you want is an RO rootfs, just specify ro on the kernel commandline and drop the rootfs entry from fstab, or if you still want the rootfs entry in fstab make sure it also has ro as an option. FWIW, systemd should be mounting /proc, /run and /sys for you (don't know if that is relevant). -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Thu, Aug 1, 2013 at 9:41 AM, Colin Guthrie gm...@colin.guthr.ie wrote: 'Twas brillig, and lux-integ at 01/08/13 15:25 did gyre and gimble: On Thursday 01 August 2013 12:58:46 Tom Gundersen wrote: 'm not following. Do you mean that systemd is already doing what you need, not sure as I am just learning ...but suppose I have already mounted proc, run and sys and I want just a read only root filesystem --a) how do I get systemd to mount a nonRW root filesystemand not bother with anything in fstab.? OR --b) could I have an fstab with / -o,ro? ( and if so what would systemd-remount-fs.service do ?) Exactly the same as with sysvinit - just set the options in fstab. Or if you don't want an fstab then set the options in the -.mount unit instead. The systemd-remount-fs.service will then basically be a no-op if the options don't change. Couldn't you just systemctl mask systemd-remount-fs.service and just keep ro in the kernel line of your bootloader? Then you just wouldn't remount the filesystem as rw, which would be what is listed in your fstab. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited http://www.tribalogic.net/ Open Source: Mageia Contributor http://www.mageia.org/ PulseAudio Hacker http://www.pulseaudio.org/ Trac Hacker http://trac.edgewall.org/ ___ 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
[systemd-devel] macros in systemd unit files question
I am trying to learn systemD. I scaned through some of the man pages. I am here asking if systemD unit file synthesis can be made to support macros; for example of the following type:- #-- IF mountpoint exists /bin/mount /dev/something $mountpoint ELSE /bin/mount /dev/something somewherelse ENDiF #-- thanks in advance LuxInteg ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
Hi, On Wed, Jul 31, 2013 at 2:14 PM, lux-integ lux-in...@btconnect.com wrote: I am trying to learn systemD. I scaned through some of the man pages. I am here asking if systemD unit file synthesis can be made to support macros; for example of the following type:- #-- IF mountpoint exists /bin/mount /dev/something $mountpoint ELSE /bin/mount /dev/something somewherelse ENDiF #-- Unit files are declarative by design, so the answer to this will almost certainly be no. If you really need a proper programming language, then you'd be better off using a script and pointing ExecStart to that. -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wednesday 31 July 2013 13:26:18 Tom Gundersen wrote: If you really need a proper programming language, then you'd be better off using a script and pointing ExecStart to that. example please? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wed, Jul 31, 2013 at 3:05 PM, lux-integ lux-in...@btconnect.com wrote: On Wednesday 31 July 2013 13:26:18 Tom Gundersen wrote: If you really need a proper programming language, then you'd be better off using a script and pointing ExecStart to that. example please? Make a bash script (or whatever else) doing what you want (the pseudo-code you posted). Save it as /usr/local/bin/foo and create a unit file with ExecStart=/usr/local/bin/foo. That said, there probably is a better way to solve your problem not involving macros or scripts (at least in my experience it always is). But that would obviously depend on exactly what you are trying to do. -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wed, Jul 31, 2013 at 01:14:08PM +0100, lux-integ wrote: I am trying to learn systemD. I scaned through some of the man pages. I am here asking if systemD unit file synthesis can be made to support macros; for example of the following type:- #-- IF mountpoint exists /bin/mount /dev/something $mountpoint ELSE /bin/mount /dev/something somewherelse ENDiF #-- You can split the logic into two mount units with opposite Condition #mountpoint.mount [Unit] Description=mount mountpoint ConditionPathIsMountPoint=/mountpoint [Mount] What=/dev/something Where=/mountpoint #somewherelse.mount [Unit] Description=mount somewhereelse ConditionPathIsMountPoint=!/mountpoint [Mount] What=/dev/something Where=/somewhereelse See man systemd.mount and man systemd.exec for details. http://www.freedesktop.org/software/systemd/man/systemd.mount.html http://www.freedesktop.org/software/systemd/man/systemd.unit.html Regards Michal Vyskocil thanks in advance LuxInteg ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel signature.asc Description: Digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
'Twas brillig, and lux-integ at 31/07/13 13:14 did gyre and gimble: I am trying to learn systemD. I scaned through some of the man pages. The first thing to learn is that's it's systemd, not systemD ;) I am here asking if systemD unit file synthesis can be made to support macros; for example of the following type:- #-- IF mountpoint exists /bin/mount /dev/something $mountpoint ELSE /bin/mount /dev/something somewherelse ENDiF #-- As Tom already said, the units are declarative, so if/then/else structure is definitely not supported. You could split that particular example up into two different mount units tho' I believe. (using /bin/mount directly is not needed if you define .mount units: see man systemd.mount) You could use ConditionPathIsDirectory=/mnt/mymountpoint in one unit and ConditionPathIsDirectory=!/mnt/mymountpoint in the other. Mount units have to be named specially after their mount points, so be careful there e.g. if the mount point is /mnt/mymountpoint then the unit should be called mnt-mymountpoint.mount Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited http://www.tribalogic.net/ Open Source: Mageia Contributor http://www.mageia.org/ PulseAudio Hacker http://www.pulseaudio.org/ Trac Hacker http://trac.edgewall.org/ ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wednesday 31 July 2013 14:13:56 Tom Gundersen wrote: example please? Make a bash script (or whatever else) doing what you want (the pseudo-code you posted). Save it as /usr/local/bin/foo and create a unit file with ExecStart=/usr/local/bin/foo. thanks for your suggestion. just one last ( I hope )question suppose my pseudocode has lines with /bin/echo something to invoke console output like so:_ #-- IF mountpoint exists /bin/echo obladee /bin/mount /dev/something $mountpoint ELSE /bin/echo obladaa /bin/mount /dev/something somewherelse ENDiF #-- does this file need to be stripped of the /bin/echo lines? in otherwords will systemd print the obladee or obladaa.. lines during execution or do they need to be removed before ExecStart works? thanks in advance ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wed, Jul 31, 2013 at 4:03 PM, lux-integ lux-in...@btconnect.com wrote: #-- IF mountpoint exists /bin/echo obladee /bin/mount /dev/something $mountpoint ELSE /bin/echo obladaa /bin/mount /dev/something somewherelse ENDiF #-- does this file need to be stripped of the /bin/echo lines? in otherwords will systemd print the obladee or obladaa.. lines during execution or do they need to be removed before ExecStart works? By default, anything you print to stdout (e.g. using echo) will end up in the journal and not on the console. If you want to override that you can set StandardOutput=journal+console (see http://0pointer.de/public/systemd-man/systemd.exec.html). Though, that is typically not what you want. The suggestions from Michal and Colin seem like the best option for you (rather than a shell script). -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] macros in systemd unit files question
On Wed, Jul 31, 2013 at 2:14 PM, lux-integ lux-in...@btconnect.com wrote: I am trying to learn systemD. I scaned through some of the man pages. I am here asking if systemD unit file synthesis can be made to support macros; for example of the following type:- #-- IF mountpoint exists /bin/mount /dev/something $mountpoint ELSE /bin/mount /dev/something somewherelse ENDiF #-- We don't want to support any language-like flow control in unit files. It's actually much more of a feature than a limitation that unit files are *descriptive* and not little programs that run. Things should not be evaluated at runtime beyond the simple conditions we support. So no, we don't want anything like macros, pre-processing, or language constructs in unit files. Kay ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel