/[PAMELA software]/DarthVader/docs/install_GL_PARAM.sh
ViewVC logotype

Diff of /DarthVader/docs/install_GL_PARAM.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mocchiut, Thu Sep 7 08:50:38 2006 UTC revision 1.5 by mocchiut, Tue Apr 17 11:58:39 2007 UTC
# Line 3  THISDIR=`pwd` Line 3  THISDIR=`pwd`
3  USERNAME=${PAM_DBUSER}  USERNAME=${PAM_DBUSER}
4  HOST=""  HOST=""
5  DBNAME=""  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  FORCE="no"
7    STATIC="no"
8    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
9  PASSWORD=${PAM_DBPSW}  PASSWORD=${PAM_DBPSW}
10  if [ $# -gt 0 ]; then  if [ $# -gt 0 ]; then
11      I=1      for INPUT in $*; do
     while [ $I -le $# ]; do  
         if [ $I -eq 1 ]; then  
             INPUT=$1  
         fi  
         if [ $I -eq 2 ]; then  
             INPUT=$2  
         fi  
         if [ $I -eq 3 ]; then  
             INPUT=$3  
         fi  
         if [ $I -eq 4 ]; then  
             INPUT=$4  
         fi  
12          if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then          if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then
13              echo ""              echo ""
14              echo " Usage: ./install_GL_PARAM.sh [options] "              echo " Usage: ./install_GL_PARAM.sh [options] "
# Line 32  if [ $# -gt 0 ]; then Line 21  if [ $# -gt 0 ]; then
21              echo ""              echo ""
22              echo " --psw=password :  MySQL password"              echo " --psw=password :  MySQL password"
23              echo ""              echo ""
24                echo " --force :  do not wait [default: wait]"          
25                echo ""
26                echo " --static :  use static path instead of symbolic ones ($PAM_CALIB) [default: no]"        
27                echo ""
28              exit 0              exit 0
29          fi          fi
30          TEST=`echo $INPUT | sed 's/--user=//g'`          TEST=`echo $INPUT | sed 's/--user=//g'`
# Line 41  if [ $# -gt 0 ]; then Line 34  if [ $# -gt 0 ]; then
34          fi          fi
35          TEST=`echo $INPUT | sed 's/--host=//g'`          TEST=`echo $INPUT | sed 's/--host=//g'`
36          if [ $TEST != $INPUT  ]; then          if [ $TEST != $INPUT  ]; then
37              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              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
38              export DBNAME;              export DBNAME;
39              export HOST;              export HOST;
40          fi          fi
# Line 50  if [ $# -gt 0 ]; then Line 43  if [ $# -gt 0 ]; then
43              PASSWORD=`echo $TEST`              PASSWORD=`echo $TEST`
44              export PASSWORD;              export PASSWORD;
45          fi          fi
46          let I=$I+1          if [ "$INPUT" == "--force" ]; then
47                FORCE="yes";
48                export FORCE;
49            fi
50            if [ "$INPUT" == "--static" ]; then
51                STATIC="yes";
52                export STATIC;
53            fi
54      done      done
55  else  else
56      if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then      if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then
# Line 70  else Line 70  else
70  fi;  fi;
71  echo ""  echo ""
72  echo " Updating GL_PARAM table on DB $DBNAME, $HOST with user $USERNAME and password $PASSWORD "  echo " Updating GL_PARAM table on DB $DBNAME, $HOST with user $USERNAME and password $PASSWORD "
 echo "               (you have 30 seconds to stop me using CTRL+c)       "  
73  echo ""  echo ""
74  sleep 30;  if [ "$FORCE" == "no" ]; then
75        echo " WARNING: if already existing the GL_PARAM table will be RECREATED and you will LOSE all data in that table! "
76        echo ""
77        echo "    =======>   You have 30 seconds to stop me using CTRL+c  <=======    "
78        echo ""
79        sleep 30;
80    fi;
81  echo " Updating GL_PARAM table"  echo " Updating GL_PARAM table"
82  #  #
83  rm -rf ${THISDIR}/temp.sql  rm -rf ${THISDIR}/temp.sql
# Line 81  PAM_CALIB2=$(echo $PAM_CALIB | sed 's/\/ Line 86  PAM_CALIB2=$(echo $PAM_CALIB | sed 's/\/
86  echo "delete from GL_PARAM;" > ${THISDIR}/temp.sql  echo "delete from GL_PARAM;" > ${THISDIR}/temp.sql
87  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql
88  #  #
89  cat ${THISDIR}/install_GL_PARAM.sql | sed 's/fullpathgoesere/'${PAM_CALIB2}'/g' >> ${THISDIR}/temp.sql  if [ "$STATIC" == "no" ]; then
90        cat ${THISDIR}/install_GL_PARAM.sql | sed 's/fullpathgoesere/$PAM_CALIB/g' >> ${THISDIR}/temp.sql
91    else
92        cat ${THISDIR}/install_GL_PARAM.sql | sed 's/fullpathgoesere/'${PAM_CALIB2}'/g' >> ${THISDIR}/temp.sql
93    fi;    
94  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql
95  #  #
96  echo " done! "  echo " done! "
97  echo ""  echo ""
98  echo "GL_PARAM TABLE NOW CONTAINS:"  echo "GL_PARAM TABLE NOW CONTAINS:"
99  echo ""  echo ""
100  echo "select * from GL_PARAM;" > ${THISDIR}/temp.sql  echo "SET time_zone='+0:00';" > ${THISDIR}/temp.sql
101    echo "select * from GL_PARAM;" >> ${THISDIR}/temp.sql
102  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql  mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql
103  echo ""  echo ""
104  echo "Please check that path and names are correct."  echo "Please check that path and names are correct."

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23