Statistics
| Revision:

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

History | View | Annotate | Download (6 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
echo "TXMHOME='$TXMHOME'"
22
if [ ! -d "$TXMHOME" ]; then
23
	mkdir "$TXMHOME"
24
fi
25
if [ ! -d "$TXMHOME" ]; then
26
	zenity --info --text="TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
27
	echo "TXM: Impossible to access '$DIR' directory. Aborting$LOGFILESMSG"
28
	exit 1
29
fi
30

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

    
43
vercomp () {
44
    echo "test $1 $2"
45
    if [[ $1 == $2 ]]
46
    then
47
        return 0
48
    fi
49
    local IFS=.
50
    local i ver1=($1) ver2=($2)
51
    # fill empty fields in ver1 with zeros
52
    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
53
    do
54
        ver1[i]=0
55
    done
56
    for ((i=0; i<${#ver1[@]}; i++))
57
    do
58
        if [[ -z ${ver2[i]} ]]
59
        then
60
            ver2[i]=0
61
        fi
62
        if ((10#${ver1[i]} > 10#${ver2[i]}))
63
        then
64
            return 0
65
        fi
66
        if ((10#${ver1[i]} < 10#${ver2[i]}))
67
        then
68
            return 1
69
        fi
70
    done
71
    return 0
72
}
73

    
74

    
75
echo "TXM: looking at the last TXM install date from the /usr/lib/TXM/STAMP file"
76

    
77
if [ ! -f "/Applications/TXM/STAMP" ]; then
78
	echo "TXM: Impossible to access '/Applications/TXM/STAMP' file. Aborting$LOGFILESMSG"
79
	exit 1
80
fi
81

    
82
STAMP=`stat -t %Y%m%d "/Applications/TXM/STAMP" | cut -d\  -f11`
83

    
84
if [ $? != 0 ]; then
85
    echo "TXM: Can't find STAMP file /Applications/TXM/STAMP $LOGFILES"
86
    exit 1 ;
87
fi
88

    
89
echo "TXM: if .txm folder does not contain the STAMP file, its a new install."
90
if [ ! -e "$TXMHOME/.txm/$STAMP" ]; then
91

    
92
	echo "New TXM install: it's the first launch after the installation"
93
	if [ -f "/tmp/org.txm.rcpapplication.prefs" ]; then
94
		rm -f "/tmp/org.txm.rcpapplication.prefs" # remove previous preference files if any
95
	fi
96

    
97
	echo "Backing up previous TXM 0.7.6 preferences if any..."
98
	if [ -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" ]; then
99
		echo "Found preference file: $HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs"
100
		cp -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
101
		if [ $? != 0 ]; then
102
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
103
		fi
104
	fi
105

    
106
	echo "Backing up previous TXM 0.7.7 preferences if any..."
107
	if [ -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" ]; then
108
		echo "Found preference file: $HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs"
109
		cp -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
110
		if [ $? != 0 ]; then
111
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
112
		fi
113
	fi
114

    
115
	echo "TXM: Installing up to date TXM directories."
116
	rm -rf "$TXMHOME/.txm"
117
	if [ -d "$TXMHOME/.txm" ]; then
118
	    zenity --info --text="TXM: Failed to remove $TXMHOME/.txm directory$LOGFILESMSG"
119
	    echo "TXM: Failed to remove $TXMHOME/.txm directory$LOGFILESMSG"
120
	    exit 1 ;
121
	fi
122

    
123
    mkdir "$TXMHOME/.txm"
124
	mkdir "$TXMHOME/.txm/user"
125
	mkdir "$TXMHOME/.txm/data"
126

    
127
    if [ ! -d "$TXMHOME/.txm" ]; then
128
		echo "TXM: Impossible to access '$TXMHOME/.txm' directory. Aborting$LOGFILESMSG"
129
		exit 1
130
    fi
131

    
132
    echo "TXM: getting '/Applications/TXM/TXM.ini' and set write permission of '$TXMHOME/.txm/TXM.ini'"
133
    cp /Applications/TXM/.main.app/Contents/MacOS/TXM.ini "$TXMHOME/.txm/TXM.ini" &&
134
    chmod +w "$TXMHOME/.txm/TXM.ini";
135
    
136
    if [ $? != 0 ]; then
137
       	echo "TXM: Can't launch TXM: failed to set TXM.ini file$LOGFILESMSG"
138
        exit 1
139
    fi
140

    
141
    echo "TXM: creating the $TXMHOME/.txm/$STAMP install STAMP file."
142
    touch "$TXMHOME/.txm/$STAMP"
143

    
144
    if [ $? != 0 ]; then
145
		echo "TXM: Can't launch TXM: failed to create the $TXMHOME/.txm/$STAMP install STAMP file$LOGFILESMSG"
146
        exit 1
147
    fi
148
fi
149

    
150
#) 1>&3 2>&4
151

    
152
# don't exec TXM if problem occurs
153
if [ $? != 0 ]; then
154
    echo "TXM: An error occurred. Aborting$LOGFILESMSG";
155
    exit 1 ;
156
fi
157

    
158
TXMINIARGSVM=""
159
TXMINIARGS=""
160
STARTVMARGS=0
161
while read i ; do 	
162
	if [ $STARTVMARGS == 1 ]; then
163
 		TXMINIARGSVM="$TXMINIARGSVM $i" ;
164
	else
165
		TXMINIARGS="$TXMINIARGS $i" ;
166
	fi
167
	
168
	if [ $i == "-vmargs" ]; then
169
 	   STARTVMARGS=1
170
	fi
171
done < "$TXMHOME/.txm/TXM.ini"; 
172

    
173
echo "TXM INI ARGS = $TXMINIARGS"
174
echo "TXM INI VM ARGS = $TXMINIARGSVM"
175

    
176
OSVERSION=`sw_vers -productVersion`
177

    
178
vercomp $OSVERSION "10.7"
179

    
180
if [ $? != 0 ];then
181
	echo "TXM: Running TXM for Mac OS X $OSVERSION with the binary launcher..."
182
	open /Applications/TXM/.main.app --args -run --launcher.ini "$TXMHOME/.txm/TXM.ini" -data "$TXMHOME/.txm/data" -user "$TXMHOME/.txm/user" -install "/Applications/TXM" &
183
else
184
	echo "TXM: Running TXM for Mac OS X $OSVERSION with the JAR launcher..."
185
	/Applications/TXM/jre/Contents/Home/bin/java -Djava.library.path="$(echo  /Applications/TXM/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_*/eclipse_*.so)" -XX:MaxPermSize=256m -XstartOnFirstThread $TXMINIARGSVM -jar "$(echo /Applications/TXM/TXM/plugins/org.eclipse.equinox.launcher_*.jar)" -os macosx -ws cocoa -arch x86_64 -showsplash -run -data "$TXMHOME/.txm/data" -user  "$TXMHOME/.txm/user" -install "/Applications/TXM/TXM"
186
fi