File: mkdemo.sh

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (438 lines) | stat: -rwxr-xr-x 10,502 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#!/bin/sh
#
#  mkdemo.sh
#
#  $Id$
#
#  Creates a demo database
#  
#  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
#  project.
#  
#  Copyright (C) 1998-2012 OpenLink Software
#  
#  This project is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; only version 2 of the License, dated June 1991.
#  
#  This program is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#  
#  

# ----------------------------------------------------------------------
#  Fix issues with LOCALE
# ----------------------------------------------------------------------
LANG=C
LC_ALL=POSIX
export LANG LC_ALL


PORT=${PORT-1112}
_HTTPPORT=`expr $PORT + 10`
HTTPPORT=${HTTPPORT-$_HTTPPORT}
#PORT=1311
#HTTPPORT=8311
HOST=${HOST-localhost}
SERVER=${SERVER-}

DSN="$HOST:$PORT"
LOGFILE=mkdemo.output
DEMO=`pwd`
export DEMO LOGFILE
SILENT=${SILENT-0}
MAKEDOCS=${MAKEDOCS-0}
HTMLDOCS=${HTMLDOCS-1}
ISQL=${ISQL-isql}
HOST_OS=`uname -s | grep WIN`

if [ "x$HOST_OS" != "x" ]
then
    TEMPFILE="`cygpath -m $TMP/isql.$$`"
    HOME="`cygpath -m $HOME`"
    LN="cp -rf"
    RM="rm -rf"
else
    TEMPFILE=/tmp/isql.$$
    LN="ln -f -s"
    RM="rm -rf"
fi

VOS=0
if [ "z$SERVER" = "z" ]  
then
    if [ "x$HOST_OS" != "x" ]
    then
	SERVER=virtuoso-odbc-t.exe
    else
	SERVER=virtuoso
    fi
fi

if [ -f ../../../autogen.sh ]
then
    VOS=1
fi

# Default ports
DBSQLPORT=1111
DBHTTPPORT=8889
DEMOSQLPORT=1112
DEMOHTTPPORT=8890

export DEMODB

#==============================================================================
#  Standard functions
#==============================================================================

ECHO()
{
    echo "$*"		| tee -a $DEMO/$LOGFILE
}


RUN()
{
    echo "+ $*"		>> $DEMO/$LOGFILE

    STATUS=1
    if test $SILENT -eq 1
    then
	eval $*		>> $DEMO/$LOGFILE 2>/dev/null
    else
	eval $*		>> $DEMO/$LOGFILE
    fi
    STATUS=$?
}


LINE()
{
    ECHO "====================================================================="
}


BREAK()
{
    ECHO ""
    ECHO "---------------------------------------------------------------------"
    ECHO ""
}


BANNER()
{
    ECHO ""
    LINE
    ECHO "=  $*"
    ECHO "= " `date`
    LINE
    ECHO ""
}


START_SERVER()
{
  timeout=180

  ECHO "Starting Virtuoso DEMO server ..."
  if [ "z$HOST_OS" != "z" ] 
  then
      "$SERVER" +foreground &
  else
      "$SERVER" +wait
  fi

  starth=`date | cut -f 2 -d :`
  starts=`date | cut -f 3 -d :|cut -f 1 -d " "`

  for i in $(seq 1 10)
    do
      sleep 6
      if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null)
        then
	  ECHO "Virtuoso server started"
	  return 0
	fi
  done
	  ECHO "***WARNING: Could not start Virtuoso DEMO Server within $timeout seconds"
	  return 1
}

STOP_SERVER()
{
    RUN $ISQL $DSN dba dba '"EXEC=raw_exit();"' VERBOSE=OFF PROMPT=OFF ERRORS=STDOUT
}


DO_COMMAND()
{
  command=$1
  uid=${2-dba}
  passwd=${3-dba}
  $ISQL $DSN $uid $passwd ERRORS=stdout VERBOSE=OFF PROMPT=OFF "EXEC=$command" 	>> $DEMO/$LOGFILE
  if test $? -ne 0
  then
    ECHO "***FAILED: $command"
  else
    ECHO "PASSED: $command"
  fi
}


CHECK_LOG()
{
    passed=`cat $DEMO/$LOGFILE | cut -b -200 | grep "PASSED:" | wc -l`
    failed=`cat $DEMO/$LOGFILE | cut -b -200 | grep "\*\*\*.*FAILED:" | wc -l`
    aborted=`cat $DEMO/$LOGFILE | cut -b -200 | grep "\*\*\*.*ABORTED:" | wc -l`

    ECHO ""
    LINE
    ECHO "=  Checking log file $LOGFILE for statistics:"
    ECHO "="
    ECHO "=  Total number of tests PASSED  : $passed"
    ECHO "=  Total number of tests FAILED  : $failed"
    ECHO "=  Total number of tests ABORTED : $aborted"
    LINE
    ECHO ""

    if (expr $failed + $aborted \> 0 > /dev/null)
    then
       ECHO "*** Not all tests completed successfully"
       ECHO "*** Check the file $LOGFILE for more information"
    fi
}


