/[PAMELA software]/YodaProfiler/docs/install_DB.sh
ViewVC logotype

Contents of /YodaProfiler/docs/install_DB.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu Sep 7 08:34:19 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
File MIME type: application/x-sh
First release of the new profiler

1 #!/bin/bash --norc
2 THISDIR=`pwd`
3 USERNAME=${PAM_DBUSER}
4 HOST=""
5 DBNAME=""
6 COUNT=0;for word in `echo ${PAM_DBHOST} | tr [\/] [" "] |sed 's/mysql://g' `; do if [ $COUNT -eq 0 ]; then HOST=`echo $word`; fi; if [ $COUNT -eq 1 ]; then DBNAME=`echo $word`; fi; let COUNT=$COUNT+1; done
7 PASSWORD=${PAM_DBPSW}
8 if [ $# -gt 0 ]; then
9 I=1
10 while [ $I -le $# ]; do
11 if [ $I -eq 1 ]; then
12 INPUT=$1
13 fi
14 if [ $I -eq 2 ]; then
15 INPUT=$2
16 fi
17 if [ $I -eq 3 ]; then
18 INPUT=$3
19 fi
20 if [ $I -eq 4 ]; then
21 INPUT=$4
22 fi
23 if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then
24 echo ""
25 echo " Usage: ./install_DB.sh [options] "
26 echo ""
27 echo " Options: "
28 echo ""
29 echo " --user=username : MySQL username. "
30 echo ""
31 echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name."
32 echo ""
33 echo " --psw=password : MySQL password"
34 echo ""
35 exit 0
36 fi
37 TEST=`echo $INPUT | sed 's/--user=//g'`
38 if [ $TEST != $INPUT ]; then
39 USERNAME=`echo $TEST`
40 export USERNAME;
41 fi
42 TEST=`echo $INPUT | sed 's/--host=//g'`
43 if [ $TEST != $INPUT ]; then
44 COUNT=0;for word in `echo $TEST | tr [\/] [" "] |sed 's/mysql://g' `; do if [ $COUNT -eq 0 ]; then HOST=`echo $word`; fi; if [ $COUNT -eq 1 ]; then DBNAME=`echo $word`; fi; let COUNT=$COUNT+1; done
45 export DBNAME;
46 export HOST;
47 fi
48 TEST=`echo $INPUT | sed 's/--psw=//g'`
49 if [ $TEST != $INPUT ]; then
50 PASSWORD=`echo $TEST`
51 export PASSWORD;
52 fi
53 let I=$I+1
54 done
55 else
56 if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then
57 echo ""
58 echo " Usage: ./install_GL_PARAM.sh [options] "
59 echo ""
60 echo " Options: "
61 echo ""
62 echo " --user=username : MySQL username. "
63 echo ""
64 echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name."
65 echo ""
66 echo " --psw=password : MySQL password"
67 echo ""
68 exit 0
69 fi
70 fi;
71 echo ""
72 echo " Installing DB $DBNAME on $HOST with user $USERNAME and password $PASSWORD "
73 echo ""
74 echo " WARNING: if already existing the DB will be RECREATED and you will LOSE all data! "
75 echo ""
76 echo " =======> You have 30 seconds to stop me using CTRL+c <======= "
77 echo ""
78 sleep 30;
79 #
80 rm -rf ${THISDIR}/temp.sql
81 #
82 cat ${THISDIR}/PAMELAProductionDB.sql | sed 's/dbname/'${DBNAME}'/g' >> ${THISDIR}/temp.sql
83 mysql --user=$USERNAME --password=$PASSWORD --host=$HOST < ${THISDIR}/temp.sql
84 echo " done! "
85 echo ""
86 rm -rf ${THISDIR}/temp.sql

  ViewVC Help
Powered by ViewVC 1.1.23