Blame view

install.sh 10.1 KB
e6be5137b   Jean-François Rey   reinitialized pro...
1
2
3
  #!/bin/bash
  
  #-------------------#
665a8dac3   Jean-François Rey   ! follow the whit...
4
  # OTMEDIA LIA       #
e6be5137b   Jean-François Rey   reinitialized pro...
5
  # Install script    #
5a14b8678   Jean-François Rey   update doc
6
  # version : 1.1.0   #
e6be5137b   Jean-François Rey   reinitialized pro...
7
  #-------------------#
5a14b8678   Jean-François Rey   update doc
8
  # nyx login name
05a45b590   Jean-François Rey   update install sc...
9
  username=${LOGNAME}
e6be5137b   Jean-François Rey   reinitialized pro...
10
  # Color variables
c00c2f189   Jean-François Rey   up
11
  txtred=$(tput setaf 1) # red
e6be5137b   Jean-François Rey   reinitialized pro...
12
13
14
  txtgrn=$(tput setaf 2) # Green
  txtylw=$(tput setaf 3) # Yellow
  txtblu=$(tput setaf 4) # Blue
c00c2f189   Jean-François Rey   up
15
  txtred=$(tput setaf 5) # Purple
e6be5137b   Jean-François Rey   reinitialized pro...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  txtcyn=$(tput setaf 6) # Cyan
  txtwht=$(tput setaf 7) # White
  txtrst=$(tput sgr0) # Text reset.
  #/color
  
  #
  ### Global Variables
  #
  PWD=$(pwd)
  OTMEDIA_HOME=$PWD
  test=$(arch)
  if [ "$test" == "x86_64" ]; then ARCH=".64"; else ARCH=""; fi
  #/Global
  
  
  #
  # Put to 0 to disable dependencies of a pass
  # and 1 to enable
  #
  PASS1=1     # First Pass 
665a8dac3   Jean-François Rey   ! follow the whit...
36
  PASS2=1     # Second and Third Pass
e6be5137b   Jean-François Rey   reinitialized pro...
37
38
  CONFPASS=1  # Confidence Pass
  EXPLOITCONFPASS=1   # SOLR query and trigg
f34231730   Jean-François Rey   add lia_ne + crf+...
39
  SCORING=1       # Compile scoring tools (crf++)
e6be5137b   Jean-François Rey   reinitialized pro...
40
41
42
43
44
45
46
  
  echo -e "
  Will do install for :"
  if [ $PASS1 -eq 1 ];then echo "- Pass 1";fi
  if [ $PASS2 -eq 1 ];then echo "- Pass 2";fi
  if [ $CONFPASS -eq 1 ];then echo "- Confidence Pass";fi
  if [ $EXPLOITCONFPASS -eq 1 ];then echo "- Exploit Confidence Pass";fi
f34231730   Jean-François Rey   add lia_ne + crf+...
47
  if [ $SCORING -eq 1 ];then echo "- Scoring Tools";fi
e6be5137b   Jean-François Rey   reinitialized pro...
48
49
50
51
52
53
54
55
56
57
58
59
  
  #
  ### CHECK Dependencies ###
  #
  echo -e "
  \t${txtblu}Check Dependencies${txtrst}
  "
  
  ## make
  test=$(whereis make)
  if [ "$test" == "make:" ]
  then
c00c2f189   Jean-François Rey   up
60
61
62
      echo -e "${txtred}ERROR${txtrst} make not found
   You have to install make
   sudo apt-get install make"
e6be5137b   Jean-François Rey   reinitialized pro...
63
64
65
66
67
68
69
70
      exit 1;
  fi
  echo -e "make \t ${txtgrn}OK${txtrst}"
  
  ## CC
  test=$(whereis cc)
  if [ "$test" == "cc:" ]
  then
c00c2f189   Jean-François Rey   up
71
72
73
      echo -e "${txtred}ERROR${txtrst} cc not found
   You have to install cc
   sudo apt-get install gcc"
e6be5137b   Jean-François Rey   reinitialized pro...
74
75
76
      exit 1;
  fi
  echo -e "cc \t ${txtgrn}OK${txtrst}"
160656fdf   Jean-François Rey   update
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  
  ## C++
  if [ $SCORING -eq 1 ]
  then
      test=$(whereis g++)
      if [ "$test" == "g++:" ]
      then
          echo -e "${txtred}ERROR${txtrst} g++ not found
   You have to install g++
   sudo apt-get install g++"
          exit 1;
      fi
      echo -e "g++ \t ${txtgrn}OK${txtrst}"
  fi
