Ubuntu Touch: Add contact list and calendars
I successfully set up the synchronization of my Owncloud server's default calendar and default contact list based on this askubuntu thread. I have more than one calendar and contact list on my Owncloud server though. I have checked the calendar and contact apps for ways of adding new contact lists and calendars. The contact app does not seem to offer this feature. The calendar app has an option to add new calendars, but when I press the respective button, I am forwarded to the system settings page. Thanks for your hints in advance! M.
(my device is a BQ Aquaris E4.5 with Ubuntu 14.10-r21)
Solution 1:
I can share this script based on alexandre_payet answers, which will add 1 Contact address-book, and 1 calendar, from your owncloud server, to sync with your phone.
Script
#!/bin/bash
# ---------------------------------------------------------------------------
# Ubuntu Phone - Sync Owncloud Contacts & Calendar Account
# Carddav & Caldav.
# Tested on : Ubuntu-touch vivid - ubuntu-touch/rc-proposed/bq-aquaris.en/vegetahd/
# Last edit : 2015/08/23.
# Author : Romain Fluttaz, boTux.fr, <[email protected]>
# ============= [ Configuration ] ============= #
# --------------- [ OwnCloud ] ---------------- #
# Server and user informations
HTTP_PROTOCOL="https" # "http" or "https". It's recommended to use an $HTTP_PROTOCOL connection
OWNCLOUD_URL="cloud.domain.com" # Without the last /.
USERNAME="owncloud-user" # Your OwnCloud username
PASSWORD="owncloud-password" # Your OwnCloud password
# Contact addressbooks
CONTACT_ADDRESSBOOK_NAME="contacts" # Check in the contact setting page.
# Calendar
CALENDAR_NAME="personnel" # Check in the calendar setting page.
# Database
OC_DATABASE_NAME="owncloud"
# ----------------- [ Phone ] ----------------- #
# Database name :
CONTACT_DB_NAME="Contacts-name" # Contact addressbook name on the phone
CALENDAR_DB_NAME="Calendar-name" # Calendar name on the phone
# CRON job
CRON_FREQUENCY="hourly" # Cronjob frequency. "hourly", "dayly", "weekly", "monthly". See $HTTP_PROTOCOL://help.ubuntu.com/community/CronHowto#Advanced_Crontab
# ============= [ /Configuration ] ============ #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
# Thanks to :
# alexandre_payet @ https://askubuntu.com/questions/616081/ubuntu-touch-add-contact-list-and-calendars
# alexandre_payet @ https://askubuntu.com/questions/611761/syncevolution-in-cronjob-to-sync-the-ubuntu-phone-via-caldav-arddav
# alexandre_payet @ https://askubuntu.com/questions/629219/automatically-sync-calendar-on-ubuntu-phone/629728#629728
# Usage: Edit the config section and run the script.
# Revision history:
# 2015-08-22 Adding 1 Contact & 1 Calendar.
# 2015-08-22 Add cronjob support.
# ---------------------------------------------------------------------------
echo "\e[4mAdding OwnCloud account : **$OWNCLOUD_URL**\e[0m"
echo ""
# Contact
echo -e "[\e[0;34m Contacts \e[m] $CONTACT_ADDRESSBOOK_NAME @ $OC_DATABASE_NAME"
syncevolution --create-database backend=evolution-contacts database=$CONTACT_DB_NAME
syncevolution --configure --template webdav username=$USERNAME password=$PASSWORD syncURL=$HTTP_PROTOCOL://$OWNCLOUD_URL/remote.php/ keyring=no target-config@$OC_DATABASE_NAME
syncevolution --configure backend=evolution-contacts database=$CONTACT_DB_NAME @default $CONTACT_DB_NAME
syncevolution --configure database=$HTTP_PROTOCOL://$OWNCLOUD_URL/remote.php/carddav/addressbooks/$USERNAME/$CONTACT_ADDRESSBOOK_NAME backend=carddav target-config@$OC_DATABASE_NAME $CONTACT_DB_NAME
syncevolution --configure --template SyncEvolution_Client Sync=None syncURL=local://@$OC_DATABASE_NAME username= password= $OC_DATABASE_NAME $CONTACT_DB_NAME
syncevolution --configure sync=two-way backend=evolution-contacts database=$CONTACT_DB_NAME $OC_DATABASE_NAME $CONTACT_DB_NAME
echo " +--> $CONTACT_DB_NAME @ local"
syncevolution --sync refresh-from-remote $OC_DATABASE_NAME $CONTACT_DB_NAME
syncevolution --sync slow $OC_DATABASE_NAME $CONTACT_DB_NAME
echo -e "[\e[0;34m Contacts \e[m] +--> Done."
echo ""
# Calendar
echo -e "[\e[33m Calendar \e[m] $CALENDAR_NAME @ $OC_DATABASE_NAME"
syncevolution --create-database backend=evolution-calendar database=$CALENDAR_NAME
syncevolution --configure --template webdav username=$USERNAME password=$PASSWORD syncURL=$HTTP_PROTOCOL://$OWNCLOUD_URL/remote.php/ keyring=no target-config@$OC_DATABASE_NAME
syncevolution --configure backend=evolution-calendar database=$CALENDAR_NAME @default $CALENDAR_NAME
syncevolution --configure database=$HTTP_PROTOCOL://$OWNCLOUD_URL/remote.php/caldav/calendars/$USERNAME/$CALENDAR_DB_NAME backend=caldav target-config@$OC_DATABASE_NAME $CALENDAR_NAME
syncevolution --configure --template SyncEvolution_Client syncURL=local://@$OC_DATABASE_NAME username= password= $OC_DATABASE_NAME $CALENDAR_NAME
syncevolution --configure sync=two-way database=$CALENDAR_NAME $OC_DATABASE_NAME $CALENDAR_NAME
echo " +--> $CALENDAR_DB_NAME @ local"
syncevolution --sync refresh-from-remote $OC_DATABASE_NAME $CALENDAR_NAME
echo -e "[\e[33m Calendar \e[m] +--> Done."
echo ""
# Cron
echo -e "[\e[0;36m Cron \e[m]"
echo -e " +--> \e[0;31mGranting SuperUser Access\e[m"
sudo mount /dev/loop0 / -o remount,rw
CRON_LINE="@$CRON_FREQUENCY export DISPLAY=:0.0 && 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) && /usr/bin/syncevolution $OC_DATABASE_NAME"
(crontab -u phablet -l; echo "$CRON_LINE" ) | crontab -u phablet -
sudo service cron restart
crontab -l | grep "$CRON_LINE"
echo -e "[\e[0;36m Cron \e[m] +--> Added."
echo ""
# First Normal Sync
echo -e "[\e[0;32m Syncronisation \e[m]"
syncevolution $OC_DATABASE_NAME
echo -e "[\e[0;32m Syncronisation \e[m] +--> Done."
# Print information
echo ""
echo ""
echo ""
echo "# To manually sync your accounts, use the command below :"
echo ""
echo -e " syncevolution $OC_DATABASE_NAME \e[m"
echo " or"
echo -e "\e[0;34msyncevolution $OC_DATABASE_NAME $CONTACT_DB_NAME\e[m | \e[33msyncevolution $OC_DATABASE_NAME $CALENDAR_NAME\e[m"
echo ""
echo "See 'syncevolution --help' to get more information."
Download ubuntu-touch_owncloud-sync_contact-calendar.sh | Github Gist
Tested on the ubuntu-touch/rc-proposed/bq-aquaris.en/vegetahd channel
How to use
Edit the configuration section, and execute on your ubuntu-phone.
From an Ubuntu desktop
(with : phablet-tools installed from ppa)
- Add phablet-shell
sudo add-apt-repository ppa:phablet-team/tools sudo apt-get update sudo apt-get install phablet-tools
- Activate Developer mode
- Download and edit the script :
wget https://gist.githubusercontent.com/boTux/069b53d8e06bdb9b9c97/raw/a03be09136c5275b2956c512accdad69b30e8074/ubuntu-touch_owncloud-sync_contact-calendar.sh gedit ubuntu-touch_owncloud-sync_contact-calendar.sh
- In the [Configuration] / [OwnCloud] Section
- Enter your OWNCLOUD_URL, whithout the last /.
- Enter your USERNAME & PASSWORD.
- Enter the name of your owncloud address-book & calendar.
- In the [Configuration] / [Phone] Section
- Edit CONTACT_DB_NAME & CALENDAR_DB_NAME with names of your choosing.
- Edit CRON_FREQUENCY to the sync interval you need.
- Save
- In the [Configuration] / [OwnCloud] Section
- Connect your phone via USB and copy the script (via nautilus, for example in Documents/)
- Connect via phablet-shell and run the script :
phablet-shell chmod +x Documents/ubuntu-touch_owncloud-sync_contact-calendar.sh ./Documents/ubuntu-touch_owncloud-sync_contact-calendar.sh
I'm hoping this can help some of you...
Solution 2:
To add and sync calendars and contacts with owncloud, you can use commands lines in terminal.
I've found it on https://lists.launchpad.net/ubuntu-phone/msg09789.html
Note : A good way to do that it's from a Desktop terminal connected to your ubuntu phone using ssh (then you can easily copy the commands lines). But it should work in the Terminal app of the phone as well
Calendar
Create Calendar
syncevolution --create-database backend=evolution-calendar database=Calendar1
Create Peer
syncevolution --configure --template webdav username=myusername password=mypassword syncURL=https://url-to-owncloud-install/remote.php/caldav/calendars/user-name/defaultcalendar keyring=no target-config@owncloud
Create New Source
syncevolution --configure backend=evolution-calendar database=Calendar1 @default Calendar1
Add remote database
syncevolution --configure database=https://url-to-owncloud-install/remote.php/caldav/calendars/user-name/defaultcalendar backend=caldav target-config@owncloud Calendar1
Connect remote calendars with local databases
syncevolution --configure --template SyncEvolution_Client syncURL=local://@owncloud username= password= owncloud Calendar1
Add local database to the source
syncevolution --configure sync=two-way database=Calendar1 owncloud Calendar1
Start firt sync
syncevolution --sync refresh-from-remote owncloud Calendar1
You can do that for calendar1, then calendar2, ...
In these commands lines, don't forget to replace :
For command N°2
'myusername' by your owncloud username
'mypassword' by your owncloud password
'https://url-to-owncloud-install/remote.php/caldav/calendars/user-name/defaultcalendar' by the adress link of calendar1 or calendar2 , ....
For command N°4
'https://url-to-owncloud-install/remote.php/caldav/calendars/user-name/defaultcalendar' by the adress link of calendar1 or calendar2 , ....
Contact :
The same way :
syncevolution --create-database backend=evolution-contacts database=Contact1
syncevolution --configure --template webdav username=myusername password=mypassword syncURL=Your_contact1_owcloud_adress keyring=no target-config@owncloud
syncevolution --configure backend=evolution-contacts database=Contact1 @default Contact1
syncevolution --configure database=Your_contact1_owcloud_adress backend=carddav target-config@owncloud Contact1
syncevolution --configure --template SyncEvolution_Client Sync=None syncURL=local://@owncloud username= password= owncloud Contact1
syncevolution --configure sync=two-way backend=evolution-contacts database=Contact1 owncloud Contact1
syncevolution --sync refresh-from-remote owncloud Contact1
Same remarks than calendar. I've tested it with only one contact database, but it should works for Contact2, Contact3, ...
For contact, make sure you use 'backend=evolution-contacts' and 'backend=carddav'(difference between calendar and contact commands lines)
Important : For the next sync, you just have to do :
syncevolution owncloud calendar1
syncevolution owncloud contact1
and calendar2, contact2, ...
To synchronize contacts and calendars automatically, you can use a crontab job to launch theses commands when you want to. You can see this post : Syncevolution in cronjob to sync the ubuntu phone via caldav/arddav
Hope there is no mistake in my commands lines.