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