Nextcloud, sync without GUI

nextcloud

Is there a way to sync a PC with a nextcloud server, but without the desktop GUI?

Syncing should happen as soon as the PC has booted. Even if the user does not log in yet.

I know the nextcloudcmd. I could run a cron job and call “nextcloudcmd` every N minutes.

But this is not nice.

I really prefer a solution where the sync happens immediately (for example via inotify).

How could this be done?

I think a shell script wrapping nextcloudcmd is just a work-around.

If nextcloud does not provide this, then I will use seafile which can do this. See: https://manual.seafile.com/deploy/start_seafile_at_system_bootup.html

I personally think this is very strange. The GUI can do this. I just want the same thing, but without a GUI. Yes, I could run the GUI in a "fake" framebuffer X environment … but no, that's too dirty.

Best Answer

This requires basic shell scripting: test for the presence of a lock file, if not present create the lock file, run the update, remove the lock file. This way the nextcloudcmd isn't launched several times.

Untested proof of concept:

#!/bin/sh

LOCKFILE=/var/lock/ncupdate.lock

[ -e $LOCKFILE ] && kill -0 $(cat $LOCKFILE) 2>/dev/null  && exit;


echo $$ > $LOCKFILE
nextcloudcmd
rm $LOCKFILE

Update: it tests for the running process, so if the script get killed it will run anyway and overwrite the PID.

Related Topic