3 # define your database name here, will be overriden by
4 # FIRST command line argument if given
6 # define your database usernamename here, will be overriden by
7 # SECOND command line argument if given
9 # define your database password here, will be overriden by
10 # THIRD command line argument if given
12 # set your PHP5 bin dir path here, if it's not in PATH
13 # The path should be terminated with dir separator!
16 # ==========================================================
17 # No changes below, please.
18 # ==========================================================
20 CALLEDPATH
=`dirname $0`
22 if [ "$1" == '-h' ] ||
[ "$1" == '--help' ]; then
23 echo; echo Usage
: setup.sh
[database name
] [database user
] [database password
]; echo
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
33 # verify if we have at least DBNAME given
34 if [ -z $DBNAME ] ; then
35 echo "No database name defined!"
38 if [ -z $DBUSER ] ; then
39 echo "No database username defined!"
42 if [ -z $DBPASS ] ; then
43 read -p "Database password:"
47 # run code generator if it's there - which means it's
48 # checkout, not packaged code
49 if [ -d $CALLEDPATH/..
/xml
]; then
51 "$PHP5PATH"php GenCode.php
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
59 PASSWDSECTION
="-p$DBPASS"
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
70 mysql
-u $DBUSER $PASSWDSECTION $DBNAME < civicrm_data.mysql
72 mysql
-u $DBUSER $PASSWDSECTION $DBNAME < zipcodes.mysql
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