-
Notifications
You must be signed in to change notification settings - Fork 0
/
photovault.sh
executable file
·122 lines (110 loc) · 2.88 KB
/
photovault.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
# Copyright (c) 2006 Harri Kaimio
# Based on Freemind startup script, copyright (c) 2004 Joerg Mueller
#
# This file is part of Photovault.
#
# Photovault is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Photovault is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Photovault; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
_debug() {
if [ -n "${DEBUG}" ]
then
echo "DEBUG: $1" >&2
shift
for text in "$@"
do
echo " ${text}" >&2
done
fi
}
_error() {
echo "ERROR: $1" >&2
shift
for text in "$@"
do
echo " ${text}" >&2
done
}
findjava() {
# We try hard to find the proper 'java' command
if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
then
_debug "Using \$JAVACMD to find java virtual machine."
elif [ -n "${JAVA_BINDIR}" ] && [ -x "${JAVA_BINDIR}/java" ]
then
JAVACMD="${JAVA_BINDIR}/java"
_debug "Using \$JAVA_BINDIR to find java virtual machine."
elif [ -n "${JAVA_HOME}" ] && [ -x "${JAVA_HOME}/bin/java" ]
then
JAVACMD="${JAVA_HOME}/bin/java"
_debug "Using \$JAVA_HOME to find java virtual machine."
else
JAVACMD=$(which java)
if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
then
_debug "Using \$PATH to find java virtual machine."
elif [ -x /usr/bin/java ]
then
_debug "Using /usr/bin/java to find java virtual machine."
JAVACMD=/usr/bin/java
fi
fi
# if we were successful, we return 0 else we complain and return 1
if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
then
_debug "Using '$JAVACMD' as java virtual machine..."
if [ -n "${DEBUG}" ]
then
"$JAVACMD" -version
fi
return 0
else
_error "Couldn't find a java virtual machine," \
"define JAVACMD, JAVA_BINDIR, JAVA_HOME or PATH."
return 1
fi
}
_source() {
if [ -f "$1" ]
then
_debug "Sourcing '$1'."
. "$1"
fi
}
_debug "Photovault parameters are '${@}'."
_debug "$(uname -a)"
findjava
if [ $? -ne 0 ]
then
exit 1
fi
pvpath=$(dirname "$0")
pvpath="${pvpath%/bin}"
for jar in "${PVAULT_BASE_DIR}" \
"${pvpath}" "${pvpath}/share/photovault" "${pvpath}/photovault"
do
if [ -f "${jar}/lib/photovault.jar" ]
then
pvdir="${jar}"
_debug "Photovault Directory is '${jar}'."
break
fi
done
if [ -z "${pvdir}" ]
then
_error "Couldn't find Photovault under '${freepath}'."
exit 1
fi
_debug "Calling: '${JAVACMD} -Xmx384M -jar ${jar}/lib/photovault.jar $@"
"${JAVACMD}" -Xmx384M "-Dpv.basedir=${pvdir}" -jar "${jar}/lib/photovault.jar" "$@"