LOAD_SQL()
{
  sql=$1
  uid=${2-dba}
  passwd=${3-dba}

  RUN $ISQL $DSN $uid $passwd ERRORS=stdout VERBOSE=OFF PROMPT=OFF $sql
  if test $? -ne 0
  then
    ECHO "***FAILED: LOAD $sql"
  else
    ECHO "PASSED: LOAD $sql"
  fi
}


#==============================================================================
#  MAIN ROUTINE
#==============================================================================
rm -f demo.db demo.trx demo.log demo.lck mkdemo.output virtuoso.ini

if [ $VOS -eq 1 ]
then
    if [ "x$HOST_OS" = "x" ]
    then
	(cd $HOME/appsrc ; make)
	(cd $HOME/binsrc/b3s ; make)
	(cd $HOME/binsrc/bpel; make)
	(cd $HOME/binsrc/isparql ; make)
	(cd $HOME/binsrc/rdf_mappers ; make)
	(cd $HOME/binsrc/rdb2rdf ; make)
	(cd $HOME/binsrc/samples/image_magick ; make)
	(cd $HOME/binsrc/samples/sparql_demo ; make)
	(cd $HOME/binsrc/tutorial ; make)
	(cd $HOME/binsrc/yacutia ; make)
    fi
else
    (cd $HOME/binsrc/bpel; make )
    [ -f doc_dav.vad ] || (chmod +x mkdoc.sh ; ./mkdoc.sh)
fi


BANNER "CREATING DEMO DATABASE (mkdemo.sh)"

$ISQL -? 2>/dev/null 1>/dev/null 
if [ $? -eq 127 ] ; then
    ECHO "***ABORTED: CREATING DEMO DATABASE, isql is not available"
    exit 1
fi
$SERVER -? 2>/dev/null 1>/dev/null 
if [ $? -eq 127 ] ; then
    ECHO "***ABORTED: CREATING DEMO DATABASE, server is not available"
    exit 1
fi

cat mkdemo.ini | sed -e "s/1112/$PORT/g" | sed -e "s/1113/$HTTPPORT/g" > virtuoso.ini

# MAKE the demo.ini

if [ $VOS -eq 1 ]
then

    cat >> virtuoso.ini <<-END_CFG
	[Plugins]
	LoadPath = ./plugin
	Load1    = plain, wikiv
	Load2    = plain, mediawiki
	Load3    = plain, creolewiki
	Load4    = plain, im
END_CFG

    if [ ! -d plugin ] 
    then
	mkdir plugin
    fi

    if [ "x$HOST_OS" != "x" ]
    then
	cp -f $BINDIR/im.dll plugin
	cp -f $BINDIR/wikiv.dll plugin
	cp -f $BINDIR/mediawiki.dll plugin
	cp -f $BINDIR/creolewiki.dll plugin
    else
	cp -f $HOME/binsrc/samples/image_magick/.libs/im.so plugin
	cp -f $HOME/appsrc/ODS-Wiki/plugin/.libs/wikiv.so plugin
	cp -f $HOME/appsrc/ODS-Wiki/plugin/.libs/mediawiki.so plugin
	cp -f $HOME/appsrc/ODS-Wiki/plugin/.libs/creolewiki.so plugin
    fi

    HOSTNAME=`uname -n`
    if [ $VOS -eq 1 -a "x$HOST_OS" != "x" ]
    then
	BINDIR=`cygpath -m "$BINDIR"`    
	PLUGINDIR=`echo "$BINDIR" | sed -e 's#/#\\\/#g; s# #\\ #g; s#-#\\-#g'` 
    else
	PLUGINDIR=`echo "$prefix/lib"| sed -e 's#/#\\\/#g; s# #\\ #g; s#-#\\-#g'` 
    fi
fi

STOP_SERVER
START_SERVER

#
#  Check status
#
RUN $ISQL $DSN dba dba '"EXEC=status();"' VERBOSE=OFF PROMPT=OFF ERRORS=STDOUT
if test $STATUS -ne 0
then
  ECHO "***FAILED: status()"
  rm -f demo.db demo.trx demo.log demo.lck virtuoso.pxa
  exit 1
else
  ECHO "PASSED: status()"
fi

BREAK
ECHO "Collecting and installing VAD packages"

$LN $HOME/binsrc/b3s/fct_dav.vad .
$LN $HOME/binsrc/bpel/bpel_dav.vad .
$LN $HOME/binsrc/isparql/isparql_dav.vad .
$LN $HOME/binsrc/rdf_mappers/rdf_mappers_dav.vad .
$LN $HOME/binsrc/rdb2rdf/rdb2rdf_dav.vad .
$LN $HOME/binsrc/samples/sparql_demo/sparql_demo_dav.vad .
$LN $HOME/binsrc/tutorial/tutorial_dav.vad .
$LN $HOME/binsrc/yacutia/conductor_dav.vad .

