/[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.3 - (show annotations) (download) (as text)
Fri Oct 20 11:11:10 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
CVS Tags: v2r01, v2r00
Changes since 1.2: +14 -5 lines
File MIME type: application/x-sh
GL_RESURS_OFFSET changed, added _RUNID_GEN table, unique run ID number implemented

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

  ViewVC Help
Powered by ViewVC 1.1.23