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