Subversion Repositories wimsdev

Rev

Rev 18640 | 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;
18402 bpr 144
    wget 'https://wims1.math.cnrs.fr/wims/jsme.tgz' -O jsme.tgz
13417 bpr 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}"
16686 obado 165
    # vGeogebra=GeoGebraWeb-WIMS-5.0.700.0
166
    vGeogebra=GeoGebraWeb-WIMS-5.0.452.0
11340 obado 167
    ggb_folder=public_html/scripts/js/geogebra
9824 bpr 168
    cd tmp
11759 obado 169
    echo "downloading $vGeogebra.zip"
15986 obado 170
    wget https://wims.univ-cotedazur.fr/download/others/$vGeogebra.zip && echo "downloaded successfully"
12677 obado 171
    if [ -f "$vGeogebra.zip" ] ; then
172
      echo "unzipping $vGeogebra.zip"
173
      unzip -q $vGeogebra.zip && echo "unzipped successfully"
174
      rm -f $vGeogebra.zip
175
      cd $dir
176
      if [ -d "$ggb_folder/geogebraweb" ] ; then
177
        mv $ggb_folder/geogebraweb $ggb_folder/geogebraweb_tmp
178
      fi
179
      mv -f tmp/$vGeogebra $ggb_folder/geogebraweb
180
      rm -rf tmp/$vGeogebra
181
      rm -rf $ggb_folder/geogebraweb_tmp
182
      echo "geogebra_exists=yes" | cat > $ggb_folder/test
183
      echo "${GREEN}Success${NC} : $vGeogebra has been installed."
184
    else
185
      echo "${RED}Warning : $vGeogebra hasn't been downloaded.${NC}"
186
      sleep 5
187
      cd $dir
9824 bpr 188
    fi
12677 obado 189
  fi
190
  if [ "$opt" = "--modules" ] ; then
7437 bpr 191
    echo "load modules"
7438 bpr 192
    src/wims_modules.pl
7437 bpr 193
    cd $dir
12677 obado 194
  fi
195
  if [ "$opt" = "--shtooka" ] ; then
7437 bpr 196
    echo "load audio shtooka"
197
    bin/swac
198
    cd $dir
12677 obado 199
  fi
200
  if [ "$opt" = "--gcov" ] ; then
8807 bpr 201
    export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
12677 obado 202
  fi
203
  shift
7437 bpr 204
done
7379 bpr 205
 
15907 bpr 206
##delete files *.bin in log/classes
15912 bpr 207
##in housekeep.daily in directory log/classes
208
## find . -type f -name "*.bin" -exec rm -v "{}" ";" 1>/dev/null
15925 bpr 209
find log/classes -path "log/classes/*/score/*.bin" -exec rm -f "{}" ";"
3856 bpr 210
cd src
4390 bpr 211
 
16015 bpr 212
##if [ -f ../.wims_maintainer_mode ]; then
213
##  touch configure.ac ;
214
##  if (autoconf); then :; else
215
##    echo "[maintainer mode] Please install autoconf first."
216
##    exit 1
217
##  fi
218
##  autoheader
219
##fi
10040 bpr 220
./configure || exit
18662 czzmrn 221
### use the following for Ubuntu 24.04
222
# ./configure CFLAGS="-g -O2 -D_FORTIFY_SOURCE=-1"  || exit
16139 bpr 223
### if some files are not found during compilation, you can try something like that
10790 bpr 224
#./configure CFLAGS="-g -O2 -I/usr/local/include" LDFLAGS=-L/usr/local/lib || exit
16141 bpr 225
#./configure CFLAGS="-g -O2 -I/opt/homebrew/include" CXXFLAGS="-g -O2 -I/opt/homebrew/include" LDFLAGS=-L/opt/homebrew/lib || exit
2 reyssat 226
make clean || exit
227
make all || exit
4290 bpr 228
 
229
if [ -f ../.wims_maintainer_mode ]; then
4355 bpr 230
### use convert, identify
4290 bpr 231
  make maintainer || exit
4355 bpr 232
### all the maintainers should have Apache ant - java compilation
14708 bpr 233
  ##if (ant -version); then :; else
234
  ##  echo "[maintainer mode] Please install Apache ant first."
235
  ##  exit 1
236
  ##fi
4663 bpr 237
  if (convert -version) || (identify -version); then :; else
4355 bpr 238
    echo "[maintainer mode] Please install convert and identify first."
239
    exit 1
240
  fi
4371 bpr 241
  cd Misc ; make maintainer || exit
4297 bpr 242
  cd ..
4290 bpr 243
fi
13940 bpr 244
if [ -f ../.wims_maintainer_mode ]; then
245
  echo "** Make canvadraw documentation... "
246
  cd Misc/canvasdraw
18640 czzmrn 247
   LC_ALL=C sh canvasinfo.sh 1>/dev/null
13940 bpr 248
  cd ../..
249
fi
15973 bpr 250
 
2 reyssat 251
cd ..
15973 bpr 252
cp public_html/gifs/svg/iconeserver_orig.svg public_html/gifs/svg/iconeserver.svg
253
if [ -f log/wims.conf ]; then
254
  color=`cat log/wims.conf | grep "ref_bgcolor" | sed "s/ref_bgcolor=//"`;
255
  if [ "$color" ]; then
256
    cat public_html/gifs/svg/iconeserver_orig.svg | sed "s/fill:#777777/fill:$color/" > public_html/gifs/svg/iconeserver.svg
257
  fi
258
else
7487 bpr 259
  cat <<@
4494 bpr 260
 
261
You can configure some parameters which allow the manager site
262
to make more configuration from the web interface.
263
 
4997 obado 264
Please write the IP address of the wims webmaster ? [127.0.0.1]
4494 bpr 265
@
4390 bpr 266
  read ans1
267
  if [ -z $ans1 ]; then :; else
4460 bpr 268
    echo "manager_site=$ans1" >> log/wims.conf
4371 bpr 269
    chmod 600 log/wims.conf
270
  fi
7487 bpr 271
  cat <<@
4494 bpr 272
 
273
Please write the email address of the wims webmaster: ? []
274
@
4390 bpr 275
  read ans2
4494 bpr 276
  if [ -z $ans2 ]; then
277
     if [ -z $ans1 ]; then :; else echo "site_manager=" >> log/wims.conf; fi
4997 obado 278
  else
279
     if [ -z $ans1 ]; then echo "manager_site=127.0.0.1" >> log/wims.conf ; fi
280
     echo "site_manager=$ans2" >> log/wims.conf
281
     chmod 600 log/wims.conf
4371 bpr 282
  fi
283
fi
284
if [ -f log/.wimspass ]; then :; else
7487 bpr 285
  cat <<@
286
 
4494 bpr 287
Please give the password for the wims webmaster
288
You can change it in the file log/.wimspass
289
Webmaster password: ? []
290
@
4390 bpr 291
  read ans3
292
  if [ -z $ans3 ]; then :; else
293
    echo "$ans3" > log/.wimspass
4371 bpr 294
    chmod 600 log/.wimspass
295
  fi
296
fi
4460 bpr 297
if [ $option = "--build-chroot" ] ; then
4430 bpr 298
  script=wrapuid ;
299
else
13394 bpr 300
  script=setwrapexec ;
4430 bpr 301
fi
7181 bpr 302
 
2 reyssat 303
cat <<@
304
 
7487 bpr 305
Please run './bin/$script' (and './bin/apache-config' for the first installation) as root
4474 bpr 306
(e.g. using sudo) to finish WIMS setup.
4460 bpr 307
 
2916 reyssat 308
See README about installation of help and teaching modules.
2 reyssat 309
 
310
@
4371 bpr 311
 
7176 bpr 312
exit