]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
re indent
[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 " 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         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 "]"su
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 ~/.bashrc
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            read linuxGroupName  
175            echo "you said : [" $linuxGroupName "]"  
176         done
177         echo
178         echo
179         # ------------------
180
181         buildType="XXX"
182         while [[ "$buildType" != "Release"  && "$Debug " != "HTML" ]]
183         do
184            echo "Build type : Release/Debug (default is Release)"
185            read buildType
186            if [ "$buildType" = "" ]
187            then
188               buildType="Release"
189            fi
190            echo "you said : [" $buildType "]"
191         done
192         echo
193         echo
194         # ------------------
195
196         gdcmVersion="XXX"
197         while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion " != "GDCM2" ]]
198         do
199            echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
200            read gdcmVersion
201            if [ "$gdcmVersion" = "" ]
202            then
203               gdcmVersion="GDCM1"
204            fi
205            echo "you said : [" $gdcmVersion "]"
206         done
207         echo
208         echo
209         echo
210         echo
211         echo "You said :"
212         echo "           Operating System                           : $OperatingSystem"
213         echo "           Name of the Generation Directory           : $generationdir"
214         echo "           Install Prefix                             : $installPrefix"
215         echo "           Boolean for Doc Generation                 : $docgeneration"
216         echo "           Where do you want to get source files from : $sourcesFrom"
217         if [ $sourcesFrom = CVS ]
218         then
219            echo "           CVS User Name                              : $cvsUserName"
220         fi
221         echo "           Login User Name                            : $linuxUserName"
222         echo "           Login Group Name                           : $linuxGroupName"
223         echo "           Build type                                 : $buildType"          
224         echo "           Gdcm version                               : $gdcmVersion"
225         echo
226         echo
227         echo "Do you confirm your choices : YES/NO ? (default is NO)"
228         read confirm
229    done
230
231  # GROS SOUCIS : Ou generer le fichier CreaTools-configure.sh?
232  # dans $generationdir/creatools_bin ?
233  # -> il n'est pas encore cree !
234  # dans ./Linux/scripts?
235  # -> ? 
236
237    configureFile="scripts/CreaTools-configure.sh"
238    touch  $configureFile
239    echo "#!/bin/sh"                          >  $configureFile
240    echo                                      >> $configureFile
241    echo "#File generated by 'menu.sh'"       >> $configureFile
242    echo "#DO NOT edit !"                     >> $configureFile
243    echo "#(except if you *know* what you do)">> $configureFile
244    echo                                      >> $configureFile
245    echo "OperatingSystem=$OperatingSystem"   >> $configureFile
246    echo "generationdir=$generationdir"       >> $configureFile
247    echo "installPrefix=$installPrefix"       >> $configureFile
248    echo "docgeneration=$docgeneration"       >> $configureFile
249    echo "sourcesFrom=$sourcesFrom"           >> $configureFile
250    echo "cvsUserName=$cvsUserName"           >> $configureFile 
251    echo "loginUserName=$linuxUserName"       >> $configureFile
252    echo "loginGroupName=$linuxGroupName"     >> $configureFile
253    echo "buildType=$buildType"               >> $configureFile
254    echo "gdcmVersion=$gdcmVersion"           >> $configureFile
255
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 " Set VTK_DIR environment variable"
270         read vtkdirVariable
271      done
272      echo "you said [" $vtkdirVariable "]"
273
274      #vtkdirVariable=""
275      #while [ "$vtkdirVariable" = "" ]
276      #do
277      #   echo " Set VTK_DIR environment variable"
278       #  read vtkdirVariable
279      #done
280      #echo "you said [" $vtkdirVariable "]"
281           
282      latexCompilerVariable=""
283      while [ "$latexCompilerVariable" = "" ]
284      do
285         echo " Set LATEX_COMPILER environment variable"
286         read latexCompilerVariable
287      done
288      echo "you said [" $latexCompilerVariable "]"     
289
290      sed -i -e '/.*VTK_DIR*/ d'        /etc/bashrc
291      sed -i -e '/.*LATEX_COMPILER*/ d' /etc/bashrc 
292      echo "export VTK_DIR=$vtkdirVariable" >> /etc/bashrc
293      echo "export LATEX_COMPILER=$latexCompilerVariable" >> /etc/bashrc
294      
295      echo "------------------------------------"
296      echo OK
297      echo "To go on, run again 'sh menu.sh' as root, in a new window"
298      echo "------------------------------------"
299      exit 0             
300   ;;
301   
302   2)
303      echo "========================== 2"
304      sh scripts/CreaTools-compile.sh
305      
306      # To allow (*very* aware) user to patch code, later
307      chown -R $generationdir/creatools_source $linuxUserName
308      chgrp -R $generationdir/creatools_source $linuxGroupName
309      # Too much time consuming
310      #chown -R $generationdir/creatools_source $linuxUserName
311      #chgrp -R $generationdir/creatools_source $linuxGroupName     
312   ;;
313   
314   3) 
315      echo "========================= 3"
316      sh scripts/CreaTools-install.sh     
317   ;;
318  
319   4)
320      echo "========================= 4"
321      sh scripts/CreaTools-uninstall.sh
322   ;;
323        
324   9) 
325   echo exit
326   ;;
327    
328   *)
329   echo "Your answer must be in {0, 1, 2, 3, 4, 9} (was $i)"
330   ;;
331   esac
332
333 done
334