Statistiques
| Révision :

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

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

1 728 mdecorde
#!/bin/bash
2 728 mdecorde
TXMINSTALLDIR="/usr/lib/TXM"
3 728 mdecorde
ARCHIVEPATH=`readlink -f "$1"`
4 728 mdecorde
5 728 mdecorde
USEZENITY=true
6 728 mdecorde
# X11 tests
7 728 mdecorde
if [ ${DISPLAY:-foobartxtm} == foobartxm ] ; then
8 728 mdecorde
	echo "use shell" ;
9 728 mdecorde
	USEZENITY=false;
10 728 mdecorde
else
11 728 mdecorde
	echo "try to use display '$DISPLAY'" ;
12 728 mdecorde
	xprop -root >/dev/null &>/dev/null # pour lancer la commande sans afficher de sortie
13 728 mdecorde
	if [ $? != 0 ];then
14 728 mdecorde
		echo "use shell"
15 728 mdecorde
		USEZENITY=false;
16 728 mdecorde
	else
17 728 mdecorde
		echo "use zenity"
18 728 mdecorde
	fi
19 728 mdecorde
fi
20 728 mdecorde
21 728 mdecorde
function question() {
22 728 mdecorde
# $1: message
23 728 mdecorde
# $2: ok message
24 728 mdecorde
# $3: cancel message
25 728 mdecorde
if ( $USEZENITY ) ; then
26 728 mdecorde
	echo "** TXM install : Question: $1"
27 728 mdecorde
	zenity --question --text="$1" --ok-label="$2" --cancel-label="$3";
28 728 mdecorde
	return $?
29 728 mdecorde
else
30 728 mdecorde
	echo "** TXM install : Question: $1"
31 728 mdecorde
	echo "$2 OR $3 = Y OR n ?"
32 728 mdecorde
	read LINE
33 728 mdecorde
	if [ "$LINE" = "Y" ];then
34 728 mdecorde
		return 0;
35 728 mdecorde
	else
36 728 mdecorde
		return 1;
37 728 mdecorde
	fi
38 728 mdecorde
fi
39 728 mdecorde
}
40 728 mdecorde
41 728 mdecorde
function error() {
42 728 mdecorde
# $1: message
43 728 mdecorde
echo "** TXM install : Error: $1";
44 728 mdecorde
if ( $USEZENITY ) ; then
45 728 mdecorde
	zenity --error --text="$1";
46 728 mdecorde
fi
47 728 mdecorde
}
48 728 mdecorde
49 728 mdecorde
echo "use zenity : $USEZENITY"
50 728 mdecorde
51 728 mdecorde
# Test usage
52 728 mdecorde
USAGE="** TXMinstall: usage: install.sh <Install source directory>"
53 728 mdecorde
if [ $# != 1 ]; then
54 728 mdecorde
	echo "$USAGE"
55 728 mdecorde
	exit 1;
56 728 mdecorde
fi
57 728 mdecorde
58 728 mdecorde
# Test if java exists
59 728 mdecorde
java -version
60 728 mdecorde
if [ $? != 0 ]; then
61 728 mdecorde
	echo "** TXM install: Could not find java. Aborting."
62 728 mdecorde
	exit 1;
63 728 mdecorde
fi
64 728 mdecorde
65 728 mdecorde
# Test if TestArchi.jar exists
66 728 mdecorde
if [ ! -f "$ARCHIVEPATH/TestPreInstall.jar" ]; then
67 728 mdecorde
	echo "** TXM install: TestArchi.jar is missing $ARCHIVEPATH/TestPreInstall.jar. Can't continue the installation."
68 728 mdecorde
	exit 1;
69 728 mdecorde
fi
70 728 mdecorde
71 728 mdecorde
# Test is javaversion os and arch match to the setup
72 728 mdecorde
java -jar "$ARCHIVEPATH/TestPreInstall.jar" 1.6.0 i386 Linux
73 728 mdecorde
if [ $? != 0 ]; then
74 728 mdecorde
	echo "** TXM install: It seems that TXM setup is not appropriate for your system. Still continue ?"
75 728 mdecorde
	echo "Type Y to continue and n to stop installation. Y/n ?"
76 728 mdecorde
	read LINE
77 728 mdecorde
	if [ "$LINE" = "n" ];then
78 728 mdecorde
		exit 1
79 728 mdecorde
	fi
80 728 mdecorde
fi
81 728 mdecorde
82 728 mdecorde
# Test if ARCHIVEPATH exists
83 728 mdecorde
if [ ! -d "$ARCHIVEPATH" ]; then
84 728 mdecorde
	echo "** TXM install: archive $ARCHIVEPATH does not exist or is not a directory. Can't continue the installation."
85 728 mdecorde
	exit 1;
86 728 mdecorde
fi
87 728 mdecorde
88 728 mdecorde
89 728 mdecorde
90 728 mdecorde
# License agreement
91 728 mdecorde
question "`cat $TXMINSTALLDIR/license.txt`" "I agree" "Cancel"
92 728 mdecorde
if [ $? != 0 ];then
93 728 mdecorde
	echo "** TXM install: abort"
94 728 mdecorde
	exit 1;
95 728 mdecorde
fi
96 728 mdecorde
97 728 mdecorde
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 728 mdecorde
echo "** TXM install: Continue ? (Y/n)"
99 728 mdecorde
100 728 mdecorde
read LINE
101 728 mdecorde
if [ "$LINE" = "Y" ];then
102 728 mdecorde
	echo ""
103 728 mdecorde
else
104 728 mdecorde
	echo "** TXM install: abort"
105 728 mdecorde
	exit;
106 728 mdecorde
fi
107 728 mdecorde
108 728 mdecorde
# install R & packages
109 728 mdecorde
echo "** TXM install: Install R packages"
110 728 mdecorde
if [ `which R` ];then
111 728 mdecorde
	echo ""
112 728 mdecorde
else
113 728 mdecorde
	aptitude install r-base
114 728 mdecorde
fi
115 728 mdecorde
116 728 mdecorde
sudo R --no-save < "$TXMINSTALLDIR/R/rlibs.R"
117 728 mdecorde
118 728 mdecorde
if [ $? != 0 ]; then
119 728 mdecorde
	error "** TXM install: R packages installation failed. Aborting."
120 728 mdecorde
	exit 1;
121 728 mdecorde
fi
122 728 mdecorde
123 728 mdecorde
echo "** TXM install: Removing $TXMINSTALLDIR..."
124 728 mdecorde
		rm -rf "$TXMINSTALLDIR"
125 728 mdecorde
		if [ $? != 0 ]; then
126 728 mdecorde
			echo "** TXM install: error in 'rm -rf $TXMINSTALLDIR', aborting."
127 728 mdecorde
			exit 1 ;
128 728 mdecorde
		fi
129 728 mdecorde
130 728 mdecorde
# create TXM install dir
131 728 mdecorde
mkdir "$TXMINSTALLDIR"
132 728 mdecorde
if [ $? != 0 ]; then
133 728 mdecorde
	echo "** TXM install: creation of directory TXMINSTALLDIR '$TXMINSTALLDIR' failed. Aborting."
134 728 mdecorde
	exit 1;
135 728 mdecorde
fi
136 728 mdecorde
137 728 mdecorde
# copy archive
138 728 mdecorde
echo "** TXM install: Copy files into TXM install directory"
139 728 mdecorde
cp -rf "$ARCHIVEPATH"/* "$TXMINSTALLDIR"
140 728 mdecorde
if [ $? != 0 ]; then
141 728 mdecorde
	echo "** TXM install: TXMinstallation files copy failed. Aborting."
142 728 mdecorde
	exit 1;
143 728 mdecorde
fi
144 728 mdecorde
145 728 mdecorde
# create launcher
146 728 mdecorde
echo "** TXM install: create the TXM launcher"
147 728 mdecorde
rm -fv "/usr/local/bin/TXM"
148 728 mdecorde
rm -fv "/usr/bin/TXM" && \
149 728 mdecorde
cp "$ARCHIVEPATH/TXMexec" "/usr/bin" && \
150 728 mdecorde
mv "/usr/bin/TXMexec" "/usr/bin/TXM"
151 728 mdecorde
152 728 mdecorde
if [ $? != 0 ]; then
153 728 mdecorde
	echo "** TXM install: Failed to create TXM launcher. Aborting."
154 728 mdecorde
	exit 1;
155 728 mdecorde
fi
156 728 mdecorde
157 728 mdecorde
echo "** TXM install: Create preferences file"
158 728 mdecorde
optExec="cqi_server_path_to_executable"
159 728 mdecorde
pathToCqp="$TXMINSTALLDIR/cwb/bin/cqpserver"
160 728 mdecorde
optInit="cqi_server_path_to_init_file"
161 728 mdecorde
pathToInit="$TXMINSTALLDIR/cwb/cqpserver.init"
162 728 mdecorde
optPathToR="r_path_to_executable"
163 728 mdecorde
pathToR=`which R`
164 728 mdecorde
optPathToTT="TREETAGGER_INSTALL_PATH"
165 728 mdecorde
pathToTT="$TXMINSTALLDIR/treetagger"
166 728 mdecorde
optPathToTTMod="TREETAGGER_MODELS_PATH"
167 728 mdecorde
pathToTTMod="$TXMINSTALLDIR/treetagger/models"
168 728 mdecorde
169 728 mdecorde
# create STAMP
170 728 mdecorde
touch "$TXMINSTALLDIR/STAMP"
171 728 mdecorde
172 728 mdecorde
# set executable files
173 728 mdecorde
chmod +x "$TXMINSTALLDIR/TXM"
174 728 mdecorde
chmod +x "$TXMINSTALLDIR/cwb/bin"/*
175 728 mdecorde
176 728 mdecorde
# set preferences
177 728 mdecorde
PREF_FILE="$TXMINSTALLDIR/install.prefs"
178 728 mdecorde
touch "$PREF_FILE"
179 728 mdecorde
echo $optExec"="$pathToCqp >> "$PREF_FILE"
180 728 mdecorde
echo $optInit"="$pathToInit >> "$PREF_FILE"
181 728 mdecorde
echo $optPathToR"="$pathToR >> "$PREF_FILE"
182 728 mdecorde
echo $optPathToTT"="$pathToTT >> "$PREF_FILE"
183 728 mdecorde
echo $optPathToTTMod"="$pathToTTMod >> "$PREF_FILE"
184 728 mdecorde
# set tools' default options
185 728 mdecorde
echo "ca_show_individuals=true" >> "$PREF_FILE"
186 728 mdecorde
echo "ca_show_variables=false" >> "$PREF_FILE"
187 728 mdecorde
echo "ca_quality_display=.00" >> "$PREF_FILE"
188 728 mdecorde
echo "ca_mass_display=###.00" >> "$PREF_FILE"
189 728 mdecorde
echo "ca_dist_display=#.00" >> "$PREF_FILE"
190 728 mdecorde
echo "ca_contrib_display=###.00" >> "$PREF_FILE"
191 728 mdecorde
echo "ca_cos2_display=.00" >> "$PREF_FILE"
192 728 mdecorde
echo "ca_coord_display=#.00" >> "$PREF_FILE"
193 728 mdecorde
echo "cooc_scoreformat=E00" >> "$PREF_FILE"
194 728 mdecorde
echo "cooc_minfreq=2" >> "$PREF_FILE"
195 728 mdecorde
echo "cooc_mincount=2" >> "$PREF_FILE"
196 728 mdecorde
echo "diag_max_value=20" >> "$PREF_FILE"
197 728 mdecorde
echo "lt_fmin=2" >> "$PREF_FILE"
198 728 mdecorde
echo "r_file_transfert=false" >> "$PREF_FILE"
199 728 mdecorde
200 728 mdecorde
touch "$TXMINSTALLDIR/STAMP"
201 728 mdecorde
202 728 mdecorde
if [ $? != 0 ]; then
203 728 mdecorde
	error "** TXM install: Failed to create install TIMESTAMP file : $TXMINSTALLDIR/STAMP"
204 728 mdecorde
	exit 1;
205 728 mdecorde
fi
206 728 mdecorde
207 728 mdecorde
echo "** TXM install: done, type TXM& in a terminal to launch the application"
208 728 mdecorde
209 728 mdecorde
exit 0