Import from SVN (r45945, r596)
[civicrm-core.git] / tools / bin / scripts / runStressTest.sh.txt
1 #!/usr/bin/env bash
2
3 # define your database name here, will be overriden by
4 # FIRST command line argument if given
5 DBNAME=
6 # define your database usernamename here, will be overriden by
7 # SECOND command line argument if given
8 DBUSER=
9 # define your database password here, will be overriden by
10 # THIRD command line argument if given
11 DBPASS=
12 # set your PHP5 bin dir path here, if it's not in PATH
13 # The path should be terminated with dir separator!
14 PHP5PATH=
15
16 # ==========================================================
17 # No changes below, please.
18 # ==========================================================
19
20 CALLEDPATH=`dirname $0`
21
22 if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
23 echo; echo Usage: setup.sh [database name] [database user] [database password]; echo
24 exit 0
25 fi
26
27
28 # fetch command line arguments if available
29 if [ ! -z $1 ] ; then DBNAME=$1; fi
30 if [ ! -z $2 ] ; then DBUSER=$2; fi
31 if [ ! -z $3 ] ; then DBPASS=$3; fi
32
33 # verify if we have at least DBNAME given
34 if [ -z $DBNAME ] ; then
35 echo "No database name defined!"
36 exit 1
37 fi
38 if [ -z $DBUSER ] ; then
39 echo "No database username defined!"
40 exit 1
41 fi
42 if [ -z $DBPASS ] ; then
43 read -p "Database password:"
44 DBPASS=$REPLY
45 fi
46
47 # run code generator if it's there - which means it's
48 # checkout, not packaged code
49 if [ -d $CALLEDPATH/../xml ]; then
50 cd $CALLEDPATH/../xml
51 "$PHP5PATH"php GenCode.php
52 fi
53
54 # someone might want to use empty password for development,
55 # let's make it possible - we asked before.
56 if [ -z $DBPASS ]; then # password still empty
57 PASSWDSECTION=""
58 else
59 PASSWDSECTION="-p$DBPASS"
60 fi
61
62 cd $CALLEDPATH/../sql
63 echo; echo Dropping $DBNAME database
64 mysqladmin -f -u $DBUSER $PASSWDSECTION drop $DBNAME
65 echo; echo Creating $DBNAME database
66 mysqladmin -f -u $DBUSER $PASSWDSECTION create $DBNAME
67 echo; echo Creating database structure
68 mysql -u $DBUSER $PASSWDSECTION $DBNAME < civicrm.mysql
69
70 mysql -u $DBUSER $PASSWDSECTION $DBNAME < civicrm_data.mysql
71
72 mysql -u $DBUSER $PASSWDSECTION $DBNAME < zipcodes.mysql
73 cd ../test/RSTest/
74 php Run.php
75
76 echo; echo "DONE!"
77
78 # to generate a new data file do the foll:
79 # mysqladmin -f -uYourDBUser -pYourDBPassword drop YourDBName
80 # mysqladmin -f -uYourDBUser -pYourDBPassword create YourDBName
81 # mysql -uYourDBUser -pYourDBPassword YourDBName < civicrm.mysql
82 # mysql -uYourDBUser -pYourDBPassword YourDBName < civicrm_data.mysql
83 # mysql -uYourDBUser -pYourDBPassword YourDBName < zipcodes.mysql
84 # php GenerateContactData.php
85 # echo "drop table zipcodes" | mysql -uYourDBUser -pYourDBPassword YourDBName
86 # mysqldump -t -n -uYourDBUser -pYourDBPassword YourDBName > GeneratedData.sql