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