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