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