e6be5137b   Jean-François Rey   reinitialized pro...
91
92
93
94
  ## AVCONV
  test=$(whereis avconv)
  if [ "$test" == "avconv:" ]
  then
c00c2f189   Jean-François Rey   up
95
96
97
      echo -e "${txtred}ERROR${txtrst} avconv not found
   You have to install avconv
   sudo apt-get install libav-tools"
e6be5137b   Jean-François Rey   reinitialized pro...
98
99
100
101
102
103
104
105
      exit 1;
  fi
  echo -e "libav-tools : avconv \t ${txtgrn}OK${txtrst}"
  
  ## JAVA
  test=$(whereis java)
  if [ "$test" == "java:" ]
  then
c00c2f189   Jean-François Rey   up
106
107
108
      echo -e "${txtred}ERROR${txtrst} java not found
   You have to install java JRE
   sudo apt-get install openjdk-7-jre"
e6be5137b   Jean-François Rey   reinitialized pro...
109
110
111
112
113
114
      exit 1;
  fi
  echo -e "Java : JRE \t ${txtgrn}OK${txtrst}"
  test=$(whereis javac)
  if [ "$test" == "javac:" ]
  then
c00c2f189   Jean-François Rey   up
115
116
117
      echo -e "${txtred}ERROR${txtrst} javac not found
   You have to install java JDK
   sudo apt-get install openjdk-7-jdk"
e6be5137b   Jean-François Rey   reinitialized pro...
118
119
120
121
122
123
124
125
126
127
      exit 1;
  fi
  echo -e "Java : JDK \t ${txtgrn}OK${txtrst}"
  
  if [ $EXPLOITCONFPASS -eq 1 ]
  then
      ## Python
      test=$(whereis python)
      if [ "$test" == "python:" ]
      then
c00c2f189   Jean-François Rey   up
128
129
130
          echo -e "${txtred}ERROR${txtrst} python not found
   You have to install python
   sudo apt-get install python"
e6be5137b   Jean-François Rey   reinitialized pro...
131
132
133
          exit 1;
      fi
      echo -e "python : \t ${txtgrn}OK${txtrst}"
665a8dac3   Jean-François Rey   ! follow the whit...
134
135
136
137
138
      
      ## csh shell
      test=$(whereis csh)
      if [ "$test" == "csh:" ]
      then
c00c2f189   Jean-François Rey   up
139
140
141
          echo -e "${txtred}ERROR${txtrst} csh shell not found
   You have to install csh shell
   sudo apt-get install csh"
665a8dac3   Jean-François Rey   ! follow the whit...
142
143
144
          exit 1;
      fi
      echo -e "csh shell : \t ${txtgrn}OK${txtrst}"
e6be5137b   Jean-François Rey   reinitialized pro...
145
146
147
148
149
150
  fi
  
  ## Perl
  test=$(whereis perl)
  if [ "$test" == "perl:" ]
  then
c00c2f189   Jean-François Rey   up
151
152
153
      echo -e "${txtred}ERROR${txtrst} perl not found
   You have to install perl
   sudo apt-get install perl"
e6be5137b   Jean-François Rey   reinitialized pro...
154
155
156
157
158
159
160
161
      exit 1;
  fi
  echo -e "perl : \t ${txtgrn}OK${txtrst}"
  
  ## iconv
  test=$(whereis iconv)
  if [ "$test" == "iconv:" ]
  then
c00c2f189   Jean-François Rey   up
162
163
164
      echo -e "${txtred}ERROR${txtrst} iconv not found
   You have to install iconv
   sudo apt-cache search iconv"
e6be5137b   Jean-François Rey   reinitialized pro...
165
166
167
      exit 1;
  fi
  echo -e "iconv : \t ${txtgrn}OK${txtrst}"
e6be5137b   Jean-François Rey   reinitialized pro...
168
  ## SRI LM
95a4fc5ec   Jean-François Rey   up
169
  if [ -z "$SRILM" ] || [ -z "$MACHINE_TYPE" ]
e6be5137b   Jean-François Rey   reinitialized pro...
170
  then
c00c2f189   Jean-François Rey   up
171
172
173
      echo -e "${txtred}ERROR${txtrst} SRILM toolkit variables are not defined (SRILM and MACHINE_TYPE)
   You have to install SRILM Toolkit
  "
e6be5137b   Jean-François Rey   reinitialized pro...
174
175
176
177
      exit 1;
  fi
  export SRILM_BIN=$SRILM/bin/$MACHINE_TYPE
  echo -e "SRILM toolkit : \t ${txtgrn}OK${txtrst}"
