]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
3aeb7f98d6eaf21bf264218122d900e2afa66152
[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 ETC_BASHRC=$HOME/.bashrc ]
90               then
91                  export ETC_BASHRC=$HOME/.bashrc
92               else
93                  if [ -f ETC_BASHRC=$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            
167            generationdir=$racine
168         fi
169         echo "you said : [" $generationdir "]"
170
171         echo
172         echo
173         # ------------------
174         installPrefixThird="___"
175         echo "Install Prefix For Third Party Library : '$generationdir/thirdparty_install' / '/usr/local' (default is '$generationdir/thirdparty_install')"
176         read installPrefixThird
177         if [ "$installPrefixThird" = "" ]
178         then
179            installPrefixThird="$generationdir/thirdparty_install"
180         fi
181         echo "you said : [" $installPrefixThird "]"
182         echo
183         echo 
184         # ------------------
185
186         installPrefix="___"
187         echo "Install Prefix for CreaTools : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
188         read installPrefix
189         if [ "$installPrefix" = "" ]
190         then
191            installPrefix="$generationdir/creatools_install"
192         fi
193         echo "you said : [" $installPrefix "]"
194         echo
195         echo 
196         # ------------------
197
198 if [ false ]
199 then
200         docgeneration="___"
201         while [[ "$docgeneration" != "ON"  && "$docgeneration" != "OFF" ]]
202         do
203            echo "Boolean For Doc Generation : ON/OFF (default is OFF)"
204            read docgeneration
205           if [ "$docgeneration" = "" ]
206           then
207              docgeneration="OFF"
208           fi
209           echo "you said : [" $docgeneration "]"
210         done
211         echo
212         echo
213 fi
214
215 docgeneration="OFF"
216
217         # ------------------
218
219         sourcesFrom="___"
220         while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
221         do
222            echo "Where do you want to get source files from : CVS/HTML ( CVS : for registered CREATIS users only! )"
223            read sourcesFrom
224            if [ "$sourcesFrom" = "" ]
225            then
226               sourcesFrom="CVS"
227            fi
228            echo "you said : [" $sourcesFrom "]"
229         done
230         echo
231         echo
232         # ------------------
233
234         cvsUserName=""
235         if [ "$sourcesFrom" = "CVS" ]
236         then
237            while [ "$cvsUserName" == "" ]
238            do
239               echo "CVS User Name ( registered CREATIS user : mandatory!)"
240               read cvsUserName
241            done
242            echo "you said : [" $cvsUserName "]"
243         else
244            cvsUserName="ForgetThisOne" 
245         fi
246         echo
247         echo
248         # ------------------
249
250
251         #loginUserName=""
252         loginUserName=$USER
253         #while [ "$loginUserName" == "" ]
254         #do 
255            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
256            ls -l menu.sh
257          #  echo "Login User Name (mandatory!)"
258          #  read loginUserName  
259          #  echo "you said : [" $loginUserName "]"  
260         #done
261         echo
262         echo
263
264         loginGroupName=""
265         while [ "$loginGroupName" == "" ]
266         do
267            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
268            echo "Login Group Name (mandatory!)"
269            read loginGroupName  
270            echo "you said : [" $loginGroupName "]"  
271         done
272         echo
273         echo
274         # ------------------
275
276         buildType="___"
277         while [[ "$buildType" != "Release"  && "$buildType" != "Debug" ]]
278         do
279            echo "Build type : Release/Debug (default is Release)"
280            read buildType
281            if [ "$buildType" = "" ]
282            then
283               buildType="Release"
284            fi
285            echo "you said : [" $buildType "]"
286         done
287         echo
288         echo
289         # ------------------
290
291         gdcmVersion="___"
292         while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
293         do
294            echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
295            read gdcmVersion
296            if [ "$gdcmVersion" = "" ]
297            then
298               gdcmVersion="GDCM1"
299            fi
300            echo "you said : [" $gdcmVersion "]"
301         done
302         echo
303         echo
304         echo
305         echo
306         echo "You said :"
307         echo "  Operating System                           : $OperatingSystem"
308         echo "  Number of Cores                            : $corenumber"       
309         echo "  Name of the Generation Directory           : $generationdir"
310         echo "  Install Prefix for Third Party Libraries   : $installPrefixThird"       
311         echo "  Install Prefix for CreaTools               : $installPrefix"
312         echo "  Boolean for Doc Generation                 : $docgeneration"
313         echo "  Where do you want to get source files from : $sourcesFrom"
314         if [ $sourcesFrom = CVS ]
315         then
316            echo "  CVS User Name                              : $cvsUserName"
317         fi
318         echo "  Login User Name                            : $loginUserName"
319         echo "  Login Group Name                           : $loginGroupName"
320         echo "  Build type                                 : $buildType"          
321         echo "  Gdcm version                               : $gdcmVersion"
322         echo
323         echo
324      
325         echo "Do you confirm your choices : YES/NO ? (default is YES)"
326         read confirm
327         if [ "$confirm" = "" ]
328         then
329            confirm=YES
330         fi
331    done
332
333  # GROS SOUCIS : Ou generer le fichier CreaTools-configure.sh?
334  # dans $generationdir/creatools_bin ?
335  # -> il n'est pas encore cree !
336  # dans ./Linux/scripts?
337  # ==> On le genere chez l'utilisateur (no choice!)...
338  # 
339
340    configureFile="scripts/CreaTools-configure.sh"
341    touch  $configureFile
342    echo "#!/bin/bash"                            >  $configureFile
343    echo                                          >> $configureFile
344    echo "#File generated by 'menu.sh'"           >> $configureFile
345    echo "#DO NOT edit !"                         >> $configureFile
346    echo "#(except if you *do* know what you do)" >> $configureFile
347    echo                                          >> $configureFile
348    echo "OperatingSystem=$OperatingSystem"       >> $configureFile
349    echo "corenumber=$corenumber"                 >> $configureFile   
350    echo "generationdir=$generationdir"           >> $configureFile
351    echo "installPrefix=$installPrefix"           >> $configureFile
352    echo "installPrefixThird=$installPrefixThird" >> $configureFile
353    echo "docgeneration=$docgeneration"           >> $configureFile
354    echo "sourcesFrom=$sourcesFrom"               >> $configureFile
355    echo "cvsUserName=$cvsUserName"               >> $configureFile 
356    echo "loginUserName=$loginUserName"           >> $configureFile
357    echo "loginGroupName=$loginGroupName"         >> $configureFile
358    echo "buildType=$buildType"                   >> $configureFile
359    echo "gdcmVersion=$gdcmVersion"               >> $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      read a
393      kill -9 $PPID 
394   ;;
395
396   1.0)
397      echo "========================== 1.0 "
398      source scripts/Check-if-root.sh
399      bash scripts/ThirdParty-install-Base-Stuff.sh     
400      bash scripts/ThirdParty-install-Finalize.sh
401   ;;
402
403   1.1)
404      echo "========================== 1.1 "
405      #source scripts/Check-if-root.sh 
406      bash scripts/ThirdParty-install-VTK.sh  
407      bash scripts/ThirdParty-install-Finalize.sh      
408      read a       
409   ;;
410
411   1.2)
412      echo "========================== 1.2 "
413      #source scripts/Check-if-root.sh
414      bash scripts/ThirdParty-install-gdcm.sh
415      bash scripts/ThirdParty-install-Finalize.sh
416   ;;
417
418   1.3)
419      echo "========================== 1.3 "
420      #source scripts/Check-if-root.sh
421      bash scripts/ThirdParty-install-ITK.sh     
422      bash scripts/ThirdParty-install-Finalize.sh         
423      read a
424   ;;
425
426
427   2)
428      #2.1
429      bash scripts/CreaTools-load.sh
430      #2.2
431      source scripts/CreaTools-configure.sh
432      bash scripts/CreaTools-compile.sh
433      #2.3
434      bash scripts/CreaTools-install.sh
435      echo "==>"
436      echo "==> You HAVE to leave current window to continue!"
437      echo "==>"
438      read a
439      kill -9 $PPID
440   ;;
441
442   2.1)
443      echo "========================== 2.1"
444      bash scripts/CreaTools-load.sh
445   ;;
446
447   2.2)
448      echo "========================== 2.2"
449      source scripts/CreaTools-configure.sh
450      
451      bash scripts/CreaTools-compile.sh
452
453      # To allow (*very* aware) user to patch code, later
454      if [ ! -e $generationdir/creatools_source ]
455      then
456         echo "You probabely made a mistake : "
457             echo "Directory $loginUserName $generationdir/creatools_source not found"
458             echo "Make sure you know the mistake"
459             echo "Hit any key to continue"
460             echo "Fix the mistake!"
461             read a
462      else
463         chown -R $loginUserName  $generationdir/creatools_source
464         chgrp -R $loginGroupName $generationdir/creatools_source
465     fi    
466   ;;
467   
468   2.3)
469
470       echo "========================= 4"
471       
472       bash scripts/CreaTools-install.sh
473    
474 #      if [ $UID != 0 ]
475 #      then
476 #        echo "You HAVE to leave current window to continue!"
477 #      else
478 #        echo "==> Hit any key to close current window"
479 #      fi
480   ;;
481
482
483   5)
484    if [ $expanded = "NO" ]
485    then
486      expanded="YES"
487    else
488      expanded="NO"
489    fi
490   ;;
491    
492   6)
493      echo "========================= 5"
494      bash scripts/CreaTools-uninstall.sh 
495      echo
496      echo "==> Hit any key to go on"
497      read a
498   ;;
499
500   7)
501      clear
502      echo "==================================="
503      more README.txt
504      echo
505      echo "==> Hit any key to go on" 
506      read a
507   ;;
508          
509   8)
510      clear
511      echo "==================================="
512      
513      # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
514      # If user configured without installing third party library,
515      # last third party library is still in use!  JPR
516
517
518      if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
519      then
520         echo WARNING
521         echo
522         echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
523         grep "installPrefixThird=" $ETC_BASHRC 
524         echo "VTK_DIR  : " $VTK_DIR
525         echo "ITK_DIR  : " $ITK_DIR
526         echo "GDCM_DIR : " $GDCM_DIR
527         echo
528         echo "installPrefixThird ... " $installPrefixThird
529      fi
530              
531      if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
532      then
533         echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
534         echo  ------
535         more $installPrefixThird/share/creatools_third_party_library_config.sh
536         echo  ------
537      fi
538      
539      echo
540      
541      if [ -f $installPrefix/share/creatools_base_library_config.sh ]
542      then
543         echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
544         echo  ------ 
545         more $installPrefix/share/creatools_base_library_config.sh
546         echo  ------ 
547         echo
548         echo "installPrefix ... " $installPrefix
549      fi 
550      echo  ------
551         echo "VTK_DIR  :                 " $VTK_DIR
552         echo "ITK_DIR  :                 " $ITK_DIR
553         echo "GDCM_DIR :                 " $GDCM_DIR
554         echo
555         echo "crea_DIR :                 " $crea_DIR
556         echo "BBTK_DIR :                 " $BBTK_DIR
557         echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
558         echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
559         echo "creaBruker_DIR :           " $creaBruker_DIR
560         echo "creaImageIO_DIR :          " $creaImageIO_DIR
561         echo "creaContours_DIR :         " $creaContours_DIR
562         echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
563         echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
564         echo "creaTools_DIR :            " $creaTools_DIR
565         echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
566         echo "Ido_DIR :                  " $Ido_DIR
567         echo "==================================="
568         echo
569         echo "Press any key to continue"
570         read a
571    ;;
572
573   9) 
574     echo
575     exit 0
576     ;;
577
578   10)
579   # Hiden option, usefull at debug time
580     bash scripts/ThirdParty-install_no_compile.sh  
581     ;;
582       
583   *)
584
585   if [ expanded="NO" ]
586   then
587      echo "Your answer must be in {0, 1, 2, 5, 6, 7, 8, 9} (was [ $i ])"
588   else
589      echo "Your answer must be in {0, 1, 2.1, 2.2, 2.3, 5, 6, 7, 8, 9} (was [ $i ])"
590   fi
591   ;;
592   esac
593
594 done
595