Statistics
| Revision:

root / tmp / org.txm.setups / shared / mac / Applications / TXM.app / Contents / MacOS / TXM @ 1908

History | View | Annotate | Download (5.5 kB)

1
#!/bin/sh
2
# This script launch TXM in the right directory and with the right TXM.ini file
3

    
4
echo "Prepare redirections in $HOME/TXMPostInstallOutputLogs.txt and $HOME/TXMPostInstallErrorLogs.txt files"
5

    
6
LOGFILESMSG=", see $HOME/TXMPostInstallOutputLogs.txt and $HOME/TXMPostInstallErrorLogs.txt output and error messages files."
7
VERSION=0.8.0
8
exec 3>$HOME/TXMPostInstallOutputLogs.txt
9
exec 4>$HOME/TXMPostInstallErrorLogs.txt
10

    
11
echo "$HOME is '$HOME'"
12

    
13
if [ ! -d "$HOME" ]; then
14
	echo "TXM: Impossible to access user home directory ($HOME). Aborting"
15
	exit 1
16
fi
17

    
18
echo "Creating all necessary directories"
19

    
20
TXMHOME="$HOME/TXM-$VERSION"
21
DOTTXMHOME="$HOME/.TXM-$VERSION"
22
echo "TXMHOME='$TXMHOME'"
23
if [ ! -d "$TXMHOME" ]; then
24
	mkdir "$TXMHOME"
25
fi
26
if [ ! -d "$TXMHOME" ]; then
27
	zenity --info --text="TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
28
	echo "TXM: Impossible to access '$DIR' directory. Aborting$LOGFILESMSG"
29
	exit 1
30
fi
31

    
32

    
33
echo "DOTTXMHOME='$DOTTXMHOME'"
34
if [ ! -d "$DOTTXMHOME" ]; then
35
	mkdir "$DOTTXMHOME"
36
fi
37
if [ ! -d "$DOTTXMHOME" ]; then
38
	zenity --info --text="TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
39
	echo "TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
40
	exit 1
41
fi
42
LOGFILES=", see log files $HOME/TXMPostInstallLogs.txt and $HOME/TXMPostInstallErrorLogs.txt."
43

    
44
echo "TXM: looking at the last TXM install date from the /Applications/TXM-TXMVERSION.app/STAMP file"
45

    
46
if [ ! -f "/Applications/TXM-TXMVERSION.app/STAMP" ]; then
47
	echo "TXM: Impossible to access '/Applications/TXM-TXMVERSION.app/STAMP' file. Aborting$LOGFILESMSG"
48
	exit 1
49
fi
50

    
51
STAMP=`stat -t %Y%m%d "/Applications/TXM-TXMVERSION.app/STAMP" | cut -d\  -f11`
52

    
53
if [ $? != 0 ]; then
54
    echo "TXM: Can't find STAMP file /Applications/TXM-TXMVERSION.app/STAMP $LOGFILES"
55
    exit 1 ;
56
fi
57

    
58
echo "TXM: if .txm folder does not contain the STAMP file, its a new install."
59
if [ ! -e "$DOTTXMHOME/$STAMP" ]; then
60

    
61
	echo "New TXM install: it's the first launch after the installation"
62
	if [ -f "/tmp/org.txm.rcpapplication.prefs" ]; then
63
		rm -f "/tmp/org.txm.rcpapplication.prefs" # remove previous preference files if any
64
	fi
65

    
66
	echo "Backing up previous TXM 0.7.6 preferences if any..."
67
	if [ -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" ]; then
68
		echo "Found preference file: $HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs"
69
		cp -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
70
		if [ $? != 0 ]; then
71
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
72
		fi
73
	fi
74

    
75
	echo "Backing up previous TXM 0.7.7 preferences if any..."
76
	if [ -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" ]; then
77
		echo "Found preference file: $HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs"
78
		cp -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
79
		if [ $? != 0 ]; then
80
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
81
		fi
82
	fi
83

    
84
	echo "TXM: Installing up to date TXM directories."
85
	rm -rf "$DOTTXMHOME"
86
	if [ -d "$DOTTXMHOME" ]; then
87
	    echo "TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
88
	    exit 1 ;
89
	fi
90

    
91
    mkdir "$DOTTXMHOME"
92
	mkdir "$DOTTXMHOME/user"
93
	mkdir "$DOTTXMHOME/data"
94

    
95
    if [ ! -d "$DOTTXMHOME" ]; then
96
		echo "TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
97
		exit 1
98
    fi
99
    
100
    echo "TXM: resetting RCP workspace."
101
	rm -rf "$TXMHOME/corpora/.metadata"
102
	if [ -d "$TXMHOME/corpora/.metadata" ]; then
103
	    echo "TXM: Failed to remove $TXMHOME/corpora/.metadata"
104
	    exit 1 ;
105
	fi
106

    
107
    echo "TXM: getting '/Applications/TXM-TXMVERSION.app/TXM.ini' and set write permission of '$DOTTXMHOME/TXM.ini'"
108
    cp "/Applications/TXM-TXMVERSION.app/Contents/TXM/TXM.ini" "$DOTTXMHOME/TXM.ini" &&
109
    chmod +w "$DOTTXMHOME/TXM.ini";
110
    
111
    if [ $? != 0 ]; then
112
       	echo "TXM: Can't launch TXM: failed to copy TXM.ini file$LOGFILESMSG"
113
        exit 1
114
    fi
115

    
116
    echo "TXM: creating the $DOTTXMHOME/$STAMP install STAMP file."
117
    touch "$DOTTXMHOME/$STAMP"
118

    
119
    if [ $? != 0 ]; then
120
		echo "TXM: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
121
        exit 1
122
    fi
123
fi
124

    
125
#) 1>&3 2>&4
126

    
127
# don't exec TXM if problem occurs
128
if [ $? != 0 ]; then
129
    echo "TXM: An error occurred. Aborting$LOGFILESMSG";
130
    exit 1 ;
131
fi
132

    
133
TXMINIARGSVM=""
134
TXMINIARGS=""
135
STARTVMARGS=0
136
while read i ; do 	
137
	if [ $STARTVMARGS == 1 ]; then
138
 		TXMINIARGSVM="$TXMINIARGSVM $i" ;
139
	else
140
		TXMINIARGS="$TXMINIARGS $i" ;
141
	fi
142
	
143
	if [ $i == "-vmargs" ]; then
144
 	   STARTVMARGS=1
145
	fi
146
done < "$DOTTXMHOME/TXM.ini"; 
147

    
148
echo "TXM INI ARGS = $TXMINIARGS"
149
echo "TXM INI VM ARGS = $TXMINIARGSVM"
150

    
151
OSVERSION=`sw_vers -productVersion`
152

    
153
echo "TXM: Running TXM for Mac OS X $OSVERSION with the JAR launcher..."
154
/Applications/TXM-TXMVERSION.app/Contents/TXM/jre/Contents/Home/bin/java -Djava.library.path="$(echo  /Applications/TXM-TXMVERSION.app/Contents/TXM/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_*/eclipse_*.so)" -XX:MaxPermSize=256m -XstartOnFirstThread $TXMINIARGSVM -jar "$(echo /Applications/TXM-TXMVERSION.app/Contents/TXM/plugins/org.eclipse.equinox.launcher_*.jar)" -os macosx -ws cocoa -arch x86_64 -consoleLog -showsplash -run --launcher.ini "$DOTTXMHOME/TXM.ini" -configuration "$DOTTXMHOME/configuration" -user "$DOTTXMHOME/user" -install "/Applications/TXM-TXMVERSION.app/Contents/TXM"