NextCloud Client Command Line
I have a headless server - one without a GUI - which I use as a NextCloud client. My laptop, phone, tablet, and server all sync with a cloud-based NextCloud instance.
But, sadly, NextCloud don't offer a way for servers to speak to servers. If you try to run apt install nextcloud
it will try to install 300MB of GUI dependencies which you just can't use.
Luckily, there's a way around all that! It's a bit convoluted, so here's a guide.
Download the latest AppImage
Grab the link for the most recent AppImage
On your server:
mkdir nextcloudapp
cd nextcloudapp
wget https://github.com/nextcloud/desktop/releases/download/????.AppImage -O Nextcloud.AppImage
Make it executable:
chmod +x Nextcloud.AppImage
Next, extract it:
./Nextcloud.AppImage --appimage-extract
That will place all the files in squashfs-root/
I moved all the files and folders out of there to a more convenient location.
You may need to install some dependencies:
sudo apt install libgl1 libharfbuzz0b
Finally, you need to export the libraries which were in the app image:
export LD_LIBRARY_PATH=~/nextcloudapp/usr/lib
Running it
I recommend creating an app specific password on your NextCloud admin interface.
You can run NextCloud as a one-off job using:
./nextcloudcmd -u "MyUserName" -p "P4ssw0rd" /path/to/NextCloud/ https://your_online.nextcloud.example/
That will spit out a lot of log files. You can make it run silently with the -s
option. Probably best to run it in a tmux
.
Make it persistent
Sadly, there's no way to permanently set the LD_LIBRARY_PATH. So you'll need to export the library each time you want to sync.
If only NextCloud offered a headless daemon. Ah well!
Bugs
There is a bug with the CLI version where it won't download files with a colon in the filename.
Ben Hardill said on bluetoot.hardill.me.uk:
@Edent You should be able to add LD_LIBRARY_PATH to a script wrapper round the nextcloudcmd command or an alias to
LD_LIBRARY_PATH=~/... nextcloudcmd ...
Max :verified: said on toet.dnzm.nl:
@Edent Haven't tried myself, but according to this document, you should be able to prefix your command with /lib/ld-linux.so.2 --library-path PATH which might make things easier.
No idea if systemd has anything for it, either, but that might be worthy of a quick search as well. Shared Libraries
More comments on Mastodon.