Syncevolution in cronjob to sync the ubuntu phone via caldav/arddav
I want to sync my contacts and calendar from my Ubuntu Phone to a self-hosted owncloud server. Since there is no out-of-the-box support yet, I tried this explaination. However, this only works from within the terminal on the ubuntu phone. If I try
syncevolution --sync slow owncloud calendar
over adb or from a cronjob, I get
creating source registry: Cannot autolaunch D-Bus without X11 $DISPLAY
Can anyone please help me?
I've understood that "syncevolution --sync slow owncloud calendar" should be use only for the first sync.
After that you should use :
syncevolution owncloud calendar
To do a cron job, I've got the same issue. One solution which work for me is :
Method 1 :
export DISPLAY=:0.0 && export DBUS_SESSION_BUS_ADDRESS=Yourdbussessioadress && /usr/bin/syncevolution owncloud calendar
To get Yourdbussessioadress :
echo $DBUS_SESSION_BUS_ADDRESS
Method 2 : I put these commands in an syncevolution.sh script like that :
#!/bin/sh
# Synchronisation des calendriers syncevolution
export DISPLAY=:0.0
export DBUS_SESSION_BUS_ADDRESS=Yourdbussessioadress
syncevolution owncloud calendar
exit 0
I've placed this script in /home/phablet/bin, make it executable and do this in crontab -e
@daily sh /home/phablet/bin/synccalendar.sh
I'm still stuck on one thing. The $DBUS_SESSION_BUS_ADDRESS value is changing at reboot of ubuntu. I've got an other script on internet (using the command sed) to put the good value of $DBUS_SESSION_BUS_ADDRESS in the syncevolution.sh script. I've put this script in /etc/rc.local to do the job on reboot of ubuntu. But it doesn't work for me (Its like $DBUS_SESSION_BUS_ADDRESS is empty just after reboot)
If someone could help more.
UPDATE 22/04/15 :
Replace "export DBUS_SESSION_BUS_ADDRESS=Yourdbussessioadress" by theses commands :
export DBUS_SESSION_BUS_ADDRESS=$(ps -u phablet e | grep -Eo 'dbus-daemon.*address=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35)
It works like a charm for me (tested with Method 2 using a sh script where "phablet" is the default user of ubuntu touch). Thanks to a KDE forum where I've found theses commands lines.
(Next steps :
Find a way to do a backup of photos on personal server with rsync using ssh and why not after a backup of SMS&MMS, some configurations files, ...
Mount an sftp server on ubuntu touch)