|
#!/bin/bash
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
user="username"
|
|
pass="password"
|
|
host="hostname"
|
|
port=5232
|
|
url="https://$host:$port/$user/contacts.vcf"
|
|
|
|
|
|
# check if the addressbook is available
|
|
curl --silent --insecure\
|
|
--basic\
|
|
--user "$user:$pass"\
|
|
--request HEAD\
|
|
--header "Accept: text/vcard"\
|
|
--write-out "%{http_code}"\
|
|
"$url"\
|
|
| grep --silent -E "2[0-9]{2}"
|
|
|
|
if [ $? -gt 0 ];
|
|
then
|
|
echo No access to adressbook at $url.
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# Write the complete addressbook to a temp-file
|
|
curl --silent --insecure\
|
|
--basic --user "$user:$pass"\
|
|
--request GET\
|
|
--header "Accept: text/vcard"\
|
|
"$url"\
|
|
> /tmp/vcards.vcf
|
|
|
|
|
|
# Reduce to the fields we are interested in:
|
|
# N:Name;Part;More;parts;;
|
|
# FN:Full Name
|
|
# NICKNAME: Nicky
|
|
sed -r\
|
|
-e "/^(FN|N|NICKNAME):.+$/!d"\
|
|
-e "s/(N|FN|NICKNAME)://"\
|
|
-e "s/;+/\n/g"\
|
|
/tmp/vcards.vcf\
|
|
> /tmp/names
|
|
|
|
# will filter the list and include only
|
|
# names that would be regarded as spelling errors
|
|
~/scripts/mk-aspell-dict.sh /tmp/names /home/USERNAME/.aspell-names.en.pws
|
|
|
|
rm /tmp/vcards.vcf
|
|
rm /tmp/names
|