Sailfish Os Photo Sync With Ftps E Dot G Fritzbox Nas
Today many users sync their photos and videos with some cloud webspace. Other users have privacy concerns and sync with their owncloud installation or a local NAS. I am one of these other users.
With my Jolla smartphone I was looking for a way to easily sync all photos to some local storage. As a result some linux scripting on the phone and a USB stick in my Fritzbox (Router,AP) did the trick.
My implementation was inspired by some german instruction of how to sync sailfish photos with owncloud (https://blog.mdosch.de/2015/03/05/sailfish-fotos-automatisch-zur-owncloud-hochladen/). At the end I did nearly the same. I will only mention the differences here.
My Fritzbox can act as NAS. You can access connected storage via Webdav, FTPS (and Samba?). What do we need to do:
-
Creating a user (e.g. photo-sync-user) on the router with read/write privileges to some directory. Let’s assume that the router has the IP 192.168.0.10.
-
Install lftp on jolla phone. lftp can mirror directories via FTP in a very handy way. Via Warehouse App the lftp tool can easily be installed. Installation needs some time. Depending libraries are installed automatically.
-
Test accessing local storage on Fritzbox. It raises an error because the certificate is not trusted by lftp :
[nemo@Jolla ~]$ lftp photo-sync-user@192.168.0.10
Password:
lftp photo-sync-user@192.168.0.10:~> ls
ls: Fatal error: Certificate verification: self signed certificate (...)
Thanks to the Internet (http://www.versatilewebsolutions.com/blog/2014/04/lftp-ftps-and-certificate-verification.html) we can solve this problem easily. Download the certificate from the fritzbox and save it as ~/.lftp/fritzboxcert.crt on the phone. After that create the file ~/.lftp/rc with the following content:
set ssl:ca-file "~/.lftp/fritzboxcert.crt"
Now the lftp command returns valid result via FTPS.
- Create scripts on phone for syncing. All steps are explained in the other tutorial. I changed the final sync script to try only once to sync after some change in directory happened.
#!/bin/sh
# Check if we're on wifi
if [ $(/sbin/ifconfig | grep -o wlan0) ]; then
#sync only when connected to wifi
#sync via FTPS
lftp -e "mirror -R ~/Pictures/ jolla/;quit" -u photo-sync-user,INPUTPASSWORDHERE 192.168.0.10
fi
exit
Finally every time a new photo was taken my jolla phone will (try to) sync all camera pictures (~/Pictures/) to the USB stick connected to my router (into folder jolla/).