#!/bin/bash #****************************************************************** #ident my-sync-tb2nokia Time-stamp: <2011-11-18 08:28:46 bav> #****************************************************************** # Gerd Bavendiek http://linos.wordpress.com 16-11-11 # # Usage: my-sync-tb2nokia # # Very dumb wrapper script for syncevolution. # # Basically this script will use the provided addressbook.vcf and the # calendar.ics to create files suitable for syncevolution. You must have # created a (hopefully working) syncevolution configuration named # SyncEvolutionConfigName in the first place. You really may want to read # http://TODO # before running this. # # See http://syncevolution.org for the real story. # #------------------------------------------------------------------ unset LANG usage() { echo $0 ' ' exit 0 } ###if [ $# -eq 0 ]; then usage; fi case $1 in '--help'|'-h') usage;; esac # With version 2.32.2-0ubuntu2 in Natty, evolution-data-server newer worked for me. # For this reason I stick to Oneiric. . /etc/lsb-release if [ $DISTRIB_CODENAME != oneiric ]; then echo Sorry, Ubuntu Oneiric is the only platform I ever tested with success, aborting ...; exit 1; fi # These are just for my personal comfort ... EXPORTED_TB_ABOOK=${1:-~/Home.vcf} EXPORTED_TB_CALENDAR=${2:-~/Home.ics} SYNCEVOLUTION_CONFIG_NAME=${3:-e66} if [ ! -r $EXPORTED_TB_ABOOK ]; then echo No exported Thunderbird addressbook $EXPORTED_TB_ABOOK found, aborting ...; exit 1; fi if [ ! -r $EXPORTED_TB_CALENDAR ]; then echo No exported Thunderbird calendar $EXPORTED_TB_CALENDAR found, aborting ...; exit 1; fi # We really need this package ... dpkg -l evolution-data-server | sed -n '$p' | grep -q ^ii if [ $? -ne 0 ]; then echo Package evolution-data-server seems not to be installed, aborting ...; exit 1; fi # Check wether SyncEvolutionConfigName has been configured ... syncevolution --quiet --print-config $SYNCEVOLUTION_CONFIG_NAME 1>/dev/null 2>&1 if [ $? -ne 0 ]; then echo Could not find such an syncevolution config $SYNCEVOLUTION_CONFIG_NAME, aborting ...; exit 1; fi # Create evolution directories and files if necessary (first run !!!) mkdir -p ~/.local/share/evolution/addressbook/system mkdir -p ~/.local/share/evolution/calendar/system mkdir -p ~/.local/share/evolution/tasks/system EVOLUTION_CALENDAR=~/.local/share/evolution/calendar/system/calendar.ics # Step 1 - create a simple (i.e. empty) task file. Currently we do not care about tasks anyway... cat > ~/.local/share/evolution/tasks/system/tasks.ics < $EVOLUTION_CALENDAR sed -n '3,$p' $EXPORTED_TB_CALENDAR >> $EVOLUTION_CALENDAR if [ $? -eq 0 ]; then echo 'Created new Evolution calendar from your exported Thunderbird calendar ...' else echo 'Error creating new Evolution calendar from your exported Thunderbird calendar, aborting ...' exit 1 fi # Step 3 - create an empty addressbook and then fill it from the exported Thunderbird addressbook syncevolution --delete-items @default addressbook '*' if [ $? -ne 0 ]; then echo 'Error deleting the addressbook, aborting ...' exit 1 fi syncevolution --import $EXPORTED_TB_ABOOK @default addressbook if [ $? -ne 0 ]; then echo 'Error importing $EXPORTED_TB_ABOOK, aborting ...' exit 1 fi # Step 4 - run syncevolution syncevolution --run printChanges=0 dumpData=0 $SYNCEVOLUTION_CONFIG_NAME # No need to check for the returncde here. syncevolution gives a pretty clear feedback ...