]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
fix generation dir
[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 # Install creatools as user (no longer as root) // JPR 2/5/2011       
90                #if [ ! -f /etc/bashrc ]
91                #then
92                 #  export ETC_BASHRC="/etc/bash.bashrc"
93                #else
94                 #  export ETC_BASHRC="/etc/bashrc"
95                #fi
96               export ETC_BASHRC=$HOME/.bashrc         
97               echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
98                  
99               grep "installPrefixThird=" $ETC_BASHRC 
100               echo "VTK_DIR  : " $VTK_DIR
101               echo "ITK_DIR  : " $ITK_DIR
102               echo "GDCM_DIR : " $GDCM_DIR
103               echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
104         fi
105         echo    
106         echo "Are these values suitable for you : YES/NO? (default is YES)"
107         read suitable
108         if [ "$suitable" = "" ]
109         then
110            suitable="YES"
111         fi
112      done
113   else
114      suitable="NO"
115   fi
116   
117   if [[ "$suitable" = "YES" || "$suitable" = "Y" || "$suitable" = "yes" || "$suitable" = "y" ]]
118   then
119      source scripts/CreaTools-configure.sh
120   fi
121   
122  if [[ "$suitable" = "NO" || "$suitable" = "N"  || "$suitable" = "no" || "$suitable" = "n" ]]
123  #if [ "$suitable" = "NO" ]
124   then
125      echo
126      echo
127      confirm="NO"
128      while [ "$confirm" != "YES" ]
129      do
130         # ///\TODO what about SuSE? Debian? Mandriva? Gentoo?    
131         OperatingSystem="XXX"
132         while [[ "$OperatingSystem" != "Fedora" && \
133                  "$OperatingSystem" != "Ubuntu" && \
134                  "$OperatingSystem" != "MacOS" ]]
135         do
136            echo "Operating System : Fedora/Ubuntu/MacOS (default : Fedora)"
137            read OperatingSystem
138            if [ "$OperatingSystem" = "" ]
139            then
140              OperatingSystem="Fedora"
141            fi  
142         done
143         echo "you said : [" $OperatingSystem "]"
144         echo
145         echo
146         
147         # ------------------
148         echo "How many cores on your computer 2 (default is 2)"
149         read corenumber
150         if [ "$corenumber" = "" ]
151         then
152            corenumber="2"
153         fi
154         echo "you said : [" $corenumber "]"
155
156         echo
157         echo
158                 
159         racine=$HOME/myDefaultCreatoolsGenerationDir
160         # ------------------
161         echo "Name of the Generation Directory (default is $racine)"
162         read generationdir
163         if [ "$generationdir" = "" ]
164         then
165            
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         while [ "$loginUserName" == "" ]
252         do 
253            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
254            ls -l menu.sh
255            echo "Login User Name (mandatory!)"
256            read loginUserName  
257            echo "you said : [" $loginUserName "]"  
258         done
259         echo
260         echo
261
262         loginGroupName=""
263         while [ "$loginGroupName" == "" ]
264         do
265             #echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
266             #echo "Login Group Name (mandatory!)"
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    
360   # ------------------      
361   # endif 'suitable'
362   fi 
363   ;;
364   
365   1)
366      echo "========================== 1 "
367      source scripts/Check-if-root.sh
368      bash scripts/ThirdParty-install-Base-Stuff.sh     
369      bash scripts/ThirdParty-install-VTK.sh
370      bash scripts/ThirdParty-install-gdcm.sh
371      bash scripts/ThirdParty-install-ITK.sh
372      bash scripts/ThirdParty-install.sh
373      bash scripts/ThirdParty-install-Finalize.sh     
374
375      if [ "$sourcesFrom" = "CVS" ]
376      then
377         echo "----------------------------------------------------------------------"
378         echo OK
379         echo "To go on, run again 'bash menu.sh' as '$loginUserName', in a new window"
380         echo "---------------------------------------------------------------------"
381      else
382         echo "----------------------------------------------------------------------"
383         echo OK
384         echo "To go on, run again 'bash menu.sh'  in a new window"
385         echo "---------------------------------------------------------------------"
386      fi
387      echo
388      echo "==> You HAVE to leave current window to continue!" 
389      read a
390      kill $PPID    
391   ;;
392
393   1.0)
394      echo "========================== 1.0 "
395      source scripts/Check-if-root.sh
396      bash scripts/ThirdParty-install-Base-Stuff.sh     
397      bash scripts/ThirdParty-install-Finalize.sh
398   ;;
399
400   1.1)
401      echo "========================== 1.1 "
402      source scripts/Check-if-root.sh 
403          read a   
404      bash scripts/ThirdParty-install-VTK.sh
405       read a            
406      bash scripts/ThirdParty-install-Finalize.sh      
407      read a       
408   ;;
409
410   1.2)
411      echo "========================== 1.2 "
412      source scripts/Check-if-root.sh
413      bash scripts/ThirdParty-install-gdcm.sh
414      bash scripts/ThirdParty-install-Finalize.sh
415   ;;
416
417   1.3)
418      echo "========================== 1.3 "
419      source scripts/Check-if-root.sh
420      bash scripts/ThirdParty-install-ITK.sh     
421      bash scripts/ThirdParty-install-Finalize.sh         
422      read a
423   ;;
424
425
426   2)
427      #2.1
428      bash scripts/CreaTools-load.sh
429      #2.2
430      source scripts/CreaTools-configure.sh
431      bash scripts/CreaTools-compile.sh
432      #2.3
433      bash scripts/CreaTools-install.sh
434      echo "You HAVE to leave current window to continue!"
435      read a
436      kill $PPID
437   ;;
438
439   2.1)
440      echo "========================== 2.1"
441      bash scripts/CreaTools-load.sh
442   ;;
443
444   2.2)
445      echo "========================== 2.2"
446      source scripts/CreaTools-configure.sh
447      
448      bash scripts/CreaTools-compile.sh
449
450      # To allow (*very* aware) user to patch code, later
451      if [ ! -e $generationdir/creatools_source ]
452      then
453         echo "You probabely made a mistake : "
454             echo "Directory $loginUserName $generationdir/creatools_source not found"
455             echo "Make sure you know the mistake"
456             echo "Hit any key to continue"
457             echo "Fix the mistake!"
458             read a
459      else
460         chown -R $loginUserName  $generationdir/creatools_source
461         chgrp -R $loginGroupName $generationdir/creatools_source
462         # Too much time consuming
463         #chown -R $loginUserName $generationdir/creatools_source 
464         #chgrp -R $loginGroupName $generationdir/creatools_source
465     fi    
466   ;;
467   
468   2.3)
469
470 #      if [ $UID != 0 ]
471 #      then
472 #         echo
473 #         echo "..ERROR.."
474 #         echo "==================================================="
475 #         echo "REMEMBER !"
476 #         echo ""
477 #         echo "YOU NEED TO RUN THIS ONE AS root"
478 #         echo "==================================================="
479 #         echo
480 #         echo
481 #         exit 0
482 #      fi
483
484       echo "========================= 4"
485       
486       bash scripts/CreaTools-install.sh
487    
488 #      if [ $UID != 0 ]
489 #      then
490 #        echo "You HAVE to leave current window to continue!"
491 #      else
492 #        echo "==> Hit any key to close current window"
493 #      fi
494   ;;
495
496
497   5)
498    if [ $expanded = "NO" ]
499    then
500      expanded="YES"
501    else
502      expanded="NO"
503    fi
504   ;;
505    
506   6)
507      echo "========================= 5"
508      bash scripts/CreaTools-uninstall.sh 
509      echo
510      echo "==> Hit any key to go on"
511      read a
512   ;;
513
514   7)
515      clear
516      echo "==================================="
517      more README.txt
518      echo
519      echo "==> Hit any key to go on" 
520      read a
521   ;;
522          
523   8)
524      clear
525      echo "==================================="
526      
527      # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
528      # if user configured without installing third party library,
529      # Last third party library is still in use!  JPR
530
531
532      if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
533      then
534         echo WARNING
535         echo
536         echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
537         grep "installPrefixThird=" /etc/bashrc
538         echo "VTK_DIR  : " $VTK_DIR
539         echo "ITK_DIR  : " $ITK_DIR
540         echo "GDCM_DIR : " $GDCM_DIR
541         echo
542         echo "installPrefixThird ... " $installPrefixThird
543      fi
544              
545      if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
546      then
547         echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
548         echo  ------
549         more $installPrefixThird/share/creatools_third_party_library_config.sh
550         echo  ------
551      fi
552      
553      echo
554      
555      if [ -f $installPrefix/share/creatools_base_library_config.sh ]
556      then
557         echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
558         echo  ------ 
559         more $installPrefix/share/creatools_base_library_config.sh
560         echo  ------ 
561         echo
562         echo "installPrefix ... " $installPrefix
563      fi 
564      echo  ------
565         echo "VTK_DIR  :                 " $VTK_DIR
566         echo "ITK_DIR  :                 " $ITK_DIR
567         echo "GDCM_DIR :                 " $GDCM_DIR
568         echo
569         echo "crea_DIR :                 " $crea_DIR
570         echo "BBTK_DIR :                 " $BBTK_DIR
571         echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
572         echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
573         echo "creaBruker_DIR :           " $creaBruker_DIR
574         echo "creaImageIO_DIR :          " $creaImageIO_DIR
575         echo "creaContours_DIR :         " $creaContours_DIR
576         echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
577         echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
578         echo "creaTools_DIR :            " $creaTools_DIR
579         echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
580         echo "Ido_DIR :                  " $Ido_DIR
581         echo "==================================="
582         echo
583         echo "Press any key to continue"
584         read a
585    ;;
586
587   9) 
588     echo
589     exit 0
590     ;;
591
592   10)
593   # Hiden option, usefull at debug time
594     bash scripts/ThirdParty-install_no_compile.sh  
595     ;;
596       
597   *)
598
599   if [ expanded="NO" ]
600   then
601      echo "Your answer must be in {0, 1, 2, 5, 6, 7, 8, 9} (was [ $i ])"
602   else
603      echo "Your answer must be in {0, 1, 2.1, 2.2, 2.3, 5, 6, 7, 8, 9} (was [ $i ])"
604   fi
605   ;;
606   esac
607
608 done
609