]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
Fix mistyping. JPR
[creaToolsTools.git] / Linux / menu.sh
1 #!/bin/bash -e
2
3   if [ -f scripts/CreaTools-configure.sh ]
4   then
5      source scripts/CreaTools-configure.sh
6   fi
7
8 expanded="NO"
9 i=999
10 while [ "$i" != 9 ]
11 do
12    clear
13    echo
14    echo
15    echo
16    echo "                MENU"
17    echo
18    echo " Choose what you want to do :"
19    echo  
20    echo " Configure :........................0"
21
22    if [ $expanded = "YES" ]
23    then 
24       echo " Install all base stuff  :..........1.0"
25       echo "        (cmake, doxygen, graphviz, ...)"
26       echo " Get, Compile, Install vtk   .......1.1"                
27       echo " Get, Compile, Install gdcm :.. .  .1.2" 
28       echo " Get, Compile, Install itk  :.......1.3"
29
30    else
31       echo " Install Third Party Libraries :....1 (as root)"   
32    fi
33      
34    if [ $expanded = "YES" ]
35    then
36    echo " Get the 'CreaTools' source files :.2.1 (CVS : as user!)" 
37    echo " Compile   the CreaTools :..........2.2"
38 # Install creatools as user (no longer as root) // JPR 2/5/2011   
39    echo " Install   the CreaTools :..........2.3"
40    else
41    echo " Get and Install the 'CreaTools':...2"
42    fi
43    echo
44    if [ $expanded = "NO" ]
45    then
46    echo " Use Expanded menu :................5 "
47    else
48    echo " Use compact menu :.................5 "
49    fi
50    echo " Uninstall the CreaTools :..........6 "
51    echo " Help ..............................7 Help about this menu"   
52    echo " Show some Environment Variables ...8"
53    echo " Exit :.............................9"
54    echo
55    echo
56    echo 
57
58   echo "Type in your choice :"
59   read i
60
61   case $i in
62   0)
63   clear
64   suitable=XXX
65   #ls -l  scripts/CreaTools-configure.sh
66   if [ -f scripts/CreaTools-configure.sh ]
67   then
68      while [[ "$suitable" != "YES" && \
69               "$suitable" != "yes" && \
70               "$suitable" != "Y"   && \
71               "$suitable" != "y"   && \
72               "$suitable" != "NO"  && \
73               "$suitable" != "no"  ]]
74      do   
75         echo "'Configure' already done : "
76         echo "------------------------"
77         more scripts/CreaTools-configure.sh
78         echo "------------------------"
79         
80         # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
81         # If user configured without installing third party library,
82         # last third party library is still in use!  JPR
83
84
85         if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
86         then
87               echo WARNING
88               echo
89               if [ -f $HOME/.bashrc ]
90               then
91                  export ETC_BASHRC=$HOME/.bashrc
92               else
93                  if [ -f $HOME/.profile ]
94                  then
95                     export ETC_BASHRC=$HOME/.profile
96                  fi
97               fi                              
98               echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
99                  
100               grep "installPrefixThird=" $ETC_BASHRC 
101               echo "VTK_DIR  : " $VTK_DIR
102               echo "ITK_DIR  : " $ITK_DIR
103               echo "GDCM_DIR : " $GDCM_DIR
104               echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
105         fi
106         echo    
107         echo "Are these values suitable for you : YES/NO? (default is YES)"
108         read suitable
109         if [ "$suitable" = "" ]
110         then
111            suitable="YES"
112         fi
113      done
114   else
115      suitable="NO"
116   fi
117   
118   if [[ "$suitable" = "YES" || "$suitable" = "Y" || "$suitable" = "yes" || "$suitable" = "y" ]]
119   then
120      source scripts/CreaTools-configure.sh
121   fi
122   
123  if [[ "$suitable" = "NO" || "$suitable" = "N"  || "$suitable" = "no" || "$suitable" = "n" ]]
124  #if [ "$suitable" = "NO" ]
125   then
126      echo
127      echo
128      confirm="NO"
129      while [ "$confirm" != "YES" ]
130      do
131         # ///\TODO what about SuSE? Debian? Mandriva? Gentoo?    
132         OperatingSystem="XXX"
133         while [[ "$OperatingSystem" != "Fedora" && \
134                  "$OperatingSystem" != "Ubuntu" && \
135                  "$OperatingSystem" != "MacOS" ]]
136         do
137            echo "Operating System : Fedora/Ubuntu/MacOS (default : Fedora)"
138            read OperatingSystem
139            if [ "$OperatingSystem" = "" ]
140            then
141              OperatingSystem="Fedora"
142            fi  
143         done
144         echo "you said : [" $OperatingSystem "]"
145         echo
146         echo
147         
148         # ------------------
149         echo "How many cores on your computer 2 (default is 2)"
150         read corenumber
151         if [ "$corenumber" = "" ]
152         then
153            corenumber="2"
154         fi
155         echo "you said : [" $corenumber "]"
156
157         echo
158         echo
159                 
160         racine=$HOME/myDefaultCreatoolsGenerationDir
161         # ------------------
162         echo "Name of the Generation Directory (default is $racine)"
163         read generationdir
164         if [ "$generationdir" = "" ]
165         then
166            generationdir=$racine
167         fi
168         echo "you said : [" $generationdir "]"
169
170         echo
171         echo
172         # ------------------
173         installPrefixThird="___"
174         echo "Install Prefix For Third Party Library : '$generationdir/thirdparty_install' / '/usr/local' (default is '$generationdir/thirdparty_install')"
175         read installPrefixThird
176         if [ "$installPrefixThird" = "" ]
177         then
178            installPrefixThird="$generationdir/thirdparty_install"
179         fi
180         echo "you said : [" $installPrefixThird "]"
181         echo
182         echo 
183         # ------------------
184
185         installPrefix="___"
186         echo "Install Prefix for CreaTools : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
187         read installPrefix
188         if [ "$installPrefix" = "" ]
189         then
190            installPrefix="$generationdir/creatools_install"
191         fi
192         echo "you said : [" $installPrefix "]"
193         echo
194         echo 
195         # ------------------
196
197 if [ false ]
198 then
199         docgeneration="___"
200         while [[ "$docgeneration" != "ON"  && "$docgeneration" != "OFF" ]]
201         do
202            echo "Boolean For Doc Generation : ON/OFF (default is OFF)"
203            read docgeneration
204           if [ "$docgeneration" = "" ]
205           then
206              docgeneration="OFF"
207           fi
208           echo "you said : [" $docgeneration "]"
209         done
210         echo
211         echo
212 fi
213
214 docgeneration="OFF"
215
216         # ------------------
217
218         sourcesFrom="___"
219         while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
220         do
221            echo "Where do you want to get source files from : CVS/HTML ( CVS : for registered CREATIS users only! )"
222            read sourcesFrom
223            if [ "$sourcesFrom" = "" ]
224            then
225               sourcesFrom="CVS"
226            fi
227            echo "you said : [" $sourcesFrom "]"
228         done
229         echo
230         echo
231         # ------------------
232
233         cvsUserName=""
234         if [ "$sourcesFrom" = "CVS" ]
235         then
236            while [ "$cvsUserName" == "" ]
237            do
238               echo "CVS User Name ( registered CREATIS user : mandatory!)"
239               read cvsUserName
240            done
241            echo "you said : [" $cvsUserName "]"
242         else
243            cvsUserName="ForgetThisOne" 
244         fi
245         echo
246         echo
247         # ------------------
248
249
250         #loginUserName=""
251         loginUserName=$USER
252         #while [ "$loginUserName" == "" ]
253         #do 
254            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
255            ls -l menu.sh
256          #  echo "Login User Name (mandatory!)"
257          #  read loginUserName  
258          #  echo "you said : [" $loginUserName "]"  
259         #done
260         echo
261         echo
262
263         loginGroupName=""
264         while [ "$loginGroupName" == "" ]
265         do
266            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
267            echo "Login Group Name (mandatory!)"
268            read loginGroupName  
269            echo "you said : [" $loginGroupName "]"  
270         done
271         echo
272         echo
273         # ------------------
274
275         buildType="___"
276         while [[ "$buildType" != "Release"  && "$buildType" != "Debug" ]]
277         do
278            echo "Build type : Release/Debug (default is Release)"
279            read buildType
280            if [ "$buildType" = "" ]
281            then
282               buildType="Release"
283            fi
284            echo "you said : [" $buildType "]"
285         done
286         echo
287         echo
288         # ------------------
289
290         gdcmVersion="___"
291         while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
292         do
293            echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
294            read gdcmVersion
295            if [ "$gdcmVersion" = "" ]
296            then
297               gdcmVersion="GDCM1"
298            fi
299            echo "you said : [" $gdcmVersion "]"
300         done
301         echo
302         echo
303         echo
304         echo
305         echo "You said :"
306         echo "  Operating System                           : $OperatingSystem"
307         echo "  Number of Cores                            : $corenumber"       
308         echo "  Name of the Generation Directory           : $generationdir"
309         echo "  Install Prefix for Third Party Libraries   : $installPrefixThird"       
310         echo "  Install Prefix for CreaTools               : $installPrefix"
311         echo "  Boolean for Doc Generation                 : $docgeneration"
312         echo "  Where do you want to get source files from : $sourcesFrom"
313         if [ $sourcesFrom = CVS ]
314         then
315            echo "  CVS User Name                              : $cvsUserName"
316         fi
317         echo "  Login User Name                            : $loginUserName"
318         echo "  Login Group Name                           : $loginGroupName"
319         echo "  Build type                                 : $buildType"          
320         echo "  Gdcm version                               : $gdcmVersion"
321         echo
322         echo
323      
324         echo "Do you confirm your choices : YES/NO ? (default is YES)"
325         read confirm
326         if [ "$confirm" = "" ]
327         then
328            confirm=YES
329         fi
330    done
331
332  # GROS SOUCIS : Ou generer le fichier CreaTools-configure.sh?
333  # dans $generationdir/creatools_bin ?
334  # -> il n'est pas encore cree !
335  # dans ./Linux/scripts?
336  # ==> On le genere chez l'utilisateur (no choice!)...
337  # 
338
339    configureFile="scripts/CreaTools-configure.sh"
340    touch  $configureFile
341    echo "#!/bin/bash"                            >  $configureFile
342    echo                                          >> $configureFile
343    echo "#File generated by 'menu.sh'"           >> $configureFile
344    echo "#DO NOT edit !"                         >> $configureFile
345    echo "#(except if you *do* know what you do)" >> $configureFile
346    echo                                          >> $configureFile
347    echo "OperatingSystem=$OperatingSystem"       >> $configureFile
348    echo "corenumber=$corenumber"                 >> $configureFile   
349    echo "generationdir=$generationdir"           >> $configureFile
350    echo "installPrefix=$installPrefix"           >> $configureFile
351    echo "installPrefixThird=$installPrefixThird" >> $configureFile
352    echo "docgeneration=$docgeneration"           >> $configureFile
353    echo "sourcesFrom=$sourcesFrom"               >> $configureFile
354    echo "cvsUserName=$cvsUserName"               >> $configureFile 
355    echo "loginUserName=$loginUserName"           >> $configureFile
356    echo "loginGroupName=$loginGroupName"         >> $configureFile
357    echo "buildType=$buildType"                   >> $configureFile
358    echo "gdcmVersion=$gdcmVersion"               >> $configureFile
359    echo "ETC_BASHRC=$ETC_BASHRC"                 >> $configureFile   
360    
361   # ------------------      
362   # endif 'suitable'
363   fi 
364   ;;
365   
366   1)
367      echo "========================== 1 "
368      source scripts/Check-if-root.sh
369      bash scripts/ThirdParty-install-Base-Stuff.sh     
370      bash scripts/ThirdParty-install-VTK.sh
371      bash scripts/ThirdParty-install-gdcm.sh
372      bash scripts/ThirdParty-install-ITK.sh
373      bash scripts/ThirdParty-install.sh
374      bash scripts/ThirdParty-install-Finalize.sh     
375
376      if [ "$sourcesFrom" = "CVS" ]
377      then
378         echo "----------------------------------------------------------------------"
379         echo OK
380         echo "To go on, run again 'bash menu.sh' as '$loginUserName', in a new window"
381         echo "---------------------------------------------------------------------"
382      else
383         echo "----------------------------------------------------------------------"
384         echo OK
385         echo "To go on, run again 'bash menu.sh'  in a new window"
386         echo "---------------------------------------------------------------------"
387      fi
388      echo
389      echo "==>"
390      echo "==> You HAVE to leave current window to continue!" 
391      echo "==>"
392      source $ETC_BASHRC
393      read a
394      kill -9 $PPID 
395   ;;
396
397   1.0)
398      echo "========================== 1.0 "
399      source scripts/Check-if-root.sh
400      bash scripts/ThirdParty-install-Base-Stuff.sh     
401      bash scripts/ThirdParty-install-Finalize.sh
402   ;;
403
404   1.1)
405      echo "========================== 1.1 "
406      #source scripts/Check-if-root.sh 
407      bash scripts/ThirdParty-install-VTK.sh  
408      bash scripts/ThirdParty-install-Finalize.sh      
409      read a       
410   ;;
411
412   1.2)
413      echo "========================== 1.2 "
414      #source scripts/Check-if-root.sh
415      bash scripts/ThirdParty-install-gdcm.sh
416      bash scripts/ThirdParty-install-Finalize.sh
417   ;;
418
419   1.3)
420      echo "========================== 1.3 "
421      #source scripts/Check-if-root.sh
422      bash scripts/ThirdParty-install-ITK.sh     
423      bash scripts/ThirdParty-install-Finalize.sh         
424      read a
425   ;;
426
427
428   2)
429      #2.1
430      bash scripts/CreaTools-load.sh
431      #2.2
432      source scripts/CreaTools-configure.sh
433      bash scripts/CreaTools-compile.sh
434      #2.3
435      bash scripts/CreaTools-install.sh
436      echo "==>"
437      echo "==> You HAVE to leave current window to continue!"
438      echo "==>"
439      source $ETC_BASHRC
440      read a
441      kill -9 $PPID
442   ;;
443
444   2.1)
445      echo "========================== 2.1"
446      bash scripts/CreaTools-load.sh
447   ;;
448
449   2.2)
450      echo "========================== 2.2"
451      source scripts/CreaTools-configure.sh
452      
453      bash scripts/CreaTools-compile.sh
454
455      # To allow (*very* aware) user to patch code, later
456      if [ ! -e $generationdir/creatools_source ]
457      then
458         echo "You probabely made a mistake : "
459             echo "Directory $loginUserName $generationdir/creatools_source not found"
460             echo "Make sure you know the mistake"
461             echo "Hit any key to continue"
462             echo "Fix the mistake!"
463             read a
464      else
465         chown -R $loginUserName  $generationdir/creatools_source
466         chgrp -R $loginGroupName $generationdir/creatools_source
467     fi    
468   ;;
469   
470   2.3)
471
472       echo "========================= 4"
473       
474       bash scripts/CreaTools-install.sh
475    
476 #      if [ $UID != 0 ]
477 #      then
478 #        echo "You HAVE to leave current window to continue!"
479 #      else
480 #        echo "==> Hit any key to close current window"
481 #      fi
482      source $ETC_BASHRC
483   ;;
484
485
486   5)
487    if [ $expanded = "NO" ]
488    then
489      expanded="YES"
490    else
491      expanded="NO"
492    fi
493   ;;
494    
495   6)
496      echo "========================= 5"
497      bash scripts/CreaTools-uninstall.sh 
498      echo
499      echo "==> Hit any key to go on"
500      read a
501   ;;
502
503   7)
504      clear
505      echo "==================================="
506      more README.txt
507      echo
508      echo "==> Hit any key to go on" 
509      read a
510   ;;
511          
512   8)
513      clear
514      echo "==================================="
515      
516      # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
517      # If user configured without installing third party library,
518      # last third party library is still in use!  JPR
519
520
521      if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
522      then
523         echo WARNING
524         echo
525         echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
526         grep "installPrefixThird=" $ETC_BASHRC 
527         echo "VTK_DIR  : " $VTK_DIR
528         echo "ITK_DIR  : " $ITK_DIR
529         echo "GDCM_DIR : " $GDCM_DIR
530         echo
531         echo "installPrefixThird ... " $installPrefixThird
532      fi
533              
534      if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
535      then
536         echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
537         echo  ------
538         more $installPrefixThird/share/creatools_third_party_library_config.sh
539         echo  ------
540      fi
541      
542      echo
543      
544      if [ -f $installPrefix/share/creatools_base_library_config.sh ]
545      then
546         echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
547         echo  ------ 
548         more $installPrefix/share/creatools_base_library_config.sh
549         echo  ------ 
550         echo
551         echo "installPrefix ... " $installPrefix
552      fi 
553      echo  ------
554         echo "VTK_DIR  :                 " $VTK_DIR
555         echo "ITK_DIR  :                 " $ITK_DIR
556         echo "GDCM_DIR :                 " $GDCM_DIR
557         echo
558         echo "crea_DIR :                 " $crea_DIR
559         echo "BBTK_DIR :                 " $BBTK_DIR
560         echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
561         echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
562         echo "creaBruker_DIR :           " $creaBruker_DIR
563         echo "creaImageIO_DIR :          " $creaImageIO_DIR
564         echo "creaContours_DIR :         " $creaContours_DIR
565         echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
566         echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
567         echo "creaTools_DIR :            " $creaTools_DIR
568         echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
569         echo "Ido_DIR :                  " $Ido_DIR
570         echo "==================================="
571         echo
572         echo "Press any key to continue"
573         read a
574    ;;
575
576   9) 
577     echo
578     exit 0
579     ;;
580
581   10)
582   # Hiden option, usefull at debug time
583     bash scripts/ThirdParty-install_no_compile.sh  
584     ;;
585       
586   *)
587
588   if [ expanded="NO" ]
589   then
590      echo "Your answer must be in {0, 1, 2, 5, 6, 7, 8, 9} (was [ $i ])"
591   else
592      echo "Your answer must be in {0, 1, 2.1, 2.2, 2.3, 5, 6, 7, 8, 9} (was [ $i ])"
593   fi
594   ;;
595   esac
596
597 done
598