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