Skip to content

Instantly share code, notes, and snippets.

@tcarrondo
Last active July 30, 2020 08:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tcarrondo/c932750928c83310fd84f8376ee17f30 to your computer and use it in GitHub Desktop.
Save tcarrondo/c932750928c83310fd84f8376ee17f30 to your computer and use it in GitHub Desktop.
Script simples para sincronizar um caledário caldav com o Ubuntu Touch. Adiciona a configuração do calendário de forma independente e adiciona uma tarefa automática para que ele sincronize periodicamente.
#!/bin/bash
# Simplified by me, Tiago Carrondo <tcarrondo@ubuntu.com>
# Thanks to: Romain Fluttaz <romain@botux.fr>
# Thanks to: Wayne Ward <info@wayneward.co.uk>
# Thanks to: Mitchell Reese <mitchell@curiouslegends.com.au>
# --------------- [ Server ] ---------------- #
CAL_URL=" " # add the caldav URL here
USERNAME=" " # you know this one
PASSWORD=" " # lots of ******
# ----------------- [ Phone ] ----------------- #
CONFIG_NAME=" " # I use "mycloud" (only lowercase allowed)
CALENDAR_NAME=" " # I use "personalcalendar"
CALENDAR_VISUAL_NAME=" " # you can choose a nice name to show on the calendar app like "OwnCalendar"
CRON_FREQUENCY= " " # I use "hourly"
#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@$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@$CONFIG_NAME $CALENDAR_NAME
#Connect remote calendars with local databases
syncevolution --configure --template SyncEvolution_Client syncURL=local://@$CONFIG_NAME $CONFIG_NAME $CALENDAR_NAME
#Add local database to the source
syncevolution --configure sync=two-way database=$CALENDAR_VISUAL_NAME $CONFIG_NAME $CALENDAR_NAME
#Start first sync
syncevolution --sync refresh-from-remote $CONFIG_NAME $CALENDAR_NAME
#Add Sync Cronjob
sudo mount / -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 $CONFIG_NAME"
(crontab -u phablet -l; echo "$CRON_LINE" ) | crontab -u phablet -
sudo mount / -o remount,ro
sudo service cron restart
@bastos77
Copy link

In line 16 I added
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)

Than script works without errors on my fairphone 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment