Subversion Repositories wimsdev

Rev

Rev 16628 | Rev 16686 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 reyssat 1
#! /bin/sh
2
 
12677 obado 3
# Color constants
4
RED='\033[0;31m'
5
GREEN='\033[0;32m'
6
ORANGE='\033[0;33m'
7
BLUE='\033[0;34m'
8
PURPLE='\033[0;35m'
9
NC='\033[0m' # No Color
10
# sample : I ${RED}love${NC} WIMS
11
 
825 bpr 12
if [ "$(id -ru)" = 0 ]; then
12677 obado 13
  cat <<@
3855 kbelabas 14
You are trying to compile WIMS as 'root'. You should not do that !
15
Please compile as 'wims'.
2 reyssat 16
@
12677 obado 17
  exit 1
2 reyssat 18
fi
19
 
4430 bpr 20
option=$1
21
 
3855 kbelabas 22
##########################################################################
2 reyssat 23
cat <<@
3855 kbelabas 24
Welcome to the compilation of WIMS (WWW Interactive Multipurpose Server)
2 reyssat 25
 
26
@
3856 bpr 27
cd `dirname $0`
7437 bpr 28
dir=`pwd`;
4371 bpr 29
 
13184 obado 30
mkdir -p lib sessions
31
mkdir -p tmp tmp/log tmp/sessions tmp/whoconnect
32
 
7437 bpr 33
if [ ! "$option" ] ; then option=no ; fi ;
13523 obado 34
## option: --mathjax --jmol --geogebra --shtooka --gcov --jme
7437 bpr 35
for a in $(seq $#) ; do opt=$1;
12677 obado 36
  if [ "$opt" = "--build-chroot" ] ; then
37
    if [ -d chroot ] ; then
38
      mkdir -p chroot/tmp
39
      mkdir -p chroot/tmp/sessions
40
      touch chroot/tmp/sessions/.chroot
41
    else
42
      cat <<@
43
You must first get and install the chroot directory. See the README
4430 bpr 44
 
45
@
12677 obado 46
      exit 1
47
    fi
7487 bpr 48
  fi
12677 obado 49
  if [ "$opt" = "--mathjax" ] ; then
50
    echo "${PURPLE}** MathJax installation **${NC}"
16628 obado 51
    #vmathjax=2.7.9
52
    vmathjax=3.2.0
12677 obado 53
 
7379 bpr 54
    cd tmp
12642 obado 55
    echo "downloading MathJax $vmathjax"
12677 obado 56
    wget https://github.com/mathjax/MathJax/archive/$vmathjax.zip
57
    if [ -f "$vmathjax.zip" ] ; then
58
      echo "unzipping MathJax $vmathjax"
59
      unzip -q $vmathjax.zip && echo "unzipped successfully"
60
      rm -f $vmathjax.zip
61
      cd $dir
62
      if [ -d "public_html/scripts/js/mathjax" ] ; then
63
        rm -rf public_html/scripts/js/mathjax
64
      fi
16628 obado 65
      mv -f tmp/MathJax-*/es5 public_html/scripts/js/mathjax
12677 obado 66
      echo "${GREEN}Success${NC} : Mathjax $vmathjax has been installed."
67
    else
68
      echo "${RED}Warning : Mathjax hasn't been downloaded.${NC}"
69
      sleep 5
70
      cd $dir
71
    fi
72
  fi
73
  if [ "$opt" = "--jmol" ] ; then
74
    echo "${PURPLE}** jMol installation **${NC}"
10024 noely 75
    vjmol0=14
12642 obado 76
    vjmol1=29
13379 obado 77
    vjmol2=26
10024 noely 78
    vjmol012=$vjmol0.$vjmol1.$vjmol2
10040 bpr 79
    vJmol=Jmol-$vjmol012
80
    vjmol=jmol-$vjmol012
7827 bpr 81
    cd tmp
12642 obado 82
    echo "downloading $vJmol-binary.zip"
12681 bpr 83
    wget --no-check-certificate https://downloads.sourceforge.net/project/jmol/Jmol/Version%20$vjmol0.$vjmol1/Jmol%20$vjmol012/$vJmol-binary.zip
12677 obado 84
    if [ -f "$vJmol-binary.zip" ] ; then
85
      echo "unzipping $vJmol-binary.zip"
86
      unzip -q $vJmol-binary.zip && echo "unzipped successfully"
87
      cd $vjmol;
88
      echo "unzipping jsmol.zip"
89
      unzip -q jsmol.zip && echo "unzipped successfully"
90
      cd $dir
91
      if [ -d "public_html/java/jmol/j2s" ] ; then
92
        mv public_html/java/jmol/j2s public_html/java/jmol/j2s_tmp
93
      fi
94
      if [ -d "public_html/java/jmol/idioma" ] ; then
95
        mv public_html/java/jmol/idioma public_html/java/jmol/idioma_tmp
96
      fi
13335 bpr 97
      mv -f tmp/$vjmol/jsmol/j2s public_html/java/jmol/j2s
12677 obado 98
      mv -f tmp/$vjmol/jsmol/idioma public_html/java/jmol/idioma
99
      cp -f tmp/$vjmol/jsmol/JSmol.min.js public_html/java/jmol/
100
      cp -f tmp/$vjmol/jsmol/JSmol.min.nojq.js public_html/java/jmol/
101
      cp -f tmp/$vjmol/jsmol/js/Jmol2.js public_html/java/jmol/
13335 bpr 102
      cp -f tmp/$vjmol/jsmol/js/JSmolJSV.js public_html/java/jmol/
13378 bpr 103
      cp -f tmp/$vjmol/jsmol/js/JSmolJME.js public_html/java/jmol/
12677 obado 104
      rm -rf tmp/$vjmol
105
      rm -rf tmp/$vJmol-binary.zip
106
      rm -rf public_html/java/jmol/j2s_tmp
107
      rm -rf public_html/java/jmol/idioma_tmp
13379 obado 108
 
12677 obado 109
      echo "${GREEN}Success${NC} : $vJmol has been installed."
110
    else
111
      echo "${RED}Warning : $vJmol hasn't been downloaded.${NC}"
112
      sleep 5
113
      cd $dir
7827 bpr 114
    fi
13379 obado 115
 
13417 bpr 116
    ##vJSME=2018-10-28
117
    ##cd tmp
118
    ##echo "downloading JSME v$vJSME"
119
    ##wget 'https://www.dropbox.com/s/aklw9uftv3ztmym?dl=1' -O JSME_$vJSME.zip
120
    ##if [ -f "JSME_$vJSME.zip" ] ; then
121
    ##  echo "unzipping JSME_$vJSME.zip"
122
    ##  unzip -q JSME_$vJSME.zip && echo "unzipped successfully"
123
    ##  rm -f JSME_$vJSME.zip
124
    ##  cd $dir
125
    ##  if [ -d "public_html/java/jmol/jsme" ] ; then
126
    ##    mv public_html/java/jmol/jsme public_html/java/jmol/jsme_tmp
127
    ##  fi
128
    ##  mkdir public_html/java/jmol/jsme
129
    ##  mv -f tmp/JSME_$vJSME/jsme public_html/java/jmol/jsme/
130
##
131
    ##  rm -rf tmp/JSME_$vJSME
132
    ##  rm -rf public_html/java/jmol/jsme_tmp
133
    ##  echo "${GREEN}Success${NC} : JSME has been installed."
134
    ##else
135
    ##  echo "${RED}Warning : JSME hasn't been downloaded.${NC}"
136
    ##  sleep 5
137
    ##  cd $dir
138
    ##fi
139
    jsmol=1;
140
  fi
13523 obado 141
  if [ "$jsmol" = 1 ] || [ "$opt" = "--jme" ]; then
13417 bpr 142
    echo "downloading JSME"
143
    cd tmp;
144
    wget 'https://wimstest1.di.u-psud.fr/wims/jsme.tgz' -O jsme.tgz
145
    if [ -f "jsme.tgz" ] ; then
146
      tar xzf jsme.tgz
147
      rm -f jsme.tgz
13379 obado 148
      cd $dir
149
      if [ -d "public_html/java/jmol/jsme" ] ; then
150
        mv public_html/java/jmol/jsme public_html/java/jmol/jsme_tmp
151
      fi
152
      mkdir public_html/java/jmol/jsme
13417 bpr 153
      mv -f tmp/jsme public_html/java/jmol/jsme/
154
      rm -rf tmp/jsme
13379 obado 155
      rm -rf public_html/java/jmol/jsme_tmp
156
      echo "${GREEN}Success${NC} : JSME has been installed."
157
    else
158
      echo "${RED}Warning : JSME hasn't been downloaded.${NC}"
159
      sleep 5
160
      cd $dir
161
    fi
12677 obado 162
  fi
163
  if [ "$opt" = "--geogebra" ] ; then
164
    echo "${PURPLE}** GeoGebraWeb installation **${NC}"
16660 obado 165
    vGeogebra=GeoGebraWeb-WIMS-5.0.700.0
11340 obado 166
    ggb_folder=public_html/scripts/js/geogebra
9824 bpr 167
    cd tmp
11759 obado 168
    echo "downloading $vGeogebra.zip"
15986 obado 169
    wget https://wims.univ-cotedazur.fr/download/others/$vGeogebra.zip && echo "downloaded successfully"
12677 obado 170
    if [ -f "$vGeogebra.zip" ] ; then
171
      echo "unzipping $vGeogebra.zip"
172
      unzip -q $vGeogebra.zip && echo "unzipped successfully"
173
      rm -f $vGeogebra.zip
174
      cd $dir
175
      if [ -d "$ggb_folder/geogebraweb" ] ; then
176
        mv $ggb_folder/geogebraweb $ggb_folder/geogebraweb_tmp
177
      fi
178
      mv -f tmp/$vGeogebra $ggb_folder/geogebraweb
179
      rm -rf tmp/$vGeogebra
180
      rm -rf $ggb_folder/geogebraweb_tmp
181
      echo "geogebra_exists=yes" | cat > $ggb_folder/test
182
      echo "${GREEN}Success${NC} : $vGeogebra has been installed."
183
    else
184
      echo "${RED}Warning : $vGeogebra hasn't been downloaded.${NC}"
185
      sleep 5
186
      cd $dir
9824 bpr 187
    fi
12677 obado 188
  fi
189
  if [ "$opt" = "--modules" ] ; then
7437 bpr 190
    echo "load modules"
7438 bpr 191
    src/wims_modules.pl
7437 bpr 192
    cd $dir
12677 obado 193
  fi
194
  if [ "$opt" = "--shtooka" ] ; then
7437 bpr 195
    echo "load audio shtooka"
196
    bin/swac
197
    cd $dir
12677 obado 198
  fi
199
  if [ "$opt" = "--gcov" ] ; then
8807 bpr 200
    export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
12677 obado 201
  fi
202
  shift
7437 bpr 203
done
7379 bpr 204
 
15907 bpr 205
##delete files *.bin in log/classes
15912 bpr 206
##in housekeep.daily in directory log/classes
207
## find . -type f -name "*.bin" -exec rm -v "{}" ";" 1>/dev/null
15925 bpr 208
find log/classes -path "log/classes/*/score/*.bin" -exec rm -f "{}" ";"
3856 bpr 209
cd src
4390 bpr 210
 
16015 bpr 211
##if [ -f ../.wims_maintainer_mode ]; then
212
##  touch configure.ac ;
213
##  if (autoconf); then :; else
214
##    echo "[maintainer mode] Please install autoconf first."
215
##    exit 1
216
##  fi
217
##  autoheader
218
##fi
10040 bpr 219
./configure || exit
16139 bpr 220
### if some files are not found during compilation, you can try something like that
10790 bpr 221
#./configure CFLAGS="-g -O2 -I/usr/local/include" LDFLAGS=-L/usr/local/lib || exit
16141 bpr 222
#./configure CFLAGS="-g -O2 -I/opt/homebrew/include" CXXFLAGS="-g -O2 -I/opt/homebrew/include" LDFLAGS=-L/opt/homebrew/lib || exit
2 reyssat 223
make clean || exit
224
make all || exit
4290 bpr 225
 
226
if [ -f ../.wims_maintainer_mode ]; then
4355 bpr 227
### use convert, identify
4290 bpr 228
  make maintainer || exit
4355 bpr 229
### all the maintainers should have Apache ant - java compilation
14708 bpr 230
  ##if (ant -version); then :; else
231
  ##  echo "[maintainer mode] Please install Apache ant first."
232
  ##  exit 1
233
  ##fi
4663 bpr 234
  if (convert -version) || (identify -version); then :; else
4355 bpr 235
    echo "[maintainer mode] Please install convert and identify first."
236
    exit 1
237
  fi
4371 bpr 238
  cd Misc ; make maintainer || exit
4297 bpr 239
  cd ..
4290 bpr 240
fi
13940 bpr 241
if [ -f ../.wims_maintainer_mode ]; then
242
  echo "** Make canvadraw documentation... "
243
  cd Misc/canvasdraw
13941 bpr 244
  sh canvasinfo.sh 1>/dev/null
13940 bpr 245
  cd ../..
246
fi
15973 bpr 247
 
2 reyssat 248
cd ..
15973 bpr 249
cp public_html/gifs/svg/iconeserver_orig.svg public_html/gifs/svg/iconeserver.svg
250
if [ -f log/wims.conf ]; then
251
  color=`cat log/wims.conf | grep "ref_bgcolor" | sed "s/ref_bgcolor=//"`;
252
  if [ "$color" ]; then
253
    cat public_html/gifs/svg/iconeserver_orig.svg | sed "s/fill:#777777/fill:$color/" > public_html/gifs/svg/iconeserver.svg
254
  fi
255
else
7487 bpr 256
  cat <<@
4494 bpr 257
 
258
You can configure some parameters which allow the manager site
259
to make more configuration from the web interface.
260
 
4997 obado 261
Please write the IP address of the wims webmaster ? [127.0.0.1]
4494 bpr 262
@
4390 bpr 263
  read ans1
264
  if [ -z $ans1 ]; then :; else
4460 bpr 265
    echo "manager_site=$ans1" >> log/wims.conf
4371 bpr 266
    chmod 600 log/wims.conf
267
  fi
7487 bpr 268
  cat <<@
4494 bpr 269
 
270
Please write the email address of the wims webmaster: ? []
271
@
4390 bpr 272
  read ans2
4494 bpr 273
  if [ -z $ans2 ]; then
274
     if [ -z $ans1 ]; then :; else echo "site_manager=" >> log/wims.conf; fi
4997 obado 275
  else
276
     if [ -z $ans1 ]; then echo "manager_site=127.0.0.1" >> log/wims.conf ; fi
277
     echo "site_manager=$ans2" >> log/wims.conf
278
     chmod 600 log/wims.conf
4371 bpr 279
  fi
280
fi
281
if [ -f log/.wimspass ]; then :; else
7487 bpr 282
  cat <<@
283
 
4494 bpr 284
Please give the password for the wims webmaster
285
You can change it in the file log/.wimspass
286
Webmaster password: ? []
287
@
4390 bpr 288
  read ans3
289
  if [ -z $ans3 ]; then :; else
290
    echo "$ans3" > log/.wimspass
4371 bpr 291
    chmod 600 log/.wimspass
292
  fi
293
fi
4460 bpr 294
if [ $option = "--build-chroot" ] ; then
4430 bpr 295
  script=wrapuid ;
296
else
13394 bpr 297
  script=setwrapexec ;
4430 bpr 298
fi
7181 bpr 299
 
2 reyssat 300
cat <<@
301
 
7487 bpr 302
Please run './bin/$script' (and './bin/apache-config' for the first installation) as root
4474 bpr 303
(e.g. using sudo) to finish WIMS setup.
4460 bpr 304
 
2916 reyssat 305
See README about installation of help and teaching modules.
2 reyssat 306
 
307
@
4371 bpr 308
 
7176 bpr 309
exit