summaryrefslogtreecommitdiff
path: root/texmf-dist/scripts/ketcindy/ketcindy.sh
blob: fe8f81552a60ce683293e214ebd5844065a37925 (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
67
68
69
70
71
72
73
74
#!/bin/sh
#
# KETCindy starter script
#
# (C) 2017 Norbert Preining
# Licensed under the same license terms as ketpic itself, that is GPLv3+
#

BinaryName=Cinderella2
TemplateFile=template.cdy

if [ "$1" = "-c" ]
then
  shift
  cinderella="$1"
else
  cinderella=`which $BinaryName 2>/dev/null`
fi

if [ -z "$cinderella" ]
then
  echo "Cannot find $BinaryName!" >&2
  exit 1
fi

if [ ! -x "$cinderella" ] ; then
  echo "Program $cinderella is not executable!" >&2
  exit 1
fi
# find real path
realcind=`realpath "$cinderella"`
cinddir=`dirname "$realcind"`
plugindir="$cinddir/Plugins"
plugin="$plugindir/KetCindyPlugin.jar"

# find Jar
KetCdyJar=`kpsewhich -format=texmfscripts KetCindyPlugin.jar`
# search for template.cdy
TempCdy=`kpsewhich -format=texmfscripts $TemplateFile`

if [ -z "$TempCdy" -o -z "$KetCdyJar" ]
then
  echo "Cannot find $TemplateFile via kpsewhich, is ketpic installed?" >&2
  exit 1
fi


if [ ! -r "$plugin" ] ; then
  echo "Cinderella is *NOT* set up for KETCindy!"
  echo "You need to copy"
  echo "   $KetCdyJar"
  echo "into"
  echo "   $plugindir"
  echo ""
  exit 1
fi

# check whether the .jar md5sum is fine, but don't make this an error
myjarmd=`cat "$KetCdyJar" | md5sum`
sysjarmd=`cat "$plugin" | md5sum`
if [ ! "$myjarmd" = "$sysjarmd" ]
then
  echo "The installed version of the plugin in"
  echo "  $plugin"
  echo "differs from the version shipped in"
  echo "  $KetCdyJar"
  echo "You might need to update the former one with the later one!"
fi


mkdir -p ~/ketcindy

exec "$cinderella" "$TempCdy"