-
Notifications
You must be signed in to change notification settings - Fork 300
/
ganttproject
executable file
·77 lines (66 loc) · 2.06 KB
/
ganttproject
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
#!/bin/bash
# Copyright 2014 BarD Software s.r.o
# This script launches GanttProject. It can be symlinked and can be ran from
# any working directory
SCRIPT_FILE="$0"
WORKING_DIR="$(pwd)"
# We want to find the directory where the real script file resides.
# If real file is symlinked (possibly many times) then we need to follow
# symlinks until we reach the real script
# After that we run pwd to get directory path
cd "$(dirname "$SCRIPT_FILE")"
SCRIPT_FILE="$(basename "$SCRIPT_FILE")"
while [ -L "$SCRIPT_FILE" ]; do
SCRIPT_FILE="$(readlink "$SCRIPT_FILE")"
cd "$(dirname "$SCRIPT_FILE")"
SCRIPT_FILE="$(basename "$SCRIPT_FILE")"
done
GP_HOME="$(pwd)"
# Create log directory
GP_LOG_DIR="$HOME/.ganttproject.d"
# Check if log dir is present (or create it)
if [ ! -d $GP_LOG_DIR ]; then
if [ -e $GP_LOG_DIR ]; then
echo "file $GP_LOG_DIR exists and is not a directory" >&2
exit 1
fi
if ! mkdir $GP_LOG_DIR ; then
echo "Could not create $GP_LOG_DIR directory" >&2
exit 1
fi
fi
# Create unique name for log file
LOG_FILE="$GP_LOG_DIR/.ganttproject-"$(date +%Y%m%d%H%M%S)".log"
if [ -e "$LOG_FILE" ] && [ ! -w "$LOG_FILE" ]; then
echo "Log file $LOG_FILE is not writable" >2
exit 1
fi
# Find usable java executable
if [ -z "$JAVA_HOME" ]; then
JAVA_COMMAND=$(which java)
if [ "1" = "$?" ]; then
echo "No executable java found. Please set JAVA_HOME variable" >&2
exit 1
fi
else
JAVA_COMMAND=$JAVA_HOME/bin/java
fi
if [ ! -e "$JAVA_COMMAND" ]; then
echo "$JAVA_COMMAND does not exist" >&2
exit 1
fi
if [ ! -x "$JAVA_COMMAND" ]; then
echo "$JAVA_COMMAND is not executable" >&2
exit 1
fi
cd "$GP_HOME"
CLASSPATH="$CLASSPATH:$GP_HOME/eclipsito.jar:$GP_HOME"
export CLASSPATH
BOOT_CLASS=org.bardsoftware.eclipsito.Boot
ECLIPSITO_ARGS="-plugins-dir plugins -app net.sourceforge.ganttproject.GanttProject"
JAVA_ARGS="-Xmx1024m -Duser.dir=$GP_HOME $BOOT_CLASS $ECLIPSITO_ARGS -log true -log_file $LOG_FILE"
if [ -n "$(echo \"$*\" | sed -n '/\(^\|\s\)-/{p;}')" ]; then
"$JAVA_COMMAND" $JAVA_ARGS "$@"
else
"$JAVA_COMMAND" $JAVA_ARGS "$@" &
fi