Statistiques
| Révision :

root / tmp / org.txm.rcp.feature / linux / install.bash @ 1261

Historique | Voir | Annoter | Télécharger (5,22 ko)

1
#!/bin/bash
2
TXMINSTALLDIR="/usr/lib/TXM"
3
ARCHIVEPATH=`readlink -f "$1"`
4

    
5
USEZENITY=true
6
# X11 tests
7
if [ ${DISPLAY:-foobartxtm} == foobartxm ] ; then 
8
	echo "use shell" ; 
9
	USEZENITY=false;
10
else 
11
	echo "try to use display '$DISPLAY'" ; 
12
	xprop -root >/dev/null &>/dev/null # pour lancer la commande sans afficher de sortie 
13
	if [ $? != 0 ];then
14
		echo "use shell"
15
		USEZENITY=false;
16
	else
17
		echo "use zenity"
18
	fi
19
fi 
20

    
21
function question() {
22
# $1: message
23
# $2: ok message
24
# $3: cancel message
25
if ( $USEZENITY ) ; then
26
	echo "** TXM install : Question: $1"
27
	zenity --question --text="$1" --ok-label="$2" --cancel-label="$3";
28
	return $?
29
else
30
	echo "** TXM install : Question: $1"
31
	echo "$2 OR $3 = Y OR n ?"
32
	read LINE
33
	if [ "$LINE" = "Y" ];then
34
		return 0;
35
	else
36
		return 1;
37
	fi
38
fi
39
} 
40

    
41
function error() {
42
# $1: message
43
echo "** TXM install : Error: $1";
44
if ( $USEZENITY ) ; then
45
	zenity --error --text="$1";
46
fi
47
} 
48

    
49
echo "use zenity : $USEZENITY"
50

    
51
# Test usage
52
USAGE="** TXMinstall: usage: install.sh <Install source directory>"
53
if [ $# != 1 ]; then
54
	echo "$USAGE"
55
	exit 1;
56
fi
57

    
58
# Test if java exists
59
java -version
60
if [ $? != 0 ]; then
61
	echo "** TXM install: Could not find java. Aborting."
62
	exit 1;
63
fi
64

    
65
# Test if TestArchi.jar exists
66
if [ ! -f "$ARCHIVEPATH/TestPreInstall.jar" ]; then
67
	echo "** TXM install: TestArchi.jar is missing $ARCHIVEPATH/TestPreInstall.jar. Can't continue the installation."
68
	exit 1;
69
fi
70

    
71
# Test is javaversion os and arch match to the setup
72
java -jar "$ARCHIVEPATH/TestPreInstall.jar" 1.6.0 i386 Linux
73
if [ $? != 0 ]; then
74
	echo "** TXM install: It seems that TXM setup is not appropriate for your system. Still continue ?"
75
	echo "Type Y to continue and n to stop installation. Y/n ?"
76
	read LINE
77
	if [ "$LINE" = "n" ];then
78
		exit 1
79
	fi
80
fi
81

    
82
# Test if ARCHIVEPATH exists
83
if [ ! -d "$ARCHIVEPATH" ]; then
84
	echo "** TXM install: archive $ARCHIVEPATH does not exist or is not a directory. Can't continue the installation."
85
	exit 1;
86
fi
87

    
88

    
89

    
90
# License agreement
91
question "`cat $TXMINSTALLDIR/license.txt`" "I agree" "Cancel"
92
if [ $? != 0 ];then
93
	echo "** TXM install: abort"
94
	exit 1;
95
fi
96

    
97
echo "** TXM install: This script will now delete and create the 'TXM' directory in the directory ($TXMINSTALLDIR), create a link to the TXM binary and install R if it is not already installed."
98
echo "** TXM install: Continue ? (Y/n)"
99

    
100
read LINE
101
if [ "$LINE" = "Y" ];then
102
	echo ""
103
else
104
	echo "** TXM install: abort"
105
	exit;
106
fi
107

    
108
# install R & packages
109
echo "** TXM install: Install R packages"
110
if [ `which R` ];then 
111
	echo ""
112
else
113
	aptitude install r-base
114
fi 
115

    
116
sudo R --no-save < "$TXMINSTALLDIR/R/rlibs.R"
117

    
118
if [ $? != 0 ]; then
119
	error "** TXM install: R packages installation failed. Aborting."
120
	exit 1;
121
fi
122

    
123
echo "** TXM install: Removing $TXMINSTALLDIR..."
124
		rm -rf "$TXMINSTALLDIR"
125
		if [ $? != 0 ]; then
126
			echo "** TXM install: error in 'rm -rf $TXMINSTALLDIR', aborting."
127
			exit 1 ;
128
		fi
129

    
130
# create TXM install dir
131
mkdir "$TXMINSTALLDIR"
132
if [ $? != 0 ]; then
133
	echo "** TXM install: creation of directory TXMINSTALLDIR '$TXMINSTALLDIR' failed. Aborting."
134
	exit 1;
135
fi
136

    
137
# copy archive
138
echo "** TXM install: Copy files into TXM install directory"
139
cp -rf "$ARCHIVEPATH"/* "$TXMINSTALLDIR"
140
if [ $? != 0 ]; then
141
	echo "** TXM install: TXMinstallation files copy failed. Aborting."
142
	exit 1;
143
fi
144

    
145
# create launcher
146
echo "** TXM install: create the TXM launcher"
147
rm -fv "/usr/local/bin/TXM"
148
rm -fv "/usr/bin/TXM" && \
149
cp "$ARCHIVEPATH/TXMexec" "/usr/bin" && \
150
mv "/usr/bin/TXMexec" "/usr/bin/TXM"
151

    
152
if [ $? != 0 ]; then
153
	echo "** TXM install: Failed to create TXM launcher. Aborting."
154
	exit 1;
155
fi
156

    
157
echo "** TXM install: Create preferences file"
158
optExec="cqi_server_path_to_executable"
159
pathToCqp="$TXMINSTALLDIR/cwb/bin/cqpserver"
160
optInit="cqi_server_path_to_init_file"
161
pathToInit="$TXMINSTALLDIR/cwb/cqpserver.init"
162
optPathToR="r_path_to_executable"
163
pathToR=`which R`
164
optPathToTT="TREETAGGER_INSTALL_PATH"
165
pathToTT="$TXMINSTALLDIR/treetagger"
166
optPathToTTMod="TREETAGGER_MODELS_PATH"
167
pathToTTMod="$TXMINSTALLDIR/treetagger/models"
168

    
169
# create STAMP
170
touch "$TXMINSTALLDIR/STAMP"
171

    
172
# set executable files
173
chmod +x "$TXMINSTALLDIR/TXM"
174
chmod +x "$TXMINSTALLDIR/cwb/bin"/*
175

    
176
# set preferences
177
PREF_FILE="$TXMINSTALLDIR/install.prefs"
178
touch "$PREF_FILE"
179
echo $optExec"="$pathToCqp >> "$PREF_FILE"
180
echo $optInit"="$pathToInit >> "$PREF_FILE"
181
echo $optPathToR"="$pathToR >> "$PREF_FILE"
182
echo $optPathToTT"="$pathToTT >> "$PREF_FILE"
183
echo $optPathToTTMod"="$pathToTTMod >> "$PREF_FILE"
184
# set tools' default options
185
echo "ca_show_individuals=true" >> "$PREF_FILE"
186
echo "ca_show_variables=false" >> "$PREF_FILE"
187
echo "ca_quality_display=.00" >> "$PREF_FILE"
188
echo "ca_mass_display=###.00" >> "$PREF_FILE"
189
echo "ca_dist_display=#.00" >> "$PREF_FILE"
190
echo "ca_contrib_display=###.00" >> "$PREF_FILE"
191
echo "ca_cos2_display=.00" >> "$PREF_FILE"
192
echo "ca_coord_display=#.00" >> "$PREF_FILE"
193
echo "cooc_scoreformat=E00" >> "$PREF_FILE"
194
echo "cooc_minfreq=2" >> "$PREF_FILE"
195
echo "cooc_mincount=2" >> "$PREF_FILE"
196
echo "diag_max_value=20" >> "$PREF_FILE"
197
echo "lt_fmin=2" >> "$PREF_FILE"
198
echo "r_file_transfert=false" >> "$PREF_FILE"
199

    
200
touch "$TXMINSTALLDIR/STAMP"
201

    
202
if [ $? != 0 ]; then
203
	error "** TXM install: Failed to create install TIMESTAMP file : $TXMINSTALLDIR/STAMP"
204
	exit 1;
205
fi
206

    
207
echo "** TXM install: done, type TXM& in a terminal to launch the application"
208

    
209
exit 0