]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
5918a29ffad2695bd9ecf43c9bbe7d4dd90791c2
[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 echo
45 echo
46   confirm="NO"
47   while [ "$confirm" != "YES" ]
48   do
49   OperatingSystem="XXX"
50   while [[ "$OperatingSystem" != "Fedora" && \
51            "$OperatingSystem" != "Ubuntu" && \
52            "$OperatingSystem" != "MacOS" ]]
53   do
54   echo "Operating System : Fedora/Ubuntu/MacOS (mandatory!)"
55   read OperatingSystem
56   done
57   echo "you said : [" $OperatingSystem "]"
58 echo
59 echo
60   # ------------------
61   
62   
63   # ------------------
64   echo "Name of the Generation Directory (default is /tmp/myGenerationDir)"
65   read generationdir
66   if [ "$generationdir" = "" ]
67   then
68      generationdir="/tmp/myGenerationDir"
69   fi
70   echo "you said : [" $generationdir "]"su
71   
72 echo
73 echo
74   # ------------------
75
76   installPrefix="XXX"
77      echo "Install Prefix : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
78      read installPrefix
79   if [ "$installPrefix" = "" ]
80   then
81      installPrefix="$generationdir/creatools_install"
82   fi
83   echo "you said : [" $installPrefix "]"
84 echo
85 echo 
86   # ------------------
87
88   docgeneration="XXX"
89   while [[ "$docgeneration" != "YES"  && "$docgeneration" != "NO" ]]
90   do
91   echo "Boolean For Doc Generation : YES/NO (default is NO)"
92   read docgeneration
93   if [ "$docgeneration" = "" ]
94   then
95      docgeneration="NO"
96   fi
97   echo "you said : [" $docgeneration "]"
98   done
99 echo
100 echo
101   # ------------------
102
103   sourcesFrom="XXX"
104   while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
105   do
106   echo "Where do you want to get source files from : CVS/HTML (default is HTML)"
107   read sourcesFrom
108   if [ "$sourcesFrom" = "" ]
109   then
110      sourcesFrom="HTML"
111   fi
112   echo "you said : [" $sourcesFrom "]"
113   done
114 echo
115 echo
116   # ------------------
117   
118   cvsUserName=""
119   if [ "$sourcesFrom" = "CVS" ]
120   then
121   while [ "$cvsUserName" == "" ]
122   do
123      echo "CVS User Name (mandatory!)"
124      read cvsUserName
125   done
126   echo "you said : [" $cvsUserName "]"
127   else
128     cvsUserName="ForgetThisOne" 
129   fi
130 echo
131 echo
132   # ------------------
133
134   linuxUserName=""
135   while [ "$linuxUserName" == "" ]
136   do 
137      echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
138      ls -l .bashrc
139      echo "Login User Name (mandatory!)"
140      read linuxUserName  
141      echo "you said : [" $linuxUserName "]"  
142   done
143 echo
144 echo
145
146   linuxGroupName=""
147   while [ "$linuxGroupName" == "" ]
148   do
149      echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
150      echo "Login Group Name (mandatory!)"
151      read linuxGroupName  
152      echo "you said : [" $linuxGroupName "]"  
153   done
154 echo
155 echo
156   # ------------------
157   
158   buildType="XXX"
159   while [[ "$buildType" != "Release"  && "$Debug " != "HTML" ]]
160   do
161   echo "Build type : Release/Debug (default is Release)"
162   read buildType
163   if [ "$buildType" = "" ]
164   then
165      buildType="Release"
166   fi
167   echo "you said : [" $buildType "]"
168   done
169 echo
170 echo
171   # ------------------
172   
173   gdcmVersion="XXX"
174   while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
175   do
176   echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
177   read gdcmVersion
178   if [ "$gdcmVersion" = "" ]
179   then
180      gdcmVersion="GDCM1"
181   fi
182   echo "you said : [" $gdcmVersion "]"
183   done
184 echo
185 echo
186 echo
187 echo
188 echo "You said :"
189 echo "           Operating System                           : $OperatingSystem"
190 echo "           Name of the Generation Directory           : $generationdir"
191 echo "           Install Prefix                             : $installPrefix"
192 echo "           Boolean For Doc Generation                 : $docgeneration"
193 echo "           Where do you want to get source files from : $sourcesFrom"
194 if [ $sourcesFrom = CVS ]
195 then
196 echo "           CVS User Name                              : $cvsUserName"
197 fi
198 echo "           Login User Name                            : $linuxUserName"
199 echo "           Login Group Name                           : $linuxGroupName"
200 echo "           Build type                                 : $buildType"          
201 echo "           Gdcm version                               : $gdcmVersion"
202 echo
203 echo
204 echo "Do you confirm your choices : YES/NO ? (default is NO)"
205 read confirm
206 done 
207
208
209  # GROS SOUCIS : Ou creer le fichier CreaTools-configure.sh?
210  # dans $generationdir/creatools_bin ?
211  # -> il n'est pas encore cree !
212  # dans ./Linux/scripts?
213  # -> ? 
214
215 configureFile="scripts/CreaTools-configure.sh"
216 touch  $configureFile
217 echo "#!/bin/sh"                          >  $configureFile
218 echo                                      >> $configureFile
219 echo "#File generated by 'menu.sh'"       >> $configureFile
220 echo "#DO NOT edit !"                     >> $configureFile
221 echo "#(except if you *know* what you do)">> $configureFile
222 echo                                      >> $configureFile
223 echo "OperatingSystem=$OperatingSystem"   >> $configureFile
224 echo "generationdir=$generationdir"       >> $configureFile
225 echo "installPrefix=$installPrefix"       >> $configureFile
226 echo "docgeneration=$docgeneration"       >> $configureFile
227 echo "sourcesFrom=$sourcesFrom"           >> $configureFile
228 echo "cvsUserName=$cvsUserName"           >> $configureFile 
229 echo "loginUserName=$linuxUserName"       >> $configureFile
230 echo "loginGroupName=$linuxGroupName"     >> $configureFile
231 echo "buildType=$buildType"               >> $configureFile
232 echo "gdcmVersion=$gdcmVersion"           >> $configureFile
233
234          
235   # ------------------      
236   ;;
237   
238   1)
239      echo "========================== $i "
240      sh scripts/ThirdParty-install.sh
241      
242      vtkdirVariable=""
243      while [ "$vtkdirVariable" = "" ]
244      do
245         echo " Set VTK_DIR environment variable"
246         read vtkdirVariable
247      done
248      echo "you said [" $vtkdirVariable "]"
249
250      #vtkdirVariable=""
251      #while [ "$vtkdirVariable" = "" ]
252      #do
253      #   echo " Set VTK_DIR environment variable"
254       #  read vtkdirVariable
255      #done
256      #echo "you said [" $vtkdirVariable "]"
257           
258      latexCompilerVariable=""
259      while [ "$latexCompilerVariable" = "" ]
260      do
261         echo " Set LATEX_COMPILER environment variable"
262         read latexCompilerVariable
263      done
264      echo "you said [" $latexCompilerVariable "]"     
265
266      sed -i -e '/.*VTK_DIR*/ d'        /etc/bashrc
267      sed -i -e '/.*LATEX_COMPILER*/ d' /etc/bashrc 
268      echo "export VTK_DIR=$vtkdirVariable" >> /etc/bashrc
269      echo "export LATEX_COMPILER=$latexCompilerVariable" >> /etc/bashrc
270      
271      echo "------------------------------------"
272      echo OK
273      echo "To go on, run again 'sh menu.sh' as root, in a new window"
274      echo "------------------------------------"
275      exit 0             
276   ;;
277   
278   2)
279      echo "========================== $i"
280      sh scripts/CreaTools-compile.sh
281      
282      # To allow (very aware) user to patch code
283      chown -R $generationdir/creatools_source $linuxUserName
284      chgrp -R $generationdir/creatools_source $linuxGroupName
285      # Too much time consuming
286      #chown -R $generationdir/creatools_source $linuxUserName
287      #chgrp -R $generationdir/creatools_source $linuxGroupName     
288   ;;
289   
290   3) 
291      echo "========================= $i"
292      sh scripts/CreaTools-install.sh     
293   ;;
294  
295   4)
296      echo "========================= $i"
297      sh scripts/CreaTools-uninstall.sh
298   ;;
299        
300   9) 
301   echo exit
302   ;;
303    
304   *)
305   echo "Your answer must be in {0, 1, 2, 3, 4, 9} (was $i)"
306   ;;
307   esac
308
309 done
310 fi