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