1 |
#!/bin/bash --norc |
#!/bin/bash --norc |
2 |
THISDIR=`pwd` |
THISDIR=`pwd` |
3 |
USERNAME="" |
USERNAME=${PAM_DBUSER} |
4 |
HOST="" |
HOST="" |
5 |
DBNAME="" |
DBNAME="" |
6 |
PASSWORD="" |
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 |
7 |
if [ $# -gt 0 ] && [ $# -le 4 ]; then |
PASSWORD=${PAM_DBPSW} |
8 |
|
if [ $# -gt 0 ]; then |
9 |
I=1 |
I=1 |
10 |
while [ $I -le $# ]; do |
while [ $I -le $# ]; do |
11 |
if [ $I -eq 1 ]; then |
if [ $I -eq 1 ]; then |
41 |
fi |
fi |
42 |
TEST=`echo $INPUT | sed 's/--host=//g'` |
TEST=`echo $INPUT | sed 's/--host=//g'` |
43 |
if [ $TEST != $INPUT ]; then |
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 |
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 |
45 |
export DBNAME; |
export DBNAME; |
46 |
export HOST; |
export HOST; |
47 |
fi |
fi |
53 |
let I=$I+1 |
let I=$I+1 |
54 |
done |
done |
55 |
else |
else |
56 |
echo "" |
if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then |
57 |
echo " Usage: ./install_GL_PARAM.sh [options] " |
echo "" |
58 |
echo "" |
echo " Usage: ./install_GL_PARAM.sh [options] " |
59 |
echo " Options: " |
echo "" |
60 |
echo "" |
echo " Options: " |
61 |
echo " --user=username : MySQL username. " |
echo "" |
62 |
echo "" |
echo " --user=username : MySQL username. " |
63 |
echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name." |
echo "" |
64 |
echo "" |
echo " --host=mysql://localhost/pamelaprod : MySQL host and DB name." |
65 |
echo " --psw=password : MySQL password" |
echo "" |
66 |
echo "" |
echo " --psw=password : MySQL password" |
67 |
exit 0 |
echo "" |
68 |
|
exit 0 |
69 |
|
fi |
70 |
fi; |
fi; |
71 |
|
echo "" |
72 |
|
echo " Updating GL_PARAM table on DB $DBNAME, $HOST with user $USERNAME and password $PASSWORD " |
73 |
|
echo " (you have 30 seconds to stop me using CTRL+c) " |
74 |
|
echo "" |
75 |
|
sleep 30; |
76 |
|
echo " Updating GL_PARAM table" |
77 |
# |
# |
78 |
rm -rf ${THISDIR}/temp.sql |
rm -rf ${THISDIR}/temp.sql |
79 |
PAM_CALIB2=$(echo $PAM_CALIB | sed 's/\//\\\//g') |
PAM_CALIB2=$(echo $PAM_CALIB | sed 's/\//\\\//g') |
84 |
cat ${THISDIR}/install_GL_PARAM.sql | sed 's/fullpathgoesere/'${PAM_CALIB2}'/g' >> ${THISDIR}/temp.sql |
cat ${THISDIR}/install_GL_PARAM.sql | sed 's/fullpathgoesere/'${PAM_CALIB2}'/g' >> ${THISDIR}/temp.sql |
85 |
mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql |
mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql |
86 |
# |
# |
87 |
|
echo " done! " |
88 |
echo "" |
echo "" |
89 |
echo "GL_PARAM TABLE NOW CONTAINS:" |
echo "GL_PARAM TABLE NOW CONTAINS:" |
90 |
echo "" |
echo "" |