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