From 44025c667ef0661dc10699adbd299f84f6105b97 Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Tue, 14 Jul 2015 15:05:02 -0400 Subject: [PATCH 1/2] Script Cleanup Added the ability to specify custom database name. Added the ability to specify custom table prefix. Created sub folders for operating systems. --- servatrice/scripts/info_db_tablesize | 3 --- servatrice/scripts/{ => linux}/db_backup_all | 0 servatrice/scripts/{ => linux}/db_restore_all | 0 servatrice/scripts/linux/info_db_tablesize | 8 ++++++++ servatrice/scripts/linux/maint_inactiveaccounts | 9 +++++++++ servatrice/scripts/linux/maint_logs | 9 +++++++++ servatrice/scripts/linux/maint_replays | 8 ++++++++ servatrice/scripts/linux/maint_sessions | 9 +++++++++ servatrice/scripts/linux/setup_addfirstadmin | 8 ++++++++ servatrice/scripts/maint_logs | 4 ---- servatrice/scripts/maint_removeinactiveplayeraccounts | 4 ---- servatrice/scripts/maint_replays | 4 ---- servatrice/scripts/maint_sessions | 4 ---- servatrice/scripts/setup_addfirstadmin | 4 ---- 14 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 servatrice/scripts/info_db_tablesize rename servatrice/scripts/{ => linux}/db_backup_all (100%) rename servatrice/scripts/{ => linux}/db_restore_all (100%) create mode 100644 servatrice/scripts/linux/info_db_tablesize create mode 100644 servatrice/scripts/linux/maint_inactiveaccounts create mode 100644 servatrice/scripts/linux/maint_logs create mode 100644 servatrice/scripts/linux/maint_replays create mode 100644 servatrice/scripts/linux/maint_sessions create mode 100644 servatrice/scripts/linux/setup_addfirstadmin delete mode 100644 servatrice/scripts/maint_logs delete mode 100644 servatrice/scripts/maint_removeinactiveplayeraccounts delete mode 100644 servatrice/scripts/maint_replays delete mode 100644 servatrice/scripts/maint_sessions delete mode 100644 servatrice/scripts/setup_addfirstadmin diff --git a/servatrice/scripts/info_db_tablesize b/servatrice/scripts/info_db_tablesize deleted file mode 100644 index a558155e..00000000 --- a/servatrice/scripts/info_db_tablesize +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -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 = "servatrice" ORDER BY (data_length + index_length) DESC;' diff --git a/servatrice/scripts/db_backup_all b/servatrice/scripts/linux/db_backup_all similarity index 100% rename from servatrice/scripts/db_backup_all rename to servatrice/scripts/linux/db_backup_all diff --git a/servatrice/scripts/db_restore_all b/servatrice/scripts/linux/db_restore_all similarity index 100% rename from servatrice/scripts/db_restore_all rename to servatrice/scripts/linux/db_restore_all diff --git a/servatrice/scripts/linux/info_db_tablesize b/servatrice/scripts/linux/info_db_tablesize new file mode 100644 index 00000000..29b5e1b9 --- /dev/null +++ b/servatrice/scripts/linux/info_db_tablesize @@ -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;' diff --git a/servatrice/scripts/linux/maint_inactiveaccounts b/servatrice/scripts/linux/maint_inactiveaccounts new file mode 100644 index 00000000..9e77176c --- /dev/null +++ b/servatrice/scripts/linux/maint_inactiveaccounts @@ -0,0 +1,9 @@ +#!/bin/bash + +# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD UNACTIVE ACCOUNT SHOULD BE REMOVED. UPDATE INTERVAL DATE TO BE NUMBER OF DAYS OLD (OR OLDER) TO REMOVE. + +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);" \ No newline at end of file diff --git a/servatrice/scripts/linux/maint_logs b/servatrice/scripts/linux/maint_logs new file mode 100644 index 00000000..4e5a43e4 --- /dev/null +++ b/servatrice/scripts/linux/maint_logs @@ -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)' diff --git a/servatrice/scripts/linux/maint_replays b/servatrice/scripts/linux/maint_replays new file mode 100644 index 00000000..bee3d0b0 --- /dev/null +++ b/servatrice/scripts/linux/maint_replays @@ -0,0 +1,8 @@ +#!/bin/bash + +# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD REPLAYS SHOULD BE SAVED UNTIL (EX: SCHEDULE ONCE A WEEK TO KEEP A WEEKS WORTH OF REPLAYS IN THE DB) + +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 'truncate table ""$DBNAME"".""$TABLEPREFIX""_replays;truncate table ""$DBNAME"".""$TABLEPREFIX""_replays_access' diff --git a/servatrice/scripts/linux/maint_sessions b/servatrice/scripts/linux/maint_sessions new file mode 100644 index 00000000..28d49b03 --- /dev/null +++ b/servatrice/scripts/linux/maint_sessions @@ -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)" diff --git a/servatrice/scripts/linux/setup_addfirstadmin b/servatrice/scripts/linux/setup_addfirstadmin new file mode 100644 index 00000000..abbaddcf --- /dev/null +++ b/servatrice/scripts/linux/setup_addfirstadmin @@ -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) values (1,'servatrice','jbB4kSWDmjaVzMNdU13n73SpdBCJTCJ/JYm5ZBZvfxlzbISbXir+e/aSvMz86KzOoaBfidxO0s6GVd8t00qC0TNPl+udHfECaF7MsA==',1);" diff --git a/servatrice/scripts/maint_logs b/servatrice/scripts/maint_logs deleted file mode 100644 index c218ff36..00000000 --- a/servatrice/scripts/maint_logs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -#SCHEDULE WITH CRONTAB AND ADJUST THE INTERVALS FOR THE NUMBER OF DAYS OF LOGS TO KEEP IN THE DATABASE -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_log where log_time < DATE_SUB(now(), INTERVAL 10 DAY)' diff --git a/servatrice/scripts/maint_removeinactiveplayeraccounts b/servatrice/scripts/maint_removeinactiveplayeraccounts deleted file mode 100644 index 75b2775f..00000000 --- a/servatrice/scripts/maint_removeinactiveplayeraccounts +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD UNACTIVE ACCOUNT SHOULD BE REMOVED. UPDATE INTERVAL DATE TO BE NUMBER OF DAYS OLD (OR OLDER) TO REMOVE. -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_users where registrationDate < DATE_SUB(now(), INTERVAL 5 DAY) AND active = 0'; diff --git a/servatrice/scripts/maint_replays b/servatrice/scripts/maint_replays deleted file mode 100644 index 22f6c097..00000000 --- a/servatrice/scripts/maint_replays +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD REPLAYS SHOULD BE SAVED UNTIL (EX: SCHEDULE ONCE A WEEK TO KEEP A WEEKS WORTH OF REPLAYS IN THE DB) -SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file -mysql --defaults-file=$SQLCONFFILE -h localhost -e 'truncate table servatrice.cockatrice_replays;truncate table servatrice.cockatrice_replays_access' diff --git a/servatrice/scripts/maint_sessions b/servatrice/scripts/maint_sessions deleted file mode 100644 index 69e531ce..00000000 --- a/servatrice/scripts/maint_sessions +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# SCHEDULE WITH CRONTAB TO RUN ONCE A MONTH -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_sessions where start_time < DATE_SUB(now(), INTERVAL 1 MONTH)" diff --git a/servatrice/scripts/setup_addfirstadmin b/servatrice/scripts/setup_addfirstadmin deleted file mode 100644 index 17c2d881..00000000 --- a/servatrice/scripts/setup_addfirstadmin +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# SCRIPT TO ADD THE FIRST ADMIN USER NAMED SERVATRICE WITH THE PASSWORD OF PASSWORD -SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file -mysql --defaults-file=$SQLCONFFILE -h localhost -e "insert into servatrice.cockatrice_users (admin,name,password_sha512,active) values (1,'servatrice','jbB4kSWDmjaVzMNdU13n73SpdBCJTCJ/JYm5ZBZvfxlzbISbXir+e/aSvMz86KzOoaBfidxO0s6GVd8t00qC0TNPl+udHfECaF7MsA==',1);" From 795c05257f831da74be54620e67247aba116d577 Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Tue, 14 Jul 2015 15:10:25 -0400 Subject: [PATCH 2/2] Inactive accounts script description update Updated description in script to clarify things. --- servatrice/scripts/linux/maint_inactiveaccounts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servatrice/scripts/linux/maint_inactiveaccounts b/servatrice/scripts/linux/maint_inactiveaccounts index 9e77176c..29446356 100644 --- a/servatrice/scripts/linux/maint_inactiveaccounts +++ b/servatrice/scripts/linux/maint_inactiveaccounts @@ -1,9 +1,9 @@ #!/bin/bash -# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD UNACTIVE ACCOUNT SHOULD BE REMOVED. UPDATE INTERVAL DATE TO BE NUMBER OF DAYS OLD (OR OLDER) TO REMOVE. +# 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);" \ No newline at end of file +mysql --defaults-file=$SQLCONFFILE -h localhost -e "delete from ""$DBNAME"".""$TABLEPREFIX""_users where active = 0 AND registrationDate < DATE_SUB(now(), INTERVAL ""$NUMBEROFDAYS"" DAY);"