[systemd-devel] macros in systemd unit files question

lux-integ lux-integ at btconnect.com
Wed Jul 31 10:59:18 PDT 2013


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?   
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 ?

thanks in advance


More information about the systemd-devel mailing list