3 |
USERNAME=${PAM_DBUSER} |
USERNAME=${PAM_DBUSER} |
4 |
HOST="" |
HOST="" |
5 |
DBNAME="" |
DBNAME="" |
6 |
|
FORCE="no" |
7 |
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 |
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 |
8 |
PASSWORD=${PAM_DBPSW} |
PASSWORD=${PAM_DBPSW} |
9 |
if [ $# -gt 0 ]; then |
if [ $# -gt 0 ]; then |
10 |
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 |
|
11 |
if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then |
if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then |
12 |
echo "" |
echo "" |
13 |
echo " Usage: ./install_GL_PARAM.sh [options] " |
echo " Usage: ./install_GL_PARAM.sh [options] " |
20 |
echo "" |
echo "" |
21 |
echo " --psw=password : MySQL password" |
echo " --psw=password : MySQL password" |
22 |
echo "" |
echo "" |
23 |
|
echo " --force : do not wait [default: wait]" |
24 |
|
echo "" |
25 |
exit 0 |
exit 0 |
26 |
fi |
fi |
27 |
TEST=`echo $INPUT | sed 's/--user=//g'` |
TEST=`echo $INPUT | sed 's/--user=//g'` |
40 |
PASSWORD=`echo $TEST` |
PASSWORD=`echo $TEST` |
41 |
export PASSWORD; |
export PASSWORD; |
42 |
fi |
fi |
43 |
let I=$I+1 |
if [ "$INPUT" == "--force" ]; then |
44 |
|
FORCE="yes"; |
45 |
|
export FORCE; |
46 |
|
fi |
47 |
done |
done |
48 |
else |
else |
49 |
if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then |
if [ "$USERNAME" == "" ] || [ "$HOST" == "" ] || [ "$DBNAME" == "" ]; then |
63 |
fi; |
fi; |
64 |
echo "" |
echo "" |
65 |
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) " |
|
66 |
echo "" |
echo "" |
67 |
sleep 30; |
if [ "$FORCE" == "no" ]; then |
68 |
|
echo " WARNING: if already existing the GL_PARAM table will be RECREATED and you will LOSE all data in that table! " |
69 |
|
echo "" |
70 |
|
echo " =======> You have 30 seconds to stop me using CTRL+c <======= " |
71 |
|
echo "" |
72 |
|
sleep 30; |
73 |
|
fi; |
74 |
echo " Updating GL_PARAM table" |
echo " Updating GL_PARAM table" |
75 |
# |
# |
76 |
rm -rf ${THISDIR}/temp.sql |
rm -rf ${THISDIR}/temp.sql |
86 |
echo "" |
echo "" |
87 |
echo "GL_PARAM TABLE NOW CONTAINS:" |
echo "GL_PARAM TABLE NOW CONTAINS:" |
88 |
echo "" |
echo "" |
89 |
echo "select * from GL_PARAM;" > ${THISDIR}/temp.sql |
echo "SET time_zone='+0:00';" > ${THISDIR}/temp.sql |
90 |
|
echo "select * from GL_PARAM;" >> ${THISDIR}/temp.sql |
91 |
mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql |
mysql --user=$USERNAME --password=$PASSWORD --host=$HOST $DBNAME < ${THISDIR}/temp.sql |
92 |
echo "" |
echo "" |
93 |
echo "Please check that path and names are correct." |
echo "Please check that path and names are correct." |