forked from Trim/qtmoko-ics2qtcal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync4ics2openmoko.sh
executable file
·70 lines (58 loc) · 2.04 KB
/
sync4ics2openmoko.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# Interpret command line options
while getopts vu:p:s: option
do case "$option" in
u) user="$OPTARG";;
p) password="$OPTARG";;
v) verbose="-v";;
s) server="$OPTARG";;
[?]) print >&2 "Usage: $0 [-v] [-u user] [-p password] [-s serverurl] fileurl1 fileurl2 ..."
exit 1;;
esac
done
shift `expr $OPTIND - 1`
# Work in tmpdir
mytmp="/tmp/ics2qtcal-`date +%H%M%S`"
mkdir $mytmp
cd $mytmp
icaldb="/home/root/Applications/Qtopia/qtopia_db.sqlite"
tmpnotes="./Annotator-tmp"
notes="/home/root/Applications/Annotator/"
echo "Creating a backup copy of qtopia_db.sqlite"
cp "$icaldb" ./qtopia_db.sqlite.bak
echo "Fetching files"
for fileurl in $*
do
# We force the output to have .ics extension to simplify next for loop
if [ -z "$server" ]; then
wget --no-check-certificate --user="$user" --password="$password" "$fileurl" -O "`basename ${fileurl%%.ics}`_`date +%Y%m%d_%H%M%S`.ics"
else
wget --no-check-certificate --user="$user" --password="$password" ${server}/${fileurl} -O "`basename ${fileurl%%.ics}`_`date +%Y%m%d_%H%M%S`.ics"
fi
done
#echo "Deleting appointments of qtopia_db"
#perl deleteqtcalappointments.pl "$icaldb"
echo "Deleting temporary Notes files from a previous execution"
rm "${tmpnotes}"/*
mkdir -p "${tmpnotes}"
echo "Transferring events to qtopia_db"
for filename in ./*.ics
do
echo "Creating temporary copy of $filename with valid lines into db $caldb"
# Create a copy and remove X-MOZ-LASTACK lines that are not understood by Tie::iCal
# FIXME Check if really needed with latest scripts
grep -v X-MOZ-LASTACK "${filename}" > "${filename}.tmp"
if [ -n "$verbose" ] ; then
ics2qtcal.pl -- -v --ical "${filename}.tmp" --qtopiadb "$icaldb" --notesdirectory "$tmpnotes"
else
ics2qtcal.pl -- --ical "${filename}.tmp" --qtopiadb "$icaldb" --notesdirectory "$tmpnotes"
fi
done;
echo "Removing existing Note files"
rm -f "${notes}"/0-*
echo "Copying Note files"
cp "${tmpnotes}"/* "${notes}"
echo "Removing *.ics local files and *.ics.tmp temporary files"
rm *.ics
rm *.ics.tmp
echo "Done"