diff options
author | Tom Willemse | 2013-11-24 23:04:18 +0100 |
---|---|---|
committer | Tom Willemse | 2013-11-24 23:04:18 +0100 |
commit | 38adb8d0ac6eebbeb5e26d2095526c3ba9459d7a (patch) | |
tree | bc00d817278d80b0d7610b7ef361aae23cebc8e1 /articles/mounting_music_dir_before_mpd.org | |
parent | 6cbdc4209febfa72a1a107ba95d816bc15b43100 (diff) | |
download | orgweb-38adb8d0ac6eebbeb5e26d2095526c3ba9459d7a.tar.gz orgweb-38adb8d0ac6eebbeb5e26d2095526c3ba9459d7a.zip |
Add blog posts
Diffstat (limited to 'articles/mounting_music_dir_before_mpd.org')
-rw-r--r-- | articles/mounting_music_dir_before_mpd.org | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/articles/mounting_music_dir_before_mpd.org b/articles/mounting_music_dir_before_mpd.org new file mode 100644 index 0000000..da9918f --- /dev/null +++ b/articles/mounting_music_dir_before_mpd.org @@ -0,0 +1,44 @@ +#+TITLE: +#+OPTIONS: toc:nil c:t +#+HTML_LINK_UP: ../blog.html + +* Mounting music dir before MPD :systemd:mpd:conf: + +Systemd allows you to specify a program to run before running the main +daemon (or program) with =ExecStartPre=. This can, for instance, be used +to run a mount command before starting ~mpd~. By adding under the +=[Service]= heading: + +#+BEGIN_SRC conf-unix + ExecStartPre=/usr/bin/mount /mnt/music +#+END_SRC + +Now I have already setup my ~fstab~ to know what to mount on ~/mnt/music~, +but of course that shouldn't be necessary. According to the +~systemd.service(5)~ man page it uses the same syntax as =ExecStart=, +which tells us that one must use absolute file names since no shell is +used to start them. + +This also has the effect of stopping the =ExecStart= part from the +~.service~ from being executed if the =ExecStartPre= doesn't finish +successfully. Which works out great in my case as I don't want to +start ~mpd~ if my music directory didn't mount. If you want to ignore +the exit status of (one of) the =ExecStartPre= commands you can prefix +it with a ~-~, for example: + +#+BEGIN_SRC conf-unix + ExecStartPre=-/usr/bin/mount /mnt/music +#+END_SRC + +Which would continue running the =ExecStart= even if mounting failed. + +Also know that there can be multiple =ExecStartPre= options and they +will be executed serially, so for example: + +#+BEGIN_SRC conf-unix + ExecStartPre=/usr/bin/mount /mnt/music + ExecStartPre=-/usr/bin/mount /mnt/music2 +#+END_SRC + +This would fail if ~/mnt/music~ doesn't mount, but would continue just +fine if ~/mnt/music~ did and ~/mnt/music2~ didn't. |