Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/odftops-filter/odftops
blob: cc63c22bb1c44ec0a71a46c2c8e6ffbee9f0c81a (plain)
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
#!/bin/bash
# CUPS filter to process ODT files using abiword



# $6 happens to be the path to file passed as argument 

fn="$6"

#for our subshell convenience

sandbox1="${TMPDIR1:-/tmp}/tempcups.$$"
(umask 077 && mkdir "$sandbox1") || exit 1


# we are creating a dummy folder, which can take different file types.

sandbox="${TMPDIR:-/tmp}/cups-odftops.$$"
(umask 077 && mkdir "$sandbox") || exit 1


#The condition which checks whether our abiword is 2.6.6+ or 2.6.6-

$(abiword --to="$sandbox1/temp123.doc" "$fn")


if [ "$?" -ne 0 ];
then

	#our dummy file

	fn1="$sandbox/temp123.odt"

	cp "$fn" "$fn1"

	# Call abiword quietly, securely 

	abiword --to="ps" "$fn1"

	fn2="`echo "$fn1" | sed -e 's/odt$/ps/' `"

else

	#check if our version doesn't require an intermediate conversion, 
	#if it does, do it

	$(abiword --to="$sandbox1/temp123.ps" "$fn")

	if [ "$?" -ne 0 ];

		then

		abiword --to="$sandbox/temp123.ps" "$sandbox1/temp123.doc"

	else

		fn2="$sandbox1/temp123.ps"
	fi

fi

cat "$fn2"

#remove the sandbox folder, for debugging purposes check by commenting the following line and see what is in the /tmp/ folder
rm -rf $sandbox
rm -rf $sandbox1