]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
upgrade (new) new way for Linux
[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 "LINUX/MacOS User Name (mandatory!)"
138      read linuxUserName  
139      echo "you said : [" $linuxUserName "]"  
140   done
141 echo
142 echo
143   # ------------------
144   
145   buildType="XXX"
146   while [[ "$buildType" != "Release"  && "$Debug " != "HTML" ]]
147   do
148   echo "Build type : Release/Debug (default is Release)"
149   read buildType
150   if [ "$buildType" = "" ]
151   then
152      buildType="Release"
153   fi
154   echo "you said : [" $buildType "]"
155   done
156 echo
157 echo
158   # ------------------
159   
160   gdcmVersion="XXX"
161   while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
162   do
163   echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
164   read gdcmVersion
165   if [ "$gdcmVersion" = "" ]
166   then
167      gdcmVersion="GDCM1"
168   fi
169   echo "you said : [" $gdcmVersion "]"
170   done
171 echo
172 echo
173 echo
174 echo
175 echo "You said :"
176 echo "           Operating System                           : $OperatingSystem"
177 echo "           Name of the Generation Directory           : $generationdir"
178 echo "           Install Prefix                             : $installPrefix"
179 echo "           Boolean For Doc Generation                 : $docgeneration"
180 echo "           Where do you want to get source files from : $sourcesFrom"
181 if [ $sourcesFrom = CVS ]
182 then
183 echo "           CVS User Name                              : $cvsUserName"
184 fi
185 echo "           LINUX/MacOS User Name                      : $linuxUserName"
186 echo "           Build type                                 : $buildType"          
187 echo "           Gdcm version                               : $gdcmVersion"
188 echo
189 echo
190 echo "Do you confirm your choices : YES/NO ? (default is NO)"
191 read confirm
192 done 
193
194
195  # GROS SOUCIS : Ou creer le fichier CreaTools-configure.sh?
196  # dans $generationdir/creatools_bin ?
197  # -> il n'est pas encore cree !
198  # dans ./Linux/scripts?
199  # -> ? 
200
201 configureFile="scripts/CreaTools-configure.sh"
202 touch  $configureFile
203 echo "#!/bin/sh"                          >  $configureFile
204 echo                                      >> $configureFile
205 echo "#File generated by 'menu.sh'"       >> $configureFile
206 echo "#DO NOT edit !"                     >> $configureFile
207 echo "#(except if you *know* what you do)">> $configureFile
208 echo                                      >> $configureFile
209 echo "OperatingSystem=$OperatingSystem"   >> $configureFile
210 echo "generationdir=$generationdir"       >> $configureFile
211 echo "installPrefix=$installPrefix"       >> $configureFile
212 echo "docgeneration=$docgeneration"       >> $configureFile
213 echo "sourcesFrom=$sourcesFrom"           >> $configureFile
214 echo "cvsUserName=$cvsUserName"           >> $configureFile 
215 echo "linuxUserName=$linuxUserName"       >> $configureFile
216 echo "buildType=$buildType"               >> $configureFile
217 echo "gdcmVersion=$gdcmVersion"           >> $configureFile
218
219          
220   # ------------------      
221   ;;
222   
223   1)
224      echo "========================== $i "
225      sh scripts/ThirdParty-install.sh
226      
227      vtkdirVariable=""
228      while [ "$vtkdirVariable" = "" ]
229      do
230         echo " Set VTK_DIR environment variable"
231         read vtkdirVariable
232      done
233      echo "you said [" $vtkdirVariable "]"
234
235      #vtkdirVariable=""
236      #while [ "$vtkdirVariable" = "" ]
237      #do
238      #   echo " Set VTK_DIR environment variable"
239       #  read vtkdirVariable
240      #done
241      #echo "you said [" $vtkdirVariable "]"
242           
243      latexCompilerVariable=""
244      while [ "$latexCompilerVariable" = "" ]
245      do
246         echo " Set LATEX_COMPILER environment variable"
247         read latexCompilerVariable
248      done
249      echo "you said [" $latexCompilerVariable "]"     
250
251      sed -i -e '/.*VTK_DIR*/ d'        /etc/bashrc
252      sed -i -e '/.*LATEX_COMPILER*/ d' /etc/bashrc 
253      echo "export VTK_DIR=$vtkdirVariable" >> /etc/bashrc
254      echo "export LATEX_COMPILER=$latexCompilerVariable" >> /etc/bashrc
255      
256      echo "------------------------------------"
257      echo OK
258      echo "To go on, run again 'sh menu.sh' as root, in a new window"
259      echo "------------------------------------"
260      exit 0             
261   ;;
262   
263   2)
264      echo "========================== $i"
265      sh scripts/CreaTools-compile.sh     
266   ;;
267   
268   3) 
269      echo "========================= $i"
270      sh scripts/CreaTools-install.sh     
271   ;;
272  
273   4)
274      echo "========================= $i"
275      sh scripts/CreaTools-uninstall.sh
276   ;;
277        
278   9) 
279   echo exit
280   ;;
281    
282   *)
283   echo "Your answer must be in {0, 1, 2, 3, 4, 9} (was $i)"
284   ;;
285   esac
286
287 done
288 fi