Headless install failing to restart on boot with data mounted on a smb share

As stated above, when rebooting the insync-headless get_status command reports “ERROR”, while get_errors reports “None”. My suspicion is that since I have the data to be synced in a samba mounted share in fstab the crontab line starts the service before the filesystem is ready, it then proceeds to barf and give up.

Is there a way to delay starting insync at boot by a couple of minutes? Else it should keep trying every 15 seconds or so to see if the filesystem is available.

Solved by creating the following systemd service:

/etc/systemd/system/insync-headless.service

[Unit]
Description=Insync Service
After=network.target
RequiresMountsFor=/PATH/TO/YOUR/MOUNTED/SHARE

[Service]
Type=oneshot
User=YOURUSERHERE
ExecStart=/usr/bin/insync-headless start
ExecStop=/usr/bin/insync-headless quit
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Then enabling the service and setting it as a dependency for the multi-user target:

$ sudo systemctl enable insync-headless
$ ln -s ‘/etc/systemd/system/insync-headless.service’ ‘/etc/systemd/system/multi-user.target.wants/insync-headless.service’

Manually start/stop with:

$ sudo service insync-headless start/stop

I cobbled together this by reading systemd manuals, never done this before so it may do more than it needs. If it contains extra stuff (such as its dependencies) please feel free to post your suggestions. It does what it’s supposed to do though.

1 Like

Thanks @voidburn, we’re looking into making this a how-to, thanks for confirming!

Be advised that it works, but I ended up not using it because mounted filesystems do not emit events on change. If you want to use it it will require a polling parameter that scans the filesystem. Surely something useful to have!