e6be5137b   Jean-François Rey   reinitialized pro...
178
  ### Speeral Configuration ### 
d93dab09a   Jean-François Rey   update
179

b3f8a55c6   Jean-François Rey   :D
180
181
182
  echo -e "
  \t${txtblu}Speeral configuration${txtrst}
  "
5a14b8678   Jean-François Rey   update doc
183
184
185
186
187
188
  read -e -p "Download Speeral bin and data ? (y/n) " speeral
  if [ "$speeral" == "y" ]
  then
      echo -e "Download Speeral bin and data :"
      scp -r ${username}@nyx:/local/OTMEDIA/OTMEDIA_DATA/Speeral $OTMEDIA_HOME/tools/
  fi
d93dab09a   Jean-François Rey   update
189
190
191
  echo -e "
  \t${txtblu}Generating Speeral configuration files :${txtrst}
  "
e6be5137b   Jean-François Rey   reinitialized pro...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  cat $PWD/tools/Speeral/CFG/SpeeralFirstPass.xml.tmp | sed -e "s|<nom>[^<]*</nom>|<nom>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer</nom>|g" \
      | sed -e "s|<ngramme>[^<]*</ngramme>|<ngramme>$PWD/tools/Speeral/LM/ML_4gOTMEDIA_LEXIQUE_V6</ngramme>|g" \
      | sed -e "s|<binode>[^<]*</binode>|<binode>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer.bin</binode>|g" \
      > $PWD/tools/Speeral/CFG/SpeeralFirstPass.xml
  echo $PWD/tools/Speeral/CFG/SpeeralFirstPass.xml
  cat $PWD/tools/Speeral/CFG/SpeeralSecondPass.xml.tmp | sed -e "s|<nom>[^<]*</nom>|<nom>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer</nom>|g" \
      | sed -e "s|<ngramme>[^<]*</ngramme>|<ngramme>$PWD/tools/Speeral/LM/ML_4gOTMEDIA_LEXIQUE_V6</ngramme>|g" \
      | sed -e "s|<binode>[^<]*</binode>|<binode>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer.bin</binode>|g" \
      > $PWD/tools/Speeral/CFG/SpeeralSecondPass.xml
  echo $PWD/tools/Speeral/CFG/SpeeralSecondPass.xml
  cat $PWD/tools/Speeral/CFG/SpeeralThirdPass.xml.tmp | sed -e "s|<nom>[^<]*</nom>|<nom>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer</nom>|g" \
      | sed -e "s|<ngramme>[^<]*</ngramme>|<ngramme>$PWD/tools/Speeral/LM/ML_4gOTMEDIA_LEXIQUE_V6</ngramme>|g" \
      | sed -e "s|<binode>[^<]*</binode>|<binode>$PWD/tools/Speeral/LEX/LEXIQUE_V6.speer.bin</binode>|g" \
      > $PWD/tools/Speeral/CFG/SpeeralThirdPass.xml
  echo $PWD/tools/Speeral/CFG/SpeeralThirdPass.xml
  
  
  if [ $EXPLOITCONFPASS -eq 1 ]
  then
      ### LIA ltbox ###
      echo -e "\t${txtblu}Install lia_ltbox${txtrst}
  "
      export LIA_TAGG_LANG="french"
      export LIA_TAGG="$OTMEDIA_HOME/tools/lia_ltbox/lia_tagg/"
      export LIA_PHON_REP="$OTMEDIA_HOME/tools/lia_ltbox/lia_phon/"
      export LIA_BIGLEX="$OTMEDIA_HOME/tools/lia_ltbox/lia_biglex/"
  
      ### config lia_phon
      cd $LIA_PHON_REP
      make all > /dev/null
      make ressource > /dev/null
      ### config lia_tagg
      cd $LIA_TAGG
      make all > /dev/null
      make ressource.french > /dev/null
      ### config lia_biglex
      cd $LIA_BIGLEX
      make -f makefile.biglex > /dev/null
      cd $OTMEDIA_HOME
f34231730   Jean-François Rey   add lia_ne + crf+...
231
232
      if [ $SCORING -eq 1 ] 
      then 
160656fdf   Jean-François Rey   update
233
234
235
          echo -e "\t${txtblu}Install CRF++${txtrst}
  "
          tar -xvzf "$OTMEDIA_HOME/tools/CRF++-0.58.tar.gz" -C "$OTMEDIA_HOME/tools/"
