Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I find systemd very exciting, but how would I use it to write a script to mount an s3ql filesystem? For example, the s3ql developer provides an upstart config that does the job.

Specifically, on startup mount.s3ql must be run (as the desired user as this is a FUSE filesystem), and on shutdown umount.s3ql must be run. In addition, what if we want to fsck.s3ql the filesystem before mounting, or run a Unison synchronization step after startup and before shutdown (all modifications I have made on my own personal upstart).

At first glance I would think I would want to setup a mount unit on systemd, but it appears that the service unit actually fits better with pre and post exec startup commands. (All the man pages are available here.)

And what .target do I depend on to encode the dependency on a network connection?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

At first, it seems that for mount.s3ql and umount.s3ql, a generic .mount unit might be appropriate. Both the mount command and systemd support mount.fstype helpers when mounting. However, the helper must support the standard -o options method of passing options, which s3ql does not. Also, the same limitations apply as with /etc/fstab.

So you might actually be better with a .service unit that calls the desired commands:

[Unit]
Wants=unison@s3ql.service
After=unison@s3ql.service

[Service]
Type=forking
Environment=AUTHFILE=/path/to/authinfo2
ExecStart=/usr/sbin/mount.s3ql --authfile ${AUTHFILE} ${BUCKET} ${MOUNTPOINT}
ExecStop=/usr/sbin/umount.s3ql ${MOUNTPOINT}
TimeoutSec=5min

Since there is no standard way of configuring networks, much less one that actually checks whether the connection is actually working, there is no standard systemd target for what you want. There is network.target, though, but it might consider itself started when the connection is not available yet.

If you are using NetworkManager, your distribution might have included a unit that runs nm-online – for example, Arch calls it NetworkManager-wait-online.service.

[Unit]
Require=NetworkManager-wait-online.service
After=NetworkManager-wait-online.service
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.