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

Annotation of /chewbacca/YodaProfiler/docs/install_DB.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Fri Apr 23 13:16:39 2010 UTC (14 years, 7 months ago) by pam-fi
Branch: MAIN
CVS Tags: v10RED, HEAD
Changes since 1.1: +28 -0 lines
File MIME type: application/x-sh
(M. Bongi) Added install_GPAMELADB_rotrasl.sh script to install the database forGPAMELA with geometry modified according to the flight alignment parameters ("rotrasl" version, after 23rd April 2010)

1 mocchiut 1.1 #!/bin/bash --norc
2     THISDIR=`pwd`
3     USERNAME=${PAM_DBUSER}
4     HOST=""
5     DBNAME=""
6     FORCE="no"
7     GPAMELA="no"
8 pam-fi 1.2 GPAMELAROTRASL="no"
9 mocchiut 1.1 COUNT=0;for word in `echo ${PAM_DBHOST} | tr [\/] [" "] |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
10     PASSWORD=${PAM_DBPSW}
11     if [ $# -gt 0 ]; then
12     for INPUT in $*; do
13     if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then
14     echo ""
15     echo " Usage: ./install_DB.sh [options] "
16     echo ""
17     echo " Options: "
18     echo ""
19     echo " --user=username : MySQL username. "
20     echo ""
21     echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name."
22     echo ""
23     echo " --psw=password : MySQL password"
24     echo ""
25     echo " --force : do not wait [default: wait]"
26     echo ""
27     exit 0
28     fi
29     TEST=`echo $INPUT | sed 's/--user=//g'`
30     if [ $TEST != $INPUT ]; then
31     USERNAME=`echo $TEST`
32     export USERNAME;
33     fi
34     TEST=`echo $INPUT | sed 's/--host=//g'`
35     if [ $TEST != $INPUT ]; then
36     COUNT=0;for word in `echo $TEST | tr [\/] [" "] | 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
37     export DBNAME;
38     export HOST;
39     fi
40     TEST=`echo $INPUT | sed 's/--psw=//g'`
41     if [ $TEST != $INPUT ]; then
42     PASSWORD=`echo $TEST`
43     export PASSWORD;
44     fi
45     if [ "$INPUT" == "--force" ]; then
46     FORCE="yes";
47     export FORCE;
48     fi
49     if [ "$INPUT" == "--gpamela" ]; then
50     GPAMELA="yes";
51     export GPAMELA;
52     fi
53 pam-fi 1.2 if [ "$INPUT" == "--gpamela-rotrasl" ]; then
54     GPAMELAROTRASL="yes";
55     export GPAMELAROTRASL;
56     fi
57 mocchiut 1.1 done
58     else
59     if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then
60     echo ""
61     echo " Usage: ./install_DB.sh [options] "
62     echo ""
63     echo " Options: "
64     echo ""
65     echo " --user=username : MySQL username. "
66     echo ""
67     echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name."
68     echo ""
69     echo " --psw=password : MySQL password"
70     echo ""
71     exit 0
72     fi
73     fi;
74     echo ""
75     echo " Installing DB $DBNAME on $HOST with user $USERNAME and password $PASSWORD "
76     echo ""
77     if [ "$FORCE" == "no" ]; then
78     echo " WARNING: if already existing the DB will be RECREATED and you will LOSE all data! "
79     echo ""
80     echo " =======> You have 30 seconds to stop me using CTRL+c <======= "
81     echo ""
82     sleep 30;
83     fi;
84     #
85     rm -rf ${THISDIR}/temp.sql
86     #
87     cat ${THISDIR}/PAMELAProductionDB.sql | sed 's/dbname/'${DBNAME}'/g' >> ${THISDIR}/temp.sql
88     mysql --user=$USERNAME --password=$PASSWORD --host=$HOST < ${THISDIR}/temp.sql
89     echo " done! "
90     #
91     #
92     #
93     if [ "$GPAMELA" == "yes" ]; then
94     echo ""
95     echo " Adapting GL_PARAM table to be used with simulated data "
96     echo ""
97     #
98     rm -rf ${THISDIR}/temp.sql
99     #
100     cat ${THISDIR}/GP_PARAM.sql | sed 's/dbname/'${DBNAME}'/g' >> ${THISDIR}/temp.sql
101     mysql --user=$USERNAME --password=$PASSWORD --host=$HOST < ${THISDIR}/temp.sql
102     #
103     echo " done! "
104     fi;
105     #
106     echo ""
107     rm -rf ${THISDIR}/temp.sql
108 pam-fi 1.2 #
109     #
110     if [ "$GPAMELAROTRASL" == "yes" ]; then
111     echo ""
112     echo " Adapting GL_PARAM table to be used with simulated data (\"rotrasl\" version)"
113     echo ""
114     #
115     rm -rf ${THISDIR}/temp.sql
116     #
117     cat ${THISDIR}/GP_PARAM_rotrasl.sql | sed 's/dbname/'${DBNAME}'/g' >> ${THISDIR}/temp.sql
118     mysql --user=$USERNAME --password=$PASSWORD --host=$HOST < ${THISDIR}/temp.sql
119     #
120     echo " done! "
121     fi;
122     #
123     echo ""
124     rm -rf ${THISDIR}/temp.sql
125    
126    
127    
128    
129    
130    

  ViewVC Help
Powered by ViewVC 1.1.23