f34231730   Jean-François Rey   add lia_ne + crf+...
236
237
238
239
          cd $OTMEDIA_HOME/tools/CRF++-0.58
          ./configure --prefix="$OTMEDIA_HOME/tools/install"
          make
          make install
160656fdf   Jean-François Rey   update
240
241
          echo -e "\t${txtblu}Install lia_ne${txtrst}
  "
f34231730   Jean-François Rey   add lia_ne + crf+...
242
243
244
245
          export PATH=$PATH:$OTMEDIA_HOME/tools/install/bin
          export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTMEDIA_HOME/tools/install/lib
          export LIA_NE=$OTMEDIA_HOME/tools/lia_ltbox/lia_ne_v2.2
          cd $LIA_NE
160656fdf   Jean-François Rey   update
246
          mkdir $LIA_NE/bin 2> /dev/null
f34231730   Jean-François Rey   add lia_ne + crf+...
247
          make all
160656fdf   Jean-François Rey   update
248
          cd $OTMEDIA_HOME
f34231730   Jean-François Rey   add lia_ne + crf+...
249
      fi
e6be5137b   Jean-François Rey   reinitialized pro...
250
251
252
253
254
255
  
      ### SOLR DB ###
      # Tomcat fisrtly
      test=$(dpkg -l | grep "^ii" | grep tomcat)
      if [ "$test" == "" ]
      then
c00c2f189   Jean-François Rey   up
256
257
258
          echo -e "${txtred}ERROR${txtrst} TOMCAT seems to not be installed)
   You have to install TOMCAT
  "
665a8dac3   Jean-François Rey   ! follow the whit...
259
          #exit 1;
83f00bae1   Jean-François Rey   update
260
261
262
263
264
265
266
          echo -e "
  TOMCAT : \t ${txtred}NOT OK${txtrst}
  "
      else
          echo -e "
  TOMCAT : \t ${txtgrn}OK${txtrst}
  "
e6be5137b   Jean-François Rey   reinitialized pro...
267
      fi
e6be5137b   Jean-François Rey   reinitialized pro...
268
      # SOLR secondly
4a412bdf3   Jean-François Rey   update
269
270
      echo -e "\t${txtblu}Install SOLR DB${txtrst}
  "
1e7751e7c   Jean-François Rey   :D :D
271
      echo -e "You will need 300 Go of free space to install SOLR DB"
4a412bdf3   Jean-François Rey   update
272
      read -p "Continue ? (y/n) " solr
b50ebdf38   Jean-François Rey   update install.sh
273
274
275
276
277
      if [ "$solr" == "y" ]
      then
  
          echo -e "Download SOLR DB\r"
          mkdir -p $OTMEDIA_HOME/tools/SOLR 2> /dev/null
5a14b8678   Jean-François Rey   update doc
278
          scp -r ${username}@nyx:/local/OTMEDIA/OTMEDIA_DATA/SOLR/otmedia-2013-04.tar.gz $OTMEDIA_HOME/tools/SOLR
b50ebdf38   Jean-François Rey   update install.sh
279
          echo -e "Unzip SOLR DB\r"
f34231730   Jean-François Rey   add lia_ne + crf+...
280
          tar -xvzf "$OTMEDIA_HOME/tools/SOLR/otmedia-2013-04.tar.gz" -C "$OTMEDIA_HOME/tools/SOLR/"
d93dab09a   Jean-François Rey   update
281
282
283
284
285
      else
          echo "Skipping SOLR install"
      fi
      read -e -p "Configure SOLR DB server ? (y/n) " solr
      if [ "$solr" == "y" ]
b3f8a55c6   Jean-François Rey   :D
286
      then
b50ebdf38   Jean-François Rey   update install.sh
287
          read -p "Enter SOLR server IP :" ip
1e7751e7c   Jean-François Rey   :D :D
288
          if [ "${ip}" == "" ];then ip="localhost";fi
4a412bdf3   Jean-François Rey   update
289
          echo "machine = \"${ip}\"" > $OTMEDIA_HOME/tools/scripts/solrinfo.py
b50ebdf38   Jean-François Rey   update install.sh
290
          read -p "Enter SOLR server port :" port
d93dab09a   Jean-François Rey   update
291
292
293
294
          if [ "${port}" == "" ]; then port="8080";fi
          echo -e "
  \tSOLR server IP ${ip}"
          echo -e "\tSOLR server port ${port}"
4a412bdf3   Jean-François Rey   update
295
          echo "port = \"${port}\"" >> $OTMEDIA_HOME/tools/scripts/solrinfo.py
