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