[ -f conductor_dav.vad ] && DO_COMMAND "vad_install ('conductor_dav.vad')" dba dba
[ -f fct_dav.vad ] && DO_COMMAND "vad_install ('fct_dav.vad')" dba dba
[ -f doc_dav.vad ] && DO_COMMAND "vad_install ('doc_dav.vad')" dba dba
[ -f rdf_mappers_dav.vad ] && DO_COMMAND "vad_install ('rdf_mappers_dav.vad')" dba dba
[ -f rdb2rdf_dav.vad ] && DO_COMMAND "vad_install ('rdb2rdf_dav.vad')" dba dba
[ -f isparql_dav.vad ] && DO_COMMAND "vad_install ('isparql_dav.vad')" dba dba
[ -f bpel_dav.vad ] && DO_COMMAND "vad_install ('bpel_dav.vad')" dba dba
[ -f sparql_demo_dav.vad ] && DO_COMMAND "vad_install ('sparql_demo_dav.vad')" dba dba


#
#  OpenLink Data Spaces
#
if [ $VOS -eq 1 ]
then
    for f in `find $HOME/appsrc -name '*_dav.vad' -print`
    do
	$LN $f .
    done
    [ -f ods_framework_dav.vad ] && DO_COMMAND "vad_install ('ods_framework_dav.vad')" dba dba
    [ -f ods_addressbook_dav.vad ] && DO_COMMAND "vad_install ('ods_addressbook_dav.vad')" dba dba
    [ -f ods_blog_dav.vad ] && DO_COMMAND "vad_install ('ods_blog_dav.vad')" dba dba
    [ -f ods_bookmark_dav.vad ] && DO_COMMAND "vad_install ('ods_bookmark_dav.vad')" dba dba
    [ -f ods_briefcase_dav.vad ] && DO_COMMAND "vad_install ('ods_briefcase_dav.vad')" dba dba
    [ -f ods_calendar_dav.vad ] && DO_COMMAND "vad_install ('ods_calendar_dav.vad')" dba dba
    [ -f ods_community_dav.vad ] && DO_COMMAND "vad_install ('ods_community_dav.vad')" dba dba
    [ -f ods_discussion_dav.vad ] && DO_COMMAND "vad_install ('ods_discussion_dav.vad')" dba dba
    [ -f ods_feedmanager_dav.vad ] && DO_COMMAND "vad_install ('ods_feedmanager_dav.vad')" dba dba
    [ -f ods_gallery_dav.vad ] && DO_COMMAND "vad_install ('ods_gallery_dav.vad')" dba dba
    [ -f ods_polls_dav.vad ] && DO_COMMAND "vad_install ('ods_polls_dav.vad')" dba dba
    [ -f ods_webmail_dav.vad ] && DO_COMMAND "vad_install ('ods_webmail_dav.vad')" dba dba
    [ -f ods_wiki_dav.vad ] && DO_COMMAND "vad_install ('ods_wiki_dav.vad')" dba dba
fi

[ -f tutorial_dav.vad ] && DO_COMMAND "vad_install ('tutorial_dav.vad')" dba dba
[ -f demo_dav.vad ] && DO_COMMAND "vad_install ('demo_dav.vad')" dba dba

DO_COMMAND "delete from wa_domains where WD_DOMAIN = 'localhost'" dba dba

DO_COMMAND checkpoint
DO_COMMAND shutdown

BREAK

RUN egrep -q '"\*\*.*FAILED:|\*\*.*ABORTED:"' "$LOGFILE"
if test $STATUS -eq 0
then
	exit 1
fi

ECHO "Dump and restore the db to remove the free pages"

rm -f demo.trx 
chmod 644 demo.db

sleep 10

RUN "$SERVER" -b -f
if test $STATUS -ne 0
then
  ECHO "***FAILED: dump demo.db"
  rm -f demo.db demo.trx demo.log demo.lck virtuoso.pxa
  exit 1
else
  ECHO "PASSED: dump demo.db"
fi

rm -f demo.db 

RUN "$SERVER" -R -f
if test $STATUS -ne 0
then
  ECHO "***FAILED: restore demo.db"
  rm -f demo.db demo.trx demo.log demo.lck virtuoso.pxa
  exit 1
else
  ECHO "PASSED: restore demo.db"
fi



#
#  Show final results of run
#
CHECK_LOG
RUN egrep -q '"\*\*.*FAILED:|\*\*.*ABORTED:"' "$LOGFILE"
if test $STATUS -eq 0
then
	exit 1
fi

ECHO "Cleanups"
chmod 644 demo.db
rm -f demo.trx demo.log virtuoso.ini

BANNER "COMPLETED DEMO DATABASE (mkdemo.sh)"

exit 0