b50ebdf38   Jean-François Rey   update install.sh
296
      else
d93dab09a   Jean-François Rey   update
297
          echo "Skipping SOLR DB Configuration"
b50ebdf38   Jean-François Rey   update install.sh
298
      fi
4a412bdf3   Jean-François Rey   update
299
300
301
      echo -e "
  See SOLR.INSTALL file for more information
  "
e6be5137b   Jean-François Rey   reinitialized pro...
302
303
304
  fi
  
  ### Set Variables in bashrc ###
743f627a8   Jean-François Rey   up
305
  cat ~/.bashrc | grep -v "OTMEDIA_HOME" | grep -v "SRILM_BIN" | grep -v "main_tools" > ~/.bashrc.org
e6be5137b   Jean-François Rey   reinitialized pro...
306
307
308
309
  #cat ~/.bashrc | grep -v "OTMEDIA_HOME" | grep -v "SRILM_BIN" | grep -v "LIA_TAGG" | grep -v "LIA_PHON" | grep -v "LIA_BIGLEX" > ~/.bashrc.org
  cp ~/.bashrc.org ~/.bashrc
  export OTMEDIA_HOME=$PWD
  echo "export OTMEDIA_HOME=$PWD" >> ~/.bashrc
0ca3a2cb5   Jean-François Rey   up
310
  echo "export PATH=\$PATH:$PWD/main_tools" >> ~/.bashrc
e6be5137b   Jean-François Rey   reinitialized pro...
311
312
313
314
315
  echo "export SRILM_BIN=$SRILM/bin/$MACHINE_TYPE" >> ~/.bashrc
  #echo "export LIA_TAGG_LANG=french" >> ~/.bashrc
  #echo "export LIA_TAGG=$OTMEDIA_HOME/tools/lia_ltbox/lia_tagg/" >> ~/.bashrc
  #echo "export LIA_PHON_REP=$OTMEDIA_HOME/tools/lia_ltbox/lia_phon/" >> ~/.bashrc
  #echo "export LIA_BIGLEX=$OTMEDIA_HOME/tools/lia_ltbox/lia_biglex/" >> ~/.bashrc
06520e7fc   Jean-François Rey   update
316
  #echo "export LIA_NE=$OTMEDIA_HOME/tools/lia_ltbox/lia_ne_v2.2" >> ~/.bashrc
e6be5137b   Jean-François Rey   reinitialized pro...
317
318
  
  # set global configuration file 
fa8235ed8   Jean-François Rey   update
319
320
  echo "OTMEDIA_HOME=\"$PWD\"" > $OTMEDIA_HOME/cfg/main_cfg.cfg
  echo "ARCH=\"$ARCH\"" >> $OTMEDIA_HOME/cfg/main_cfg.cfg
e6be5137b   Jean-François Rey   reinitialized pro...
321
322
323
324
  echo "VERBOSE=0" >> $OTMEDIA_HOME/cfg/main_cfg.cfg
  echo "DEBUG=0" >> $OTMEDIA_HOME/cfg/main_cfg.cfg
  echo "CHECK=0" >> $OTMEDIA_HOME/cfg/main_cfg.cfg
  echo "RERUN=0" >> $OTMEDIA_HOME/cfg/main_cfg.cfg
4a412bdf3   Jean-François Rey   update
325
326
327
  echo -e "
  \t${txtgrn}### Install completed ###${txtrst}
  "
e6be5137b   Jean-François Rey   reinitialized pro...
328
329
330
331
  echo -e "do : source ~/.bashrc"
  echo -e "or set variable :
  "
  echo "export OTMEDIA_HOME=$PWD"
05a45b590   Jean-François Rey   update install sc...
332
  echo "export PATH=\$PATH:$OTMEDIA_HOME/main_tools"
e6be5137b   Jean-François Rey   reinitialized pro...
333
  echo "export SRILM_BIN=$SRILM/bin/$MACHINE_TYPE"
665a8dac3   Jean-François Rey   ! follow the whit...
334

5a14b8678   Jean-François Rey   update doc
335
  echo "${txtwht}             \\\\ "
665a8dac3   Jean-François Rey   ! follow the whit...
336
337
  echo "        ,-~~~-\\\\_"
  echo "       (        .\ "
5a14b8678   Jean-François Rey   update doc
338
  echo "       @\___(__--'${txtrst}"
665a8dac3   Jean-François Rey   ! follow the whit...
339

c00c2f189   Jean-François Rey   up
340
  echo "${txtgrn}Yes${txtylw}I${txtred}Rastafari${txtrst}"