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