Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
bf230f2c
Commit
bf230f2c
authored
Aug 11, 2015
by
Zach
Browse files
Merge pull request #1366 from woogerboy21/add_script_maintcountrycodes
Add script to validate/clear invalid country codes in the DB.
parents
e9478ff9
f636c0ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
servatrice/scripts/linux/maint_countrycodes
0 → 100644
View file @
bf230f2c
#!/bin/bash
# THIS SCRIPT EXPECTS TO BE EXECUTED FROM THE GITHUB SOURCE FOLDER PATH STRUCTURE
# OTHERWISE, UPDATE THE 'COUNTRYCODEIMAGEPATH' TO POINT TO THE FOLDER CONTAINING THE COUNTRY CODE IMAGES
# USE THIS SCRIPT TO COMPARE EXISTING USER ACCOUNTS TO VALID COUNTRY CODES AND CLEAR INVALID COUNTRY CODE DATA
MODE
=
"report"
#set this to correct to fix invalid country codes, otherwise it only reports
DBNAME
=
"servatrice"
#set this to the database name used
TABLEPREFIX
=
"cockatrice"
#set this to the prefix used for the table names in the database (do not inclue the _)
SQLCONFFILE
=
"./mysql.cnf"
#set this to the path that contains the mysql.cnf file
COUNTRYCODEIMAGEPATH
=
'../../../cockatrice/resources/countries'
VALIDCOUNT
=
0
INVALIDCOUNT
=
0
for
i
in
`
mysql
--defaults-file
=
$SQLCONFFILE
-h
localhost
-e
"select distinct(country) from ""
$DBNAME
"".""
$TABLEPREFIX
""_users;"
`
do
if
[
"
$i
"
!=
"country"
]
;
then
if
[
-f
"
$COUNTRYCODEIMAGEPATH
/
$i
.svg"
]
;
then
((
VALIDCOUNT++
))
else
((
INVALIDCOUNT++
))
if
[
"
$MODE
"
==
"correct"
]
;
then
echo
"
$i
COUNTRY CODE INVALID, ATTEMPTING TO CORRECT"
mysql
--defaults-file
=
$SQLCONFFILE
-h
localhost
-e
"update ""
$DBNAME
"".""
$TABLEPREFIX
""_users set country = '' where country = '
$i
';"
fi
fi
fi
done
echo
"INVALID:
$INVALIDCOUNT
"
echo
"VALID:
$VALIDCOUNT
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment