0

My ultimate goal is to have docker wait for my mergerfs mount before it starts docker and for mergerfs to wait for 3 rclone mounts before it starts itself. I've tried 'requires' and bash script for 'execprestart' and 'requiresmountsfor', 'wants=', 'after=', and a combination of all of these things. I've even tried mounting mergerfs via /etc/fstab. None of it works. The systemd services just 'fail' and don't try again because of requirements etc. Nothing waits or keeps trying. What's the proper way to mount rclone, have mergerfs wait until those mounts are successful, then have docker override wait for mergerfs to successfully mount to start?

docker.service.d/override.conf

[Unit]
After=merge.service

{tv,movies,music}.service

[Unit]
Description=tv
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/data/rclone/config/rclone.conf
RestartSec=5
ExecStart=/usr/bin/rclone mount tv: /mnt/media/tv \
--<options>
ExecStop=/bin/fusermount -uz /mnt/media/tv
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
Restart=on-failure
User=user
Group=user

[Install]
WantedBy=multi-user.target

merge.service

[Unit]
Description=merge
After=tv.service movies.service music.service

[Service]
Type=forking
ExecStart=/usr/bin/mergerfs /mnt/local:/mnt/media=NC /mnt/merge -o rw,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=auto-full,nonempty
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target
Danny Michel
  • 61
  • 1
  • 1
  • 11

1 Answers1

0

A quick way to accomplish the goal is to test for existence of the mount via pre start script and have systemd retry on failure.

[Service]
ExecStartPre=/usr/bin/test -f /mnt/media/tv
RestartSec=5s
Restart=on-failure
jcragun
  • 2,060
  • 10
  • 8