[systemd-devel] macros in systemd unit files question

Michal Vyskocil mvyskocil at suse.cz
Wed Jul 31 06:22:35 PDT 2013


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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130731/86ff1deb/attachment.pgp>


More information about the systemd-devel mailing list