Created
August 31, 2012 09:20
-
-
Save alick/3550700 to your computer and use it in GitHub Desktop.
Thunderbird Contact Sync tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# vim: set et sw=4: | |
# Thunderbird contact pull and push. | |
usage () | |
{ | |
echo "USAGE:" | |
echo "$0 push/pull" | |
} | |
get_conf () | |
{ | |
conf="$HOME/.config/tbcon" | |
if [ -e "$conf" ]; then | |
source "$conf" | |
fi | |
if [ -n "$local_profile_dir" ] && [ -n "$remote_profile_dir" ]; then | |
return 0 | |
else | |
echo 'ERROR: no configuration found!' | |
echo "Please specify your configuration in the file \`$conf'." | |
echo "You need to provide the values of" | |
printf "\tlocal_profile_dir, remote_profile_dir, and remote_host.\n" | |
return 10 | |
fi | |
} | |
do_push () | |
{ | |
if ! ssh $remote_host /sbin/pidof thunderbird > /dev/null 2>&1; then | |
for mab in abook.mab history.mab; do | |
rsync -abv "$local_profile_dir/$mab" "$remote_profile_dir/$mab" | |
done | |
else | |
echo 'ERROR: thunderbird is running at remote side! Quit first.' | |
fi | |
} | |
do_pull () | |
{ | |
# Check no local thunderbird process running | |
if ! pidof thunderbird > /dev/null 2>&1; then | |
for mab in abook.mab history.mab; do | |
rsync -abv "$remote_profile_dir/$mab" "$local_profile_dir/$mab" | |
done | |
else | |
echo 'ERROR: thunderbird is running! Quit first.' | |
fi | |
} | |
# Main | |
get_conf || exit $? | |
case "$1" in | |
pull) | |
do_pull | |
;; | |
push) | |
do_push | |
;; | |
*) | |
usage | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment