]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
more checking
[creaToolsTools.git] / Linux / menu.sh
1 #!/bin/sh
2
3 if [ $UID != 0 ] 
4 then
5    echo
6    echo "..ERROR.."
7    echo "==================================================="
8    echo "REMEMBER !"
9    echo ""
10    echo "YOU NEED TO RUN THIS ONE AS root"
11    echo "==================================================="
12    echo
13    echo
14    exit 0
15 fi
16
17
18 i=999
19 while [ $i != 9 ]
20 do
21    echo
22    echo
23    echo
24    echo "                MENU"
25    echo
26    echo " Choose what you want to do :"
27    echo  
28    echo " Configure :                        0"
29    echo " Install Third Party Libraries :    1"
30    echo " Get the 'CreaTools' source files : 2"   
31    echo " Compile   the CreaTools :          3"
32    echo " Install   the CreaTools :          4"
33    echo " Uninstall the CreaTools :          5"
34    echo
35    echo " Exit :                             9"
36   echo
37   echo
38   echo 
39
40   echo "Type in your choice :"
41   read i
42
43   case $i in
44   0)
45   suitable=XXX
46   #ls -l  scripts/CreaTools-configure.sh
47   if [ -f scripts/CreaTools-configure.sh ]
48   then
49      while [[ "$suitable" != "YES" && \
50               "$suitable" != "NO" ]]
51      do   
52         echo "'Configure' already done : "
53         echo "------------------------"
54         more scripts/CreaTools-configure.sh
55         echo "------------------------"
56         echo "Are the following values suitable for you : YES/NO? (default is YES)"
57         read suitable
58         if [ "$suitable" = "" ]
59         then
60            suitable="YES"
61         fi
62      done
63   else
64      suitable="NO"
65   fi
66
67   if [ "$suitable" = "NO" ]
68   then
69      echo
70      echo
71      confirm="NO"
72      while [ "$confirm" != "YES" ]
73      do
74         OperatingSystem="XXX"
75         while [[ "$OperatingSystem" != "Fedora" && \
76                  "$OperatingSystem" != "Ubuntu" && \
77                  "$OperatingSystem" != "MacOS" ]]
78         do
79            echo "Operating System : Fedora/Ubuntu/MacOS (mandatory!)"
80            read OperatingSystem
81         done
82         echo "you said : [" $OperatingSystem "]"
83         echo
84         echo
85
86         # ------------------
87         echo "Name of the Generation Directory (default is /tmp/myGenerationDir)"
88         read generationdir
89         if [ "$generationdir" = "" ]
90         then
91            generationdir="/tmp/myGenerationDir"
92         fi
93         echo "you said : [" $generationdir "]"
94
95         echo
96         echo
97         # ------------------
98
99         installPrefix="XXX"
100         echo "Install Prefix : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
101         read installPrefix
102         if [ "$installPrefix" = "" ]
103         then
104            installPrefix="$generationdir/creatools_install"
105         fi
106         echo "you said : [" $installPrefix "]"
107         echo
108         echo 
109         # ------------------
110
111         docgeneration="XXX"
112         while [[ "$docgeneration" != "YES"  && "$docgeneration" != "NO" ]]
113         do
114            echo "Boolean For Doc Generation : YES/NO (default is NO)"
115            read docgeneration
116           if [ "$docgeneration" = "" ]
117           then
118              docgeneration="NO"
119           fi
120           echo "you said : [" $docgeneration "]"
121         done
122         echo
123         echo
124         # ------------------
125
126         sourcesFrom="XXX"
127         while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
128         do
129            echo "Where do you want to get source files from : CVS/HTML (default is HTML)"
130            read sourcesFrom
131            if [ "$sourcesFrom" = "" ]
132            then
133               sourcesFrom="HTML"
134            fi
135            echo "you said : [" $sourcesFrom "]"
136         done
137         echo
138         echo
139         # ------------------
140
141         cvsUserName=""
142         if [ "$sourcesFrom" = "CVS" ]
143         then
144            while [ "$cvsUserName" == "" ]
145            do
146               echo "CVS User Name (mandatory!)"
147               read cvsUserName
148            done
149            echo "you said : [" $cvsUserName "]"
150         else
151            cvsUserName="ForgetThisOne" 
152         fi
153         echo
154         echo
155         # ------------------
156
157         linuxUserName=""
158         while [ "$linuxUserName" == "" ]
159         do 
160            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
161            ls -l menu.sh
162            echo "Login User Name (mandatory!)"
163            read linuxUserName  
164            echo "you said : [" $linuxUserName "]"  
165         done
166         echo
167         echo
168
169         linuxGroupName=""
170         while [ "$linuxGroupName" == "" ]
171         do
172             #echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
173             #echo "Login Group Name (mandatory!)"
174            echo "Login Group Name (mandatory!)"
175            read linuxGroupName  
176            echo "you said : [" $linuxGroupName "]"  
177         done
178         echo
179         echo
180         # ------------------
181
182         buildType="XXX"
183         while [[ "$buildType" != "Release"  && "$Debug " != "HTML" ]]
184         do
185            echo "Build type : Release/Debug (default is Release)"
186            read buildType
187            if [ "$buildType" = "" ]
188            then
189               buildType="Release"
190            fi
191            echo "you said : [" $buildType "]"
192         done
193         echo
194         echo
195         # ------------------
196
197         gdcmVersion="XXX"
198         while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
199         do
200            echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
201            read gdcmVersion
202            if [ "$gdcmVersion" = "" ]
203            then
204               gdcmVersion="GDCM1"
205            fi
206            echo "you said : [" $gdcmVersion "]"
207         done
208         echo
209         echo
210         echo
211         echo
212         echo "You said :"
213         echo "           Operating System                           : $OperatingSystem"
214         echo "           Name of the Generation Directory           : $generationdir"
215         echo "           Install Prefix                             : $installPrefix"
216         echo "           Boolean for Doc Generation                 : $docgeneration"
217         echo "           Where do you want to get source files from : $sourcesFrom"
218         if [ $sourcesFrom = CVS ]
219         then
220            echo "           CVS User Name                              : $cvsUserName"
221         fi
222         echo "           Login User Name                            : $linuxUserName"
223         echo "           Login Group Name                           : $linuxGroupName"
224         echo "           Build type                                 : $buildType"          
225         echo "           Gdcm version                               : $gdcmVersion"
226         echo
227         echo
228         echo "Do you confirm your choices : YES/NO ? (default is NO)"
229         read confirm
230    done
231
232  # GROS SOUCIS : Ou generer le fichier CreaTools-configure.sh?
233  # dans $generationdir/creatools_bin ?
234  # -> il n'est pas encore cree !
235  # dans ./Linux/scripts?
236  # -> ? 
237
238    configureFile="scripts/CreaTools-configure.sh"
239    touch  $configureFile
240    echo "#!/bin/sh"                          >  $configureFile
241    echo                                      >> $configureFile
242    echo "#File generated by 'menu.sh'"       >> $configureFile
243    echo "#DO NOT edit !"                     >> $configureFile
244    echo "#(except if you *know* what you do)">> $configureFile
245    echo                                      >> $configureFile
246    echo "OperatingSystem=$OperatingSystem"   >> $configureFile
247    echo "generationdir=$generationdir"       >> $configureFile
248    echo "installPrefix=$installPrefix"       >> $configureFile
249    echo "docgeneration=$docgeneration"       >> $configureFile
250    echo "sourcesFrom=$sourcesFrom"           >> $configureFile
251    echo "cvsUserName=$cvsUserName"           >> $configureFile 
252    echo "loginUserName=$linuxUserName"       >> $configureFile
253    echo "loginGroupName=$linuxGroupName"     >> $configureFile
254    echo "buildType=$buildType"               >> $configureFile
255    echo "gdcmVersion=$gdcmVersion"           >> $configureFile
256
257   # ------------------      
258   # endif 'suitable'
259   fi 
260   ;;
261   
262   1)
263      echo "========================== 1 "
264      sh scripts/ThirdParty-install.sh
265      
266      vtkdirVariable=""
267      while [ "$vtkdirVariable" = "" ]
268      do
269         echo
270         echo " --------------------------------"
271         echo " Set VTK_DIR environment variable"
272         echo " --------------------------------"
273         echo            
274         read vtkdirVariable
275      done
276      echo "you said [" $vtkdirVariable "]"
277
278      #vtkdirVariable=""
279      #while [ "$vtkdirVariable" = "" ]
280      #do
281      #   echo " Set VTK_DIR environment variable"
282       #  read vtkdirVariable
283      #done
284      #echo "you said [" $vtkdirVariable "]"
285           
286      latexCompilerVariable=""
287      while [ "$latexCompilerVariable" = "" ]
288      do
289         echo
290         echo " ---------------------------------------"
291         echo " Set LATEX_COMPILER environment variable"
292         echo " ---------------------------------------"
293         echo            
294         read latexCompilerVariable
295      done
296      echo "you said [" $latexCompilerVariable "]"     
297
298      sed -i -e '/.*VTK_DIR*/ d'        /etc/bashrc
299      sed -i -e '/.*LATEX_COMPILER*/ d' /etc/bashrc 
300      echo "export VTK_DIR=$vtkdirVariable" >> /etc/bashrc
301      echo "export LATEX_COMPILER=$latexCompilerVariable" >> /etc/bashrc
302      
303      echo "---------------------------------------------------------"
304      echo OK
305      echo "To go on, run again 'sh menu.sh' as root, in a new window"
306      echo "---------------------------------------------------------"
307      exit 0             
308   ;;
309
310   2)
311      echo "========================== 3" 
312      sh scripts/CreaTools-load.sh
313   ;;
314   
315   3)
316      echo "========================== 3"
317      sh scripts/CreaTools-compile.sh
318      
319      # To allow (*very* aware) user to patch code, later
320      chown -R $linuxUserName $generationdir/creatools_source
321      chgrp -R $linuxGroupName $generationdir/creatools_source
322      # Too much time consuming
323      #chown -R $linuxUserName $generationdir/creatools_source 
324      #chgrp -R $linuxGroupName $generationdir/creatools_source     
325   ;;
326   
327   4) 
328      echo "========================= 4"
329      sh scripts/CreaTools-install.sh     
330   ;;
331  
332   5)
333      echo "========================= 5"
334      sh scripts/CreaTools-uninstall.sh
335   ;;
336        
337   9) 
338   echo exit
339   ;;
340    
341   *)
342   echo "Your answer must be in {0, 1, 2, 3, 4, 5, 9} (was $i)"
343   ;;
344   esac
345
346 done
347