[systemd-devel] macros in systemd unit files question
Michal Vyskocil
mvyskocil at suse.cz
Thu Aug 1 00:51:32 PDT 2013
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
-------------- 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/20130801/70fb0e34/attachment.pgp>
More information about the systemd-devel
mailing list