-
-
Save bastos77/0c47a94dd0bf3e394f879c0ff42b7839 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# This script is a draft combination of the script found at https://gist.github.com/tcarrondo | |
# It is what I have done to make it work for my Fairphone 2 with UBports ubuntu touch 16.04 | |
# Combined by me: Sebastian Gallehr <[email protected]> | |
# Thanks to: Tiago Carrondo <[email protected]> | |
# Thanks to: Romain Fluttaz <[email protected]> | |
# Thanks to: Wayne Ward <[email protected]> | |
# Thanks to: Mitchell Reese <[email protected]> | |
# --------------- [ Server ] ---------------- # | |
CAL_URL="https://..." # add the caldav URL here | |
CONTACTS_URL="https://...." # add the carddav URL here | |
USERNAME="" # you know this one | |
PASSWORD="" # lots of ****** | |
# ----------------- [ Phone ] ----------------- # | |
CALENDAR_CONFIG_NAME="sogokalender" # I use "myCloud" | |
CONTACTS_CONFIG_NAME="sogoadressen" # I use "myCloud" | |
CALENDAR_NAME="sogokalender" # I use "personalcalendar" | |
CALENDAR_VISUAL_NAME="sogokalender" # you can choose a nice name to show on the calendar app like "OwnCalendar" | |
CONTACTS_NAME="sogoadressen" # I use "personalcontacts" | |
CONTACTS_VISUAL_NAME="sogoadressen" # you can choose a nice name to show on the contacts app like "OwnContacts" | |
CRON_FREQUENCY="hourly" # I use "hourly" | |
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) | |
#Create Calendar | |
syncevolution --create-database backend=evolution-calendar database=$CALENDAR_VISUAL_NAME | |
#Create Peer | |
syncevolution --configure --template webdav username=$USERNAME password=$PASSWORD syncURL=$CAL_URL keyring=no target-config@$CALENDAR_CONFIG_NAME | |
#Create New Source | |
syncevolution --configure backend=evolution-calendar database=$CALENDAR_VISUAL_NAME @default $CALENDAR_NAME | |
#Add remote database | |
syncevolution --configure database=$CAL_URL backend=caldav target-config@$CALENDAR_CONFIG_NAME $CALENDAR_NAME | |
#Connect remote calendars with local databases | |
syncevolution --configure --template SyncEvolution_Client syncURL=local://@$CALENDAR_CONFIG_NAME $CALENDAR_CONFIG_NAME $CALENDAR_NAME | |
#Add local database to the source | |
syncevolution --configure sync=two-way database=$CALENDAR_VISUAL_NAME $CALENDAR_CONFIG_NAME $CALENDAR_NAME | |
#Start first sync | |
syncevolution --sync refresh-from-remote $CALENDAR_CONFIG_NAME $CALENDAR_NAME | |
#Create contact list | |
syncevolution --create-database backend=evolution-contacts database=$CONTACTS_VISUAL_NAME | |
#Create Peer | |
syncevolution --configure --template webdav username=$USERNAME password=$PASSWORD syncURL=$CONTACTS_URL keyring=no target-config@$CONTACTS_CONFIG_NAME | |
#Create New Source | |
syncevolution --configure backend=evolution-contacts database=$CONTACTS_VISUAL_NAME @default $CONTACTS_NAME | |
#Add remote database | |
syncevolution --configure database=$CONTACTS_URL backend=carddav target-config@$CONTACTS_CONFIG_NAME $CONTACTS_NAME | |
#Connect remote contact list with local databases | |
syncevolution --configure --template SyncEvolution_Client Sync=None syncURL=local://@$CONTACTS_CONFIG_NAME $CONTACTS_CONFIG_NAME $CONTACTS_NAME | |
#Add local database to the source | |
syncevolution --configure sync=two-way backend=evolution-contacts database=$CONTACTS_VISUAL_NAME $CONTACTS_CONFIG_NAME $CONTACTS_NAME | |
#Start first sync | |
syncevolution --sync refresh-from-remote $CONTACTS_CONFIG_NAME $CONTACTS_NAME | |
#Add Sync Cronjob | |
sudo mount / -o remount,rw | |
COMMAND_LINE="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 $CALENDAR_CONFIG_NAME && /usr/bin/syncevolution $CONTACTS_CONFIG_NAME" | |
sudo echo "$COMMAND_LINE" > /sbin/sogosync | |
sudo chmod +x /sbin/sogosync | |
CRON_LINE="@$CRON_FREQUENCY /sbin/sogosync" | |
(crontab -u phablet -r;) # only if no other cronjob already exist in the crontab | |
(crontab -u phablet -l; echo "$CRON_LINE" ) | crontab -u phablet - | |
sudo mount / -o remount,ro | |
sudo service cron restart |
Thanks! works for me(PRO5/Ubports) making some changes...
-at line 60:
changing $CALENDAR_NAME
& $CONTACTS_NAME
variables to $CALENDAR_CONFIG_NAME
& $CONTACTS_CONFIG_NAME
-at line 61:
sudo sh -c "echo '$COMMAND_LINE' > /sbin/sogosync"
, instead of sudo echo "$COMMAND_LINE" > /sbin/sogosync
, to avoid permission denied error
Forked this gist with patched above applied
added CONTACT_URL in line 11 thanks to olisax
changed $CALENDAR_NAME & $CONTACTS_NAME variables to $CALENDAR_CONFIG_NAME & $CONTACTS_CONFIG_NAME in line 61 thanks to ghost
How can i edit line 25 CRON_FREQUENCY="hourly" # I use "hourly" ?
I want to run some devices with this script on different times.
For example:
CRON_FREQUENCY="30 * * * *" # I use "hourly"
don't work with these crontab-format.
I'd like these concept:
Device 1 : each 5. minute per hour
Device 2 : each 15. minute per hour
Device 3 : each 25. minute per hour
Hi will this work with the latest Ubuntu Touch 16.04 (OTA-10) ?
Hi will this work with the latest Ubuntu Touch 16.04 (OTA-10) ?
Yes, it works. And really reliable. But unfortunately not the cron job. So no automatic regular sync. My workaround is, that I start the script in terminal manually (type sogosync
and than execute) every time I need updated calender or contacts.
But please help. Maybe someone will be able to fix this bug
I notice that on the doc there: http://docs.ubports.com/en/latest/userguide/advanceduse/dav.html
it is written to replace 👍
sudo echo "$COMMAND_LINE" > /sbin/sogosync
by
sudo sh -c echo "$COMMAND_LINE" > /sbin/sogosync
also ligne 11 replace
# add the caldav URL here
by
# add the carddav URL here
How can i edit line 25 CRON_FREQUENCY="hourly" # I use "hourly" ?
I want to run some devices with this script on different times.
For example:
CRON_FREQUENCY="30 * * * *" # I use "hourly"
don't work with these crontab-format.
I'd like these concept:
Device 1 : each 5. minute per hour
Device 2 : each 15. minute per hour
Device 3 : each 25. minute per hour
Hi,
did you ever resolve this?
Hi will this work with the latest Ubuntu Touch 16.04 (OTA-10) ?
Yes, it works. And really reliable. But unfortunately not the cron job. So no automatic regular sync. My workaround is, that I start the script in terminal manually (type
sogosync
and than execute) every time I need updated calender or contacts.
But please help. Maybe someone will be able to fix this bug
-bash: sogosync: command not found
How can i edit line 25 CRON_FREQUENCY="hourly" # I use "hourly" ?
I want to run some devices with this script on different times.
For example:
CRON_FREQUENCY="30 * * * *" # I use "hourly"
don't work with these crontab-format.
I'd like these concept:
Device 1 : each 5. minute per hour
Device 2 : each 15. minute per hour
Device 3 : each 25. minute per hourHi,
did you ever resolve this?
Personally I don't because the cronjob as such is not working for me anymore as stated above.
Have a look here, maybe this could help: https://wiki.ubuntuusers.de/Cron/
How can i edit line 25 CRON_FREQUENCY="hourly" # I use "hourly" ?
I want to run some devices with this script on different times.
For example:
CRON_FREQUENCY="30 * * * *" # I use "hourly"
don't work with these crontab-format.
I'd like these concept:
Device 1 : each 5. minute per hour
Device 2 : each 15. minute per hour
Device 3 : each 25. minute per hourHi,
did you ever resolve this?Personally I don't because the cronjob as such is not working for me anymore as stated above.
Have a look here, maybe this could help: https://wiki.ubuntuusers.de/Cron/
I managed to make it work now. First I removed the existing contacts:
syncevolution --remove-database backend=evolution-contacts database=NextContacts
syncevolution --remove-database backend=evolution-calendar database=NextCalendar
Next I removed files/folder in .cache/syncevolution
Then I installed again the script. To manually launch an update, I open a Terminal on the device and type:
syncevolution myCloud
(CALENDAR_CONFIG_NAME=myCloud)
Cheers
I use UT 16.04 (OTA-12) and calendar sync with nextcloud is now supported in the calendar app via gui but contacts unfortunately still not,
so i try to trim the script only for contacts without cronjob (i think there is no need) but it seems to be a problem with datastore and configuration template. Syncevolution can`t find the datastore (CONTACTS_NAME=)"sogoadressen" and no configuration template for
(CONTACTS_CONFIG_NAME=)"sogoadressen" is available. Any ideas?
I use UT 16.04 (OTA-12) and calendar sync with nextcloud is now supported in the calendar app via gui but contacts unfortunately still not,
so i try to trim the script only for contacts without cronjob (i think there is no need) but it seems to be a problem with datastore and configuration template. Syncevolution can`t find the datastore (CONTACTS_NAME=)"sogoadressen" and no configuration template for
(CONTACTS_CONFIG_NAME=)"sogoadressen" is available. Any ideas?
Okay now it works. I follow this tutorial https://help.ubuntu.com/community/SyncEvolution/synchronize-google-contacts-with-evolution-addressbooks and made some adjustments.
I do it without a script an run the commands in descending order in the adb shell:
(customize username, Password and url)
`#config=next-conf
#datastore=next-datastore
#0. create database
syncevolution --create-database backend=evolution-contacts database=NextContacts
#1. create peer
syncevolution --configure --template webdav username=John password=johnssecret keyring=no target-config@next-conf
#2. create new datastore
syncevolution --configure backend=evolution-contacts database=NextContacts @default next-datastore
#3. Add a remote database to the datastore
syncevolution --configure database= https://domain.com/remote.php/dav/addressbooks/users/john/contacts/ backend=carddav target-config@next-conf next-datastore
#4. Connect remote Contacts with the local Database
syncevolution --configure --template SyncEvolution_Client syncURL=local://@next-conf username=john password=johnssecret next-conf next-datastore
#5. Add a local database to the datastore
syncevolution --configure sync=two-way backend=evolution-contacts database=NextContacts next-conf next-datastore
#6 first time syncing
syncevolution --sync refresh-from-remote next-conf next-datastore`
Hello,
There is an error in this script, on line 61, so that the cron jobs never work.
COMMAND_LINE="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 $CALENDAR_CONFIG_NAME && /usr/bin/syncevolution $CONTACTS_CONFIG_NAME"
where DBUS_SESSION_BUS_ADDRESS=$(ps
should be replaced by DBUS_SESSION_BUS_ADDRESS=\$(ps
Please can you change this script ?
As a matter of fact, it is used in the UBTouch Doumentation here: https://docs.ubports.com/en/latest/userguide/advanceduse/dav.html.
It would be nice .
Thanks in advance
where DBUS_SESSION_BUS_ADDRESS=$(ps should be replaced by DBUS_SESSION_BUS_ADDRESS=$(ps
Please can you change this script ?
done.
@Marc-Flender thanks. I have changed it.
Sorry
On line 11 you should also define CONTACTS_URL="https://..." otherwise on line 50 there are no contacts to import...