aboutsummaryrefslogtreecommitdiffstats
path: root/mayor/update/processUpdateScripts.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mayor/update/processUpdateScripts.sh')
-rw-r--r--mayor/update/processUpdateScripts.sh69
1 files changed, 41 insertions, 28 deletions
diff --git a/mayor/update/processUpdateScripts.sh b/mayor/update/processUpdateScripts.sh
index 47fbb23e..fb54ab8f 100644
--- a/mayor/update/processUpdateScripts.sh
+++ b/mayor/update/processUpdateScripts.sh
@@ -6,22 +6,31 @@ source $BASEDIR/update/linkme.sh
echo -e "[mysqld]
character-set-server = utf8
collation-server = utf8_hungarian_ci
-skip-character-set-client-handshake
[client]
+default-character-set=utf8
host=$MYSQL_HOST
user=$MYSQL_USER
password=$MYSQL_PW
" > $BASEDIR/config/my.cnf
+
+PRECHARSET="SET character_set_client = utf8;
+SET character_set_database = utf8;
+SET character_set_server = utf8;
+SET character_set_results = utf8;
+SET collation_connection = utf8_hungarian_ci;
+SET collation_database = utf8_general_ci;
+SET collation_server = utf8_general_ci; " ## fontos, hogy a ";" ott legyen a végén!!
+
MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf"
MYSQL_PARAMETERS=""
-TEST=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null`
+TEST=$($MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null)
if [ $? == "0" ]; then
echo "SQL-connect test #2 OK"
MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW"
else
echo "Hibás SQL csatlakozás(2)"
fi
-TEST=`$MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null`
+TEST=$($MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null)
if [ $? == "0" ]; then
echo "SQL-connect test #1 OK"
MYSQL_PARAMETERS=$MYSQL_CONFIG
@@ -31,8 +40,12 @@ fi
echo "Karakterkódolás ellenőrzése"
echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS
# patch by Acsai Gabor <acsi@c3.hu> - FreeBSD
-TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "`
-if [ "x${TEST}" == "x1" ]; then
+# Kiegészítve: Miklós Gergő <gergo@bmrg.hu> - Baár-Madas
+# gondolatmenet:
+# A "default-character-set" beállítása után a "character_set_client" változóból 1db kell legyen, és értéke pontosan "utf8" kell legyen!
+### TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "`
+TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_PARAMETERS | tail -n+2 | cut -f 2)
+if [ "$TEST" == "utf8" ]; then
echo "SQL-UTF8 test OK"
else
echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n"
@@ -42,7 +55,7 @@ fi
# --
run_script() {
- FILEELEJE=`echo $FILE | cut -f 1 -d '-'`
+ FILEELEJE=$(echo $FILE | cut -f 1 -d '-')
FILEREV=${FILEELEJE: -6}
LOGSQL=""
if [ "$FILEREV" != "" ]; then
@@ -51,14 +64,14 @@ run_script() {
fi
fi
if [ ! "${FILEREV}" \< "${REVSTR}" ]; then
- FILEEXT=`echo $FILE | cut -f 2 -d '.'`
+ FILEEXT=$(echo $FILE | cut -f 2 -d '.')
if [ "$FILEEXT" == "sh" ]; then
echo " - Szkript futtatása ($FILE)..."
. $FILE
if [ $? != 0 ]; then exit 13; fi
elif [ "$FILEEXT" == "sql" ]; then
echo " - SQL utasítások végrehajtása ($FILE)..."
- FILEDB=`echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-'`
+ FILEDB=$(echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-')
case "$FILEDB" in
naplo)
DBS=$DB_NAPLO
@@ -78,7 +91,7 @@ run_script() {
if [ "$FILEREV" != "" ]; then
if [ "$FILEREV" -gt 3399 ]; then
- TEST=`echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'" | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db"`
+ TEST=$((echo $PRECHARSET && echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'") | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db")
if [ "$TEST" == "0" ]; then
echo " Hiányzik a mayorUpdateLog tábla... tovább..."
continue
@@ -88,21 +101,21 @@ run_script() {
case "$FILEDB" in
naplo)
- INTEZMENYDB=`echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/'`
- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'`
- TANEV=`echo $DB | cut -f 3 -d '_'`
- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \
+ INTEZMENYDB=$(echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/')
+ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_')
+ TANEV=$(echo $DB | cut -f 3 -d '_')
+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \
sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB
;;
auth)
- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB
+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB
;;
intezmeny)
- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'`
- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB
+ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_')
+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB
;;
*)
- (cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB
+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB
;;
esac
if [ $? != 0 ]; then
@@ -116,8 +129,8 @@ run_script() {
echo " Az új változat verziószáma: $UJ_REV"
-REVSTR=`printf "%06d" $REV`
-MYSQL_ENCODE_STR=`grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/"`
+REVSTR=$(printf "%06d" $REV)
+MYSQL_ENCODE_STR=$(grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/")
# mysql host beállítása
if [ "$MYSQL_HOST" == "" ]; then
@@ -129,9 +142,9 @@ echo " Figyelem! MySQL Master-Slave architekturát az upgrade script jelenleg
echo -e "\n * Adatbázisok lekérdezése..."
if [ -f $MYSQL ]
then
- DB_MAYOR=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$'`
- DB_NAPLO=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$'`
- DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$'`
+ DB_MAYOR=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$') ## ide elvileg nem kellene precharset, mert itt minden ASCCI/2
+ DB_NAPLO=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$')
+ DB_INTEZMENY=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$')
# DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'`
if [ $? != 0 ]; then exit 12; fi
DB_AUTH=""
@@ -153,7 +166,7 @@ if [ "$SKIPLOCK" != "1" ]; then
echo "kész."
echo -n " - Aktív munkamenetek törlése... "
- $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session"
+ $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ##itt se kell, jó az ASCII
echo "kész."
fi
else
@@ -161,7 +174,7 @@ else
fi
echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n"
-for FILE in `ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort`; do
+for FILE in $(ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort); do
run_script
done
@@ -175,8 +188,8 @@ if [ "$EXECONLY" != "1" ]; then
else
# Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum
if [ -f $TMPDIR/md5sum ]; then
- MOD=`echo $MODULE | sed "s#/#-#"`
- FILE=`grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3`
+ MOD=$(echo $MODULE | sed "s#/#-#")
+ FILE=$(grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3)
if [ -f $TMPDIR/$FILE ]; then
tar xfz $TMPDIR/$FILE -C $BASEDIR
if [ $? != 0 ]; then exit 13; fi
@@ -189,7 +202,7 @@ if [ "$EXECONLY" != "1" ]; then
fi
echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n"
-for FILE in `ls $UPDATEDIR/post* | sort`; do
+for FILE in $(ls $UPDATEDIR/post* | sort); do
run_script
done
@@ -219,7 +232,7 @@ if [ "$EXECONLY" != "1" ]; then
for POLICY in $POLICIES; do
eval "LIST=\$${POLICY}Link"
for f in $LIST; do
- DIR=`echo $f | cut -d / -f 1-2`
+ DIR=$(echo $f | cut -d / -f 1-2)
if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then
echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR"
mkdir -p $BASEDIR/www/policy/$POLICY/$DIR