Initial commit of mtgonline project
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
SLEEPTIME=5
|
||||
SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file
|
||||
LOGAPPENDDATE=`date +%m%d%Y`
|
||||
EXPIRATION=`date +%m%d%Y -d "-3 days"`
|
||||
DBNAME="servatrice"
|
||||
APPNAME="servatrice"
|
||||
ROOTFOLDER="./backups" #set this to the root path you want backups to be stored in
|
||||
BACKUPDIR="$ROOTFOLDER/$LOGAPPENDDATE/db/$APPNAME"
|
||||
TABLES=(
|
||||
"cockatrice_users"
|
||||
"cockatrice_decklist_files"
|
||||
"cockatrice_replays"
|
||||
"cockatrice_buddylist"
|
||||
"cockatrice_ignorelist"
|
||||
"cockatrice_bans"
|
||||
"cockatrice_sessions"
|
||||
"cockatrice_decklist_folders"
|
||||
"cockatrice_replays_access"
|
||||
"cockatrice_games"
|
||||
"cockatrice_games_players"
|
||||
"cockatrice_uptime"
|
||||
"cockatrice_schema_version"
|
||||
"cockatrice_servermessages"
|
||||
"cockatrice_servers"
|
||||
"cockatrice_rooms"
|
||||
"cockatrice_rooms_gametypes"
|
||||
)
|
||||
|
||||
PROCESSNAME="mysqldump"
|
||||
if [ "$(pgrep $PROCESSNAME)" == "" ];
|
||||
then
|
||||
[ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/
|
||||
for TABLENAME in "${TABLES[@]}"
|
||||
do
|
||||
BACKUPFILE="$BACKUPDIR/$APPNAME.$TABLENAME.sql.$LOGAPPENDDATE"
|
||||
echo "Backing up DB Table [$TABLENAME]"
|
||||
ionice -c3 nice -n19 mysqldump --defaults-file=$SQLCONFFILE $DBNAME $TABLENAME > $BACKUPFILE
|
||||
sleep $SLEEPTIME
|
||||
done
|
||||
rm -rf "$ROOTFOLDER/$EXPIRATION/"
|
||||
else
|
||||
echo "Backup in progress, aborting"
|
||||
fi
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
SLEEPTIME=5
|
||||
SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file
|
||||
LOGAPPENDDATE=`date +%m%d%Y`
|
||||
EXPIRATION=`date +%m%d%Y -d "-3 days"`
|
||||
DBNAME="servatrice"
|
||||
APPNAME="servatrice"
|
||||
ROOTFOLDER="./backups" #set this to the root path that contains the backup files
|
||||
BACKUPDIR="$ROOTFOLDER/$LOGAPPENDDATE/db/$APPNAME"
|
||||
TABLES=(
|
||||
"cockatrice_users"
|
||||
"cockatrice_decklist_files"
|
||||
"cockatrice_replays"
|
||||
"cockatrice_buddylist"
|
||||
"cockatrice_ignorelist"
|
||||
"cockatrice_bans"
|
||||
"cockatrice_sessions"
|
||||
"cockatrice_decklist_folders"
|
||||
"cockatrice_replays_access"
|
||||
"cockatrice_games"
|
||||
"cockatrice_games_players"
|
||||
"cockatrice_uptime"
|
||||
"cockatrice_schema_version"
|
||||
"cockatrice_servermessages"
|
||||
"cockatrice_servers"
|
||||
"cockatrice_rooms"
|
||||
"cockatrice_rooms_gametypes"
|
||||
)
|
||||
|
||||
PROCESSNAME="mysqldump"
|
||||
if [ "$(pgrep $PROCESSNAME)" == "" ];
|
||||
then
|
||||
[ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/
|
||||
for TABLENAME in "${TABLES[@]}"
|
||||
do
|
||||
BACKUPFILE="$BACKUPDIR/$APPNAME.$TABLENAME.sql.$LOGAPPENDDATE"
|
||||
if [ -f "$BACKUPFILE" ]
|
||||
then
|
||||
echo "Restoring up DB Table [$TABLENAME]"
|
||||
ionice -c3 nice -n19 mysql --defaults-file=$SQLCONFFILE $DBNAME < $BACKUPFILE
|
||||
sleep $SLEEPTIME
|
||||
else
|
||||
echo "Missing backup file [$$TABLENAME]"
|
||||
sleep $SLEEPTIME
|
||||
fi
|
||||
done
|
||||
rm -rf "$ROOTFOLDER/$EXPIRATION/"
|
||||
else
|
||||
echo "Restore in progress, aborting"
|
||||
fi
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
#USE THIS SCRIPT TO IDENTIFY THE SIZE OF YOUR TABLES IN THE DATABASE
|
||||
|
||||
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
|
||||
mysql --defaults-file=$SQLCONFFILE -e 'SELECT table_name AS "Tables", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "'$DBNAME'" ORDER BY (data_length + index_length) DESC;'
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/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
|
||||
|
||||
if [ "$MODE" == "correct" ]; then
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e "update ""$DBNAME"".""$TABLEPREFIX""_users set country = lower(country);"
|
||||
fi
|
||||
|
||||
echo "INVALID: $INVALIDCOUNT"
|
||||
echo "VALID: $VALIDCOUNT"
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SCHEDULE WITH CRONTAB ON A REGULAR BASIS. NUMBER OF DAYS IS THE AMOUNT OF DAYS TO KEEP INACTIVE ACCOUNTS (EX: 1 DAY REMOVES ALL INACTIVE ACCOUNTS OLDER THAN A SINGLE DAY).
|
||||
|
||||
DBNAME="servatrice" #set this to the database name used
|
||||
TABLEPREFIX="cockatrice" #set this to the prefix used for the table names with in the database
|
||||
SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file
|
||||
NUMBEROFDAYS=5 #set this to the number of days to search for
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e "delete from ""$DBNAME"".""$TABLEPREFIX""_users where active = 0 AND registrationDate < DATE_SUB(now(), INTERVAL ""$NUMBEROFDAYS"" DAY);"
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
#SCHEDULE WITH CRONTAB AND ADJUST THE INTERVALS FOR THE NUMBER OF DAYS OF LOGS TO KEEP IN THE DATABASE
|
||||
|
||||
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
|
||||
NUMBEROFDAYS=10 #set this to the number of days desired
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e 'delete from ""$DBNAME"".""$TABLEPREFIX""_log where log_time < DATE_SUB(now(), INTERVAL ""$NUMBEROFDAYS"" DAY)'
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SCHEDULE WITH CRONTAB TO RUN ON A REGULAR BASIS
|
||||
|
||||
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
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e "update ""$DBNAME"".""$TABLEPREFIX""_users set privlevel = 'NONE' where privelevel != 'NONE" AND privlevelEndDate < NOW()"
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SCHEDULE WITH CRONTAB DAILY
|
||||
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
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e 'delete from servatrice.cockatrice_games where time_finished < DATE_SUB(now(), INTERVAL 8 DAY)'
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SCHEDULE WITH CRONTAB TO RUN ON A REGULAR BASIS
|
||||
|
||||
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
|
||||
NUMBEROFDAYS=10 #set this to the number of days desired
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e "delete from ""$DBNAME"".""$TABLEPREFIX""_sessions where start_time < DATE_SUB(now(), INTERVAL ""$NUMBEROFDAYS"" DAY)"
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SCRIPT TO ADD THE FIRST ADMIN USER NAMED SERVATRICE WITH THE PASSWORD OF PASSWORD
|
||||
|
||||
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
|
||||
mysql --defaults-file=$SQLCONFFILE -h localhost -e "insert into ""$DBNAME"".""$TABLEPREFIX""_users ((admin,name,password_sha512,active,realname,email,country,avatar_bmp,registrationDate,clientID,adminnotes,privlevelStartDate,privlevelEndDate) values (1,'servatrice','jbB4kSWDmjaVzMNdU13n73SpdBCJTCJ/JYm5ZBZvfxlzbISbXir+e/aSvMz86KzOoaBfidxO0s6GVd8t00qC0TNPl+udHfECaF7MsA==',1,'servatrice','servatrice@localhost','us','null.bmp','1970-01-01 10:00:00','','','1970-01-01 10:00:00','9999-01-01 10:00:00');
|
||||
Reference in New Issue
Block a user