]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
Fix comments
[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
16 else
17  i=999
18 while [ $i != 9 ]
19 do
20
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 " Compile   the CreaTools :       2"
31 echo " Install   the CreaTools :       3"
32 echo " Uninstall the CreaTools :       4"
33 echo
34 echo " Exit :                          9"
35 echo
36 echo
37 echo 
38
39 echo "Type in your choice :"
40 read i
41
42   case $i in
43   0)
44   suitable=XXX
45   ls -l  scripts/CreaTools-configure.sh
46   if [ -f scripts/CreaTools-configure.sh ]
47   then
48      while [[ "$suitable" != "YES" && \
49               "$suitable" != "NO" ]]
50      do   
51         echo "'Configure' already done : "
52         echo "------------------------"
53         more scripts/CreaTools-configure.sh
54         echo "------------------------"
55         echo "Are the following values suitable for you : YES/NO (default is YES)?"
56         read suitable
57         if [ "$suitable" = "" ]
58         then
59            $suitable="YES"
60         fi
61      done
62   else
63      $suitable="NO"
64   fi
65    
66   if [ "$suitable" = "NO" ]
67   then
68 echo
69 echo
70   confirm="NO"
71   while [ "$confirm" != "YES" ]
72   do
73   OperatingSystem="XXX"
74   while [[ "$OperatingSystem" != "Fedora" && \
75            "$OperatingSystem" != "Ubuntu" && \
76            "$OperatingSystem" != "MacOS" ]]
77   do
78   echo "Operating System : Fedora/Ubuntu/MacOS (mandatory!)"
79   read OperatingSystem
80   done
81   echo "you said : [" $OperatingSystem "]"
82 echo
83 echo
84   # ------------------
85   
86   
87   # ------------------
88   echo "Name of the Generation Directory (default is /tmp/myGenerationDir)"
89   read generationdir
90   if [ "$generationdir" = "" ]
91   then
92      generationdir="/tmp/myGenerationDir"
93   fi
94   echo "you said : [" $generationdir "]"su
95   
96 echo
97 echo
98   # ------------------
99
100   installPrefix="XXX"
101      echo "Install Prefix : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
102      read installPrefix
103   if [ "$installPrefix" = "" ]
104   then
105      installPrefix="$generationdir/creatools_install"
106   fi
107   echo "you said : [" $installPrefix "]"
108 echo
109 echo 
110   # ------------------
111
112   docgeneration="XXX"
113   while [[ "$docgeneration" != "YES"  && "$docgeneration" != "NO" ]]
114   do
115   echo "Boolean For Doc Generation : YES/NO (default is NO)"
116   read docgeneration
117   if [ "$docgeneration" = "" ]
118   then
119      docgeneration="NO"
120   fi
121   echo "you said : [" $docgeneration "]"
122   done
123 echo
124 echo
125   # ------------------
126
127   sourcesFrom="XXX"
128   while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
129   do
130   echo "Where do you want to get source files from : CVS/HTML (default is HTML)"
131   read sourcesFrom
132   if [ "$sourcesFrom" = "" ]
133   then
134      sourcesFrom="HTML"
135   fi
136   echo "you said : [" $sourcesFrom "]"
137   done
138 echo
139 echo
140   # ------------------
141   
142   cvsUserName=""
143   if [ "$sourcesFrom" = "CVS" ]
144   then
145   while [ "$cvsUserName" == "" ]
146   do
147      echo "CVS User Name (mandatory!)"
148      read cvsUserName
149   done
150   echo "you said : [" $cvsUserName "]"
151   else
152     cvsUserName="ForgetThisOne" 
153   fi
154 echo
155 echo
156   # ------------------
157
158   linuxUserName=""
159   while [ "$linuxUserName" == "" ]
160   do 
161      echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
162      ls -l .bashrc
163      echo "Login User Name (mandatory!)"
164      read linuxUserName  
165      echo "you said : [" $linuxUserName "]"  
166   done
167 echo
168 echo
169
170   linuxGroupName=""
171   while [ "$linuxGroupName" == "" ]
172   do
173      echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
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 creer 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   # ------------------      
259 # endif 'suitable'
260 fi 
261   ;;
262   
263   1)
264      echo "========================== $i "
265      sh scripts/ThirdParty-install.sh
266      
267      vtkdirVariable=""
268      while [ "$vtkdirVariable" = "" ]
269      do
270         echo " Set VTK_DIR environment variable"
271         read vtkdirVariable
272      done
273      echo "you said [" $vtkdirVariable "]"
274
275      #vtkdirVariable=""
276      #while [ "$vtkdirVariable" = "" ]
277      #do
278      #   echo " Set VTK_DIR environment variable"
279       #  read vtkdirVariable
280      #done
281      #echo "you said [" $vtkdirVariable "]"
282           
283      latexCompilerVariable=""
284      while [ "$latexCompilerVariable" = "" ]
285      do
286         echo " Set LATEX_COMPILER environment variable"
287         read latexCompilerVariable
288      done
289      echo "you said [" $latexCompilerVariable "]"     
290
291      sed -i -e '/.*VTK_DIR*/ d'        /etc/bashrc
292      sed -i -e '/.*LATEX_COMPILER*/ d' /etc/bashrc 
293      echo "export VTK_DIR=$vtkdirVariable" >> /etc/bashrc
294      echo "export LATEX_COMPILER=$latexCompilerVariable" >> /etc/bashrc
295      
296      echo "------------------------------------"
297      echo OK
298      echo "To go on, run again 'sh menu.sh' as root, in a new window"
299      echo "------------------------------------"
300      exit 0             
301   ;;
302   
303   2)
304      echo "========================== $i"
305      sh scripts/CreaTools-compile.sh
306      
307      # To allow (*very* aware) user to patch code, later
308      chown -R $generationdir/creatools_source $linuxUserName
309      chgrp -R $generationdir/creatools_source $linuxGroupName
310      # Too much time consuming
311      #chown -R $generationdir/creatools_source $linuxUserName
312      #chgrp -R $generationdir/creatools_source $linuxGroupName     
313   ;;
314   
315   3) 
316      echo "========================= $i"
317      sh scripts/CreaTools-install.sh     
318   ;;
319  
320   4)
321      echo "========================= $i"
322      sh scripts/CreaTools-uninstall.sh
323   ;;
324        
325   9) 
326   echo exit
327   ;;
328    
329   *)
330   echo "Your answer must be in {0, 1, 2, 3, 4, 9} (was $i)"
331   ;;
332   esac
333
334 done
335 fi