summaryrefslogtreecommitdiff
path: root/deps/drassil
diff options
context:
space:
mode:
Diffstat (limited to 'deps/drassil')
-rw-r--r--deps/drassil/cmake-utils/.gitignore50
-rw-r--r--deps/drassil/cmake-utils/utils.cmake137
-rw-r--r--deps/drassil/mysql-tools/.gitignore13
-rw-r--r--deps/drassil/mysql-tools/README53
-rw-r--r--deps/drassil/mysql-tools/bin/dump-parserbin0 -> 13355 bytes
-rw-r--r--deps/drassil/mysql-tools/bin/mysql.exebin0 -> 4094976 bytes
-rw-r--r--deps/drassil/mysql-tools/bin/mysqldump.exebin0 -> 4079104 bytes
-rw-r--r--deps/drassil/mysql-tools/bin/mysqlimport.exebin0 -> 4013056 bytes
-rw-r--r--deps/drassil/mysql-tools/build-dump-parser.sh5
-rw-r--r--deps/drassil/mysql-tools/dump-parser.c129
-rw-r--r--deps/drassil/mysql-tools/mysql-config.dist62
-rw-r--r--deps/drassil/mysql-tools/mysql-dump119
-rw-r--r--deps/drassil/mysql-tools/mysql-import109
-rw-r--r--deps/drassil/mysql-tools/mysql-tools23
-rw-r--r--deps/drassil/mysql-tools/shared-def34
15 files changed, 734 insertions, 0 deletions
diff --git a/deps/drassil/cmake-utils/.gitignore b/deps/drassil/cmake-utils/.gitignore
new file mode 100644
index 0000000000..92da74b036
--- /dev/null
+++ b/deps/drassil/cmake-utils/.gitignore
@@ -0,0 +1,50 @@
+!.gitignore
+
+!*
+
+#
+#Generic
+#
+
+.directory
+.mailmap
+*.orig
+*.rej
+*~
+.hg/
+*.kdev*
+.DS_Store
+CMakeLists.txt.user
+*.bak
+*.patch
+*.diff
+*.REMOTE.*
+*.BACKUP.*
+*.BASE.*
+*.LOCAL.*
+
+#
+# IDE & other softwares
+#
+/.settings/
+/.externalToolBuilders/*
+# exclude in all levels
+nbproject/
+.sync.ffs_db
+*.kate-swp
+
+#
+# Eclipse
+#
+*.pydevproject
+.metadata
+.gradle
+tmp/
+*.tmp
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+.project
+.cproject
diff --git a/deps/drassil/cmake-utils/utils.cmake b/deps/drassil/cmake-utils/utils.cmake
new file mode 100644
index 0000000000..6c89684d67
--- /dev/null
+++ b/deps/drassil/cmake-utils/utils.cmake
@@ -0,0 +1,137 @@
+
+#
+# CU_SUBDIRLIST
+#
+FUNCTION(CU_SUBDIRLIST result curdir recursive includeRoot)
+ # glob recurse seem's doesn't work
+ FILE(GLOB children RELATIVE ${curdir} "${curdir}/[^\\.]*")
+ if (${includeRoot})
+ SET(dirlist "${curdir}")
+ else()
+ SET(dirlist "")
+ endif()
+
+ FOREACH(child ${children})
+ IF(IS_DIRECTORY "${curdir}/${child}")
+ if (${recursive})
+ CU_SUBDIRLIST(sub_Dirs "${curdir}/${child}" TRUE FALSE)
+ SET(dirlist "${curdir}/${child}" ${sub_Dirs} ${dirlist})
+ else()
+ SET(dirlist "${curdir}/${child}" ${dirlist})
+ endif()
+ ENDIF()
+ ENDFOREACH()
+ SET(${result} ${dirlist} PARENT_SCOPE)
+ENDFUNCTION(CU_SUBDIRLIST result curdir recursive)
+
+#
+# CU_SET_GLOBAL
+#
+MACRO(CU_SET_GLOBAL name val)
+ set_property ( GLOBAL PROPERTY ${name} ${val})
+ # after set , create the variable for current scope
+ CU_GET_GLOBAL(${name})
+ENDMACRO()
+
+MACRO(CU_ADD_GLOBAL name val)
+ CU_GET_GLOBAL(${name})
+
+ set_property ( GLOBAL PROPERTY ${name}
+ ${${name}}
+ ${val}
+ )
+ # after set , create the variable for current scope
+ CU_GET_GLOBAL(${name})
+ENDMACRO()
+
+#
+# CU_GET_GLOBAL
+#
+MACRO(CU_GET_GLOBAL name)
+ get_property(${name} GLOBAL PROPERTY ${name})
+ENDMACRO()
+
+#
+# CU_SET_CACHE
+#
+MACRO(CU_SET_CACHE name val)
+ set(${name} ${val} CACHE INTERNAL "CU Var")
+ENDMACRO()
+
+#
+# CU_LIST_ADD_CACHE
+#
+MACRO(CU_LIST_ADD_CACHE name val)
+
+ # avoid duplicates
+ if (";${${name}};" MATCHES ";${val};")
+ # nothing to do for now
+ else()
+ set(${name} ${val} ${${name}} CACHE INTERNAL "CU Var")
+ endif()
+ENDMACRO()
+
+
+#
+# CU_SET_PATH
+#
+MACRO(CU_SET_PATH name val)
+ CU_SET_CACHE(${name} ${val})
+
+ CU_ADD_INC_PATH(${val})
+ENDMACRO()
+
+#
+# CU_ADD_INC_PATH
+#
+MACRO(CU_ADD_INC_PATH val)
+
+ if (";${CU_INC_PATHS};" MATCHES ";${val};")
+ # nothing to do for now
+ else()
+ set(CU_INC_PATHS
+ ${CU_INC_PATHS}
+ ${val}
+ )
+
+ #update cache
+ CU_SET_CACHE("CU_INC_PATHS" "${CU_INC_PATHS}")
+ include_directories(${val})
+ endif()
+ENDMACRO()
+
+
+#
+# CU_LOAD_INC_PATHS
+#
+MACRO(CU_LOAD_INC_PATHS)
+ include_directories(${CU_INC_PATHS})
+ENDMACRO()
+
+#
+# CU_SET_PARENT
+#
+MACRO(CU_SET_PARENT name val)
+ set(${name} ${val} PARENT_SCOPE)
+ENDMACRO()
+
+
+MACRO(CU_ADD_HOOK hook_name value)
+ CU_ADD_GLOBAL(${hook_name} "${value}")
+ENDMACRO()
+
+MACRO(CU_RUN_HOOK hook_name)
+ CU_GET_GLOBAL(${hook_name})
+ message("Running cmake hook: ${hook_name}")
+ if (${hook_name})
+ set(HOOK_ARRAY ${${hook_name}})
+ FOREACH (hook_file ${HOOK_ARRAY})
+ message("Including ${hook_file}")
+ include("${hook_file}")
+ ENDFOREACH()
+ else()
+ message("No hooks registered for ${hook_name}")
+ endif()
+ENDMACRO()
+
+
diff --git a/deps/drassil/mysql-tools/.gitignore b/deps/drassil/mysql-tools/.gitignore
new file mode 100644
index 0000000000..fa1ea4671a
--- /dev/null
+++ b/deps/drassil/mysql-tools/.gitignore
@@ -0,0 +1,13 @@
+/mysql_config
+mysql_tools_(for usr-local-bin)
+
+#
+# Editors / debuggers / other output files
+#
+*~
+*.bak
+*.orig
+*.patch
+callgrind.out.*
+
+.upt.json
diff --git a/deps/drassil/mysql-tools/README b/deps/drassil/mysql-tools/README
new file mode 100644
index 0000000000..453829ce72
--- /dev/null
+++ b/deps/drassil/mysql-tools/README
@@ -0,0 +1,53 @@
+* Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+* GNU General Public License version 3; see www.hyperweb2.com/terms/
+
+#
+# HOW TO USE MYSQL_* tools
+#
+
+Before starting to dump/import, please rename mysql_config.dist in mysql_config and change infos using your configurations
+If you are using AppArmor , edit /etc/apparmor.d/usr.sbin.mysqld and add directory that must be used by the dump
+
+to easy dump/import the database, use ./mysql-tools command that includes dump and import scripts, instead if you need to separate the functions ,
+ use ./mysql-dump and ./mysql-import.
+
+mysql-tools utilization:
+
+# This script automatically dump and import sql files
+#
+# syntax: ./mysql_tools <opt> <database> <tables> <method> <configpath>
+# OPT -> dump/import ( export / import tables )
+# TABLES -> use "," to separate table names; ex: mysql_dump "" "table1,table2..tableN". Leave blank to dump all tables.
+# DATABASE -> specify database to process, use "" for default ( see in mysql-config )
+# METHOD -> 0/1 (0: no fulldb,1: use fulldb) default: ( see in mysql-config )
+# CONFIGPATH -> specify alternative path of config file, use "" to check in source folder
+#
+
+
+mysql-dump utilization:
+
+# This script will export all tables from specified db and tables in separated sql files
+# it can also export the full db in a single sql file.
+#
+# syntax: ./mysql_dump <database> <tables> <method> <configpath>
+# options are not required, because values can be defined in config file:
+# DATABASE -> specify database to dump, use "" for default ( see in mysql-config )
+# TABLES -> use "" to dump all tables. Use "," to separate table names; ex: mysql_dump "" "table1,table2..tableN"
+# METHOD -> 0/1 (0: no fulldb,1: with fulldb) default: ( see in mysql-config )
+# CONFIGPATH -> specify alternative path for config file, use "" to check in source folder.
+#
+
+
+mysql-import utilization:
+
+# This script will import the contents of the sql/ directory to the MySQL database.
+# You can choose to import table by table, or the entire db
+#
+# syntax: ./mysql_import <database> <tables> <method> <configpath>
+# options are not required, because values can be defined in config file:
+#
+# DATABASE -> specify database to dump, use "" for default ( see in mysql-config )
+# TABLES -> use "," to separate table names; ex: mysql_dump "" "table1,table2..tableN" ..OR use "" to dump all tables.
+# METHOD -> 1/0 ( 1: by folder, 0: by full dump) default: ( see in mysql-config )
+# CONFIGPATH -> specify alternative path for config file, use "" to check in source folder.
+#
diff --git a/deps/drassil/mysql-tools/bin/dump-parser b/deps/drassil/mysql-tools/bin/dump-parser
new file mode 100644
index 0000000000..6d07b528f1
--- /dev/null
+++ b/deps/drassil/mysql-tools/bin/dump-parser
Binary files differ
diff --git a/deps/drassil/mysql-tools/bin/mysql.exe b/deps/drassil/mysql-tools/bin/mysql.exe
new file mode 100644
index 0000000000..66267a989a
--- /dev/null
+++ b/deps/drassil/mysql-tools/bin/mysql.exe
Binary files differ
diff --git a/deps/drassil/mysql-tools/bin/mysqldump.exe b/deps/drassil/mysql-tools/bin/mysqldump.exe
new file mode 100644
index 0000000000..24355c07c3
--- /dev/null
+++ b/deps/drassil/mysql-tools/bin/mysqldump.exe
Binary files differ
diff --git a/deps/drassil/mysql-tools/bin/mysqlimport.exe b/deps/drassil/mysql-tools/bin/mysqlimport.exe
new file mode 100644
index 0000000000..8dc3613870
--- /dev/null
+++ b/deps/drassil/mysql-tools/bin/mysqlimport.exe
Binary files differ
diff --git a/deps/drassil/mysql-tools/build-dump-parser.sh b/deps/drassil/mysql-tools/build-dump-parser.sh
new file mode 100644
index 0000000000..a38a195f81
--- /dev/null
+++ b/deps/drassil/mysql-tools/build-dump-parser.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+gcc -O2 -Wall -pedantic dump-parser.c -o ./bin/dump-parser
+
+read -p "done"
diff --git a/deps/drassil/mysql-tools/dump-parser.c b/deps/drassil/mysql-tools/dump-parser.c
new file mode 100644
index 0000000000..a9262d4f92
--- /dev/null
+++ b/deps/drassil/mysql-tools/dump-parser.c
@@ -0,0 +1,129 @@
+/* gcc -O2 -Wall -pedantic dump-parser.c -o dump-parser
+ Usage: cat dump.sql | dump-parser
+ Or : dump-parser dump.sql
+ bugs :
+ * the parser will fail if the 10001st character of a line is an escaped quote, it will see it as an unescaped quote.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#define BUFFER 100000
+
+bool is_escaped(char* string, int offset) {
+ if (offset == 0) {
+ return false;
+ } else if (string[offset - 1] == '\\') {
+ return !is_escaped(string, offset - 1);
+ } else {
+ return false;
+ }
+}
+
+bool is_commented(char* string) {
+ char buffer[4];
+
+ sprintf(buffer, "%.3s", string);
+
+ return strcmp(buffer, "-- ") == 0;
+}
+
+int main(int argc, char *argv[])
+{
+ FILE* file = argc > 1 ? fopen(argv[1], "r") : stdin;
+
+ char buffer[BUFFER];
+ char* line;
+ int pos;
+ int parenthesis = 0;
+ bool quote = false;
+ bool escape = false;
+ bool comment = false;
+
+ while (fgets(buffer, BUFFER, file) != NULL) {
+ line = buffer;
+
+ /* skip commented */
+ if (comment || is_commented(line)) {
+ comment = line[strlen(line) - 1] != '\n';
+ fputs(line, stdout);
+ } else {
+ pos = 0;
+
+ nullchar:
+ while (line[pos] != '\0') {
+ /* if we are still in escape state, we need to check first char. */
+ if (!escape) {
+ /* find any character in ()' */
+ pos = strcspn(line, "()'\\");
+ }
+
+ if (pos > 0) {
+ /* print before match */
+ printf("%.*s", pos, line);
+ }
+
+ switch (line[pos]) {
+ case '(':
+ if (!quote) {
+ if (parenthesis == 0) {
+ putchar('\n');
+ }
+ parenthesis++;
+ }
+ if (escape) {
+ escape = false;
+ }
+ break;
+
+ case ')':
+ if (!quote) {
+ if (parenthesis > 0) {
+ parenthesis--;
+ } else {
+ /* whoops */
+ puts("\n");
+ fputs(line, stdout);
+ fputs("Found closing parenthesis without opening one.\n", stderr);
+ exit(1);
+ }
+ }
+ if (escape) {
+ escape = false;
+ }
+ break;
+
+ case '\\':
+ escape = !escape;
+ break;
+
+ case '\'':
+ if (escape) {
+ escape = false;
+ } else {
+ quote = !quote;
+ }
+ break;
+
+ case '\0':
+ goto nullchar;
+
+ default:
+ if (escape) {
+ escape = false;
+ }
+ break;
+ }
+
+ /* print char then skip it (to make sure we don’t double match) */
+ putchar(line[pos]);
+ line = line + pos + 1;
+ pos = 0;
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/deps/drassil/mysql-tools/mysql-config.dist b/deps/drassil/mysql-tools/mysql-config.dist
new file mode 100644
index 0000000000..ca71fc41ea
--- /dev/null
+++ b/deps/drassil/mysql-tools/mysql-config.dist
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+# * GNU General Public License version 3; see www.hyperweb2.com/terms/
+#
+# This file contains login/password information for accessing the MySQL database
+# and is used by all the mysql_* scripts.
+#
+
+#
+# MYSQL
+#
+
+# change these lines with your mysql config
+MYSQL_DB=test
+MYSQL_USER=usr
+MYSQL_PASS=pwd
+MYSQL_HOST=localhost
+#MYSQL_SOCK=/var/lib/mysql/mysql.sock
+
+#
+# File Options
+#
+
+# path of directory where extract separated tables ( without end slash )
+TPATH=./tables
+
+# (boolean) clean directory before dump, in this way non-existant db tables will be deleted
+CLEANFOLDER=1
+
+# path of file to extract database full dump
+FPATH=./full/full.sql
+
+# (boolean) switch to enable(1)/disable(0) the dump/import of full db file
+# ( you can do it manually using command parameters )
+FULL=0
+
+# (boolean) set 1 to enable --tab option for mysqldump and import data from it
+# it's very fast import/export process but doesn't utilize the insert query
+# NOTE: full db continue to be dumped with normal sql format
+# NOTE2: if you have problem with permissions ( mysql errorcode:13) mostly in linux
+# you should enable CHMODE config and disable/edit
+# some protections such as AppArmor in Ubuntu or SELinux in Fedora..
+
+TEXTDUMPS=1
+
+# (boolean) allow to change "TPATH" folder permissions to enable mysql server writing
+
+CHMODE=0
+
+
+#
+# TOOLS OPTIONS
+#
+
+#number of threads you want to use in TEXT import mode ( you can safely set it to your number of processor increasing process speed )
+THREADS=1
+
+IMPORTOPTS_TEXT="--use-threads=$THREADS --local --compress --delete --lock-tables"
+
+DUMPOPTS="--skip-comments --skip-set-charset --extended-insert --order-by-primary --single-transaction --quick"
+
diff --git a/deps/drassil/mysql-tools/mysql-dump b/deps/drassil/mysql-tools/mysql-dump
new file mode 100644
index 0000000000..33e5e35aca
--- /dev/null
+++ b/deps/drassil/mysql-tools/mysql-dump
@@ -0,0 +1,119 @@
+#!/bin/bash
+#
+# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+# * GNU General Public License version 3; see www.hyperweb2.com/terms/
+
+echo "starting dump process.."
+# check config from same folder and include only if exists
+CONF_FILE=$MT_DIR"/mysql-config"
+if [ -f "$CONF_FILE" ]; then
+ source "$CONF_FILE"
+fi;
+
+#overwrite configs if file exists and variables are defined
+if [ ! -z "$4" ]; then
+ if [ -e "$4" ]; then
+ source "$4"
+ else # if 4th parameter is not a file, then try to eval
+ eval "$4"
+ fi;
+fi;
+
+source $MT_DIR"/shared-def"
+
+if [ ! -z "$1" ]; then
+ MYSQL_DB=$1;
+fi
+
+#change group instead mod
+#group=`ls -l tables | awk '{print $4}'`
+#if [ $group != "mysql" ]; then
+# if (($CHMODE != 0)); then
+# sudo chgrp -v mysql $TPATH
+# fi
+#fi
+
+#change permissions for other users
+if [ ! -z $TPATH ]; then
+ if [ ! -d "$TPATH" ]; then
+ #create the path recursively
+ echo "creating dir: $TPATH.."
+ mkdir -p "$TPATH"
+ fi
+
+ if (($CHMODE != 0)); then
+ echo "changing permissions.."
+ sudo chmod -v o=rwx $TPATH
+ fi
+
+ #clean old tables
+ if (($CLEANFOLDER != 0)); then
+ rm -rvf $TPATH/*
+ fi
+
+ if [ ! -z "$2" ]; then
+ #if tables are specified in parameters then..
+ arr=$(echo $2 | tr "," "\n")
+
+ for T in $arr
+ do
+ echo "exporting "$T;
+ if (($TEXTDUMPS != 1)); then
+ FILE="$TPATH/$T.sql"
+ if [ -f $FILE ]; then
+ rm -f $FILE
+ fi
+
+ if (($PARSEDUMP != 0)); then
+ echo "Parsing enabled";
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' '$T' | $DUMPPARSER > $FILE"
+ else
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' '$T' -r $FILE"
+ fi
+ else
+ echo $(eval "$MYSQLDUMP$OPTS $DUMPOPTS --tab=$TPATH/ '$MYSQL_DB' '$T'")
+ fi
+ done
+
+ else
+ #else get all tables from selected db
+ CMD="$MYSQL$OPTS -N -B -e 'show tables from \`$MYSQL_DB\`'"
+ echo "command: "$CMD
+ for T in $(eval $CMD)
+ do
+ if (($TEXTDUMPS != 1)); then
+ echo "exporting "$T;
+ FILE="$TPATH/$T.sql"
+ if [ -f $FILE ]; then
+ rm -f $FILE
+ fi
+
+ if (($PARSEDUMP != 0)); then
+ echo "Parsing enabled on file "$FILE;
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' '$T' | $DUMPPARSER > $FILE"
+ else
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' '$T' -r $FILE"
+ fi
+ else
+ echo "exporting "$MYSQL_DB" tables: "$T;
+ echo $(eval "$MYSQLDUMP$OPTS $DUMPOPTS --tab=$TPATH/ '$MYSQL_DB' '$T'")
+ fi
+ done;
+
+ fi
+fi
+
+if [ ! -z "$3" ]; then FULL=$3; fi
+# export full file if option is enabled
+if (($FULL != 0)); then
+ echo 'exporting FULL '$MYSQL_DB' in single file';
+ rm -f $FPATH
+
+ if (($PARSEDUMP != 0)); then
+ echo "Parsing enabled";
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' | $DUMPPARSER > $FPATH"
+ else
+ eval "$MYSQLDUMP$OPTS $DUMPOPTS '$MYSQL_DB' -r $FPATH"
+ fi
+fi
+
diff --git a/deps/drassil/mysql-tools/mysql-import b/deps/drassil/mysql-tools/mysql-import
new file mode 100644
index 0000000000..ad05e1bd05
--- /dev/null
+++ b/deps/drassil/mysql-tools/mysql-import
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+# * GNU General Public License version 3; see www.hyperweb2.com/terms/
+
+echo "starting import process.."
+# check config from same folder and include only if exists
+CONF_FILE=$MT_DIR"/mysql-config"
+if [ -f "$CONF_FILE" ]; then
+ source "$CONF_FILE"
+fi;
+
+#overwrite configs if file exists and variables are defined
+if [ ! -z "$4" ]; then
+ if [ -e "$4" ]; then
+ source "$4"
+ else # if 4th parameter is not a file, then try to eval
+ eval "$4"
+ fi;
+fi;
+
+source $MT_DIR"/shared-def"
+
+if [ ! -z "$1" ]; then
+ MYSQL_DB=$1;
+fi
+
+# Table prefix ( to implement )
+PFX=
+
+# par 1 : db_name
+function checkdb {
+ # Check if database exists
+ err=`echo "quit" | $(eval "$MYSQL$OPTS '$1'") 2>&1`
+ if [ $? != 0 ]; then
+ if echo "$err" | grep -q "Access denied"; then
+ echo -e "\nDATABASE $1 EXISTS BUT USER $MYSQL_USER DOES NOT HAVE ACCESS TO IT, ABORTING"
+ exit
+ fi
+ echo -n "[creating $1]"
+ if ! echo "CREATE DATABASE $1;" | $(eval "$MYSQL$OPTS" ) 2>/dev/null ; then
+ echo -e "\nDATABASE $1 DOES NOT EXIST AND I FAILED TO CREATE IT, ABORTING"
+ exit
+ fi
+ fi
+}
+
+#par1: is_text_file ; par2: file
+function import
+{
+ echo "Importing $2 into $MYSQL_DB (text: $1) ..."
+
+ SQL="SET FOREIGN_KEY_CHECKS = 0;"
+ #eval "$MYSQL$OPTS -e \"SET FOREIGN_KEY_CHECKS = 0\" '$MYSQL_DB'" #disable foreign check
+
+ FILE=$2
+ if (($1 != 0)); then
+ #eval "$MYSQLIMPORT$OPTS $IMPORTOPTS_TEXT '$MYSQL_DB' $2"
+ TABLE=${FILE##*/}
+ TABLE=${TABLE%.txt}
+ SQL+="LOAD DATA LOCAL INFILE '$2' INTO TABLE $MYSQL_DB.$TABLE;"
+ else
+ #eval "$MYSQL$OPTS '$MYSQL_DB'" < "$2"
+ SQL+="SOURCE $2;"
+ fi
+ #eval "$MYSQL$OPTS -e \"SET FOREIGN_KEY_CHECKS = 1\" '$MYSQL_DB'" #enable foreign check
+ SQL+="SET FOREIGN_KEY_CHECKS = 1";
+
+ eval "$MYSQL$OPTS -e \"$SQL\" '$MYSQL_DB'"
+
+ echo " done"
+}
+
+if [ ! -z "$1" ]; then
+ DB=$1;
+fi
+
+checkdb $MYSQL_DB
+
+if [ ! -z "$2" ]; then
+ tables=$(echo $2 | tr "," "\n")
+fi
+if [ ! -z "$3" ]; then
+ FULL=$3;
+fi
+
+if (($FULL != 0)); then
+ echo "importing full world file"
+ $(eval "$MYSQL$OPTS '$MYSQL_DB'") < $FPATH
+else
+ if [ ! -z "$2" ]; then
+ import "0" "$TPATH/$2.sql" # TODO we should check if it's a set of tables before
+ if (($TEXTDUMPS != 0)); then
+ for x in $TPATH/*.txt; do
+ import "1" "$x"
+ done
+ fi
+ else
+ for x in $TPATH/*.sql; do
+ import "0" "$x"
+ done
+
+ if (($TEXTDUMPS != 0)); then
+ for x in $TPATH/*.txt; do
+ import "1" "$x"
+ done
+ fi
+ fi
+fi
diff --git a/deps/drassil/mysql-tools/mysql-tools b/deps/drassil/mysql-tools/mysql-tools
new file mode 100644
index 0000000000..6f2fad77c6
--- /dev/null
+++ b/deps/drassil/mysql-tools/mysql-tools
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+# * GNU General Public License version 3; see www.hyperweb2.com/terms/
+
+MT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+function main {
+ if [ ! -z "$1" ]; then
+ if [ "$1" == "dump" ]; then
+ source $MT_DIR"/mysql-dump" "$3" "$2" "$4" "$5"
+ return
+ elif [ "$1" == "import" ]; then
+ source $MT_DIR"/mysql-import" "$3" "$2" "$4" "$5"
+ return
+ fi
+ else
+ echo "!!no command specified!!"
+ fi
+}
+
+# OPT - Tables - database - full file - config path
+main "$1" "$2" "$3" "$4" "$5"
diff --git a/deps/drassil/mysql-tools/shared-def b/deps/drassil/mysql-tools/shared-def
new file mode 100644
index 0000000000..6742fcf3b8
--- /dev/null
+++ b/deps/drassil/mysql-tools/shared-def
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# * Copyright (C) 2007 - 2015 Hyperweb2 All rights reserved.
+# * GNU General Public License version 3; see www.hyperweb2.com/terms/
+
+MYSQL="mysql"
+MYSQLIMPORT="mysqlimport"
+MYSQLDUMP="mysqldump"
+DUMPPARSER=$MT_DIR"/bin/dump-parser"
+
+#empty for bash commands
+WIN_BIN=0
+command -v mysql >/dev/null 2>&1 || { WIN_BIN=1; }
+command -v mysqlimport >/dev/null 2>&1 || { WIN_BIN=1; }
+command -v mysqldump >/dev/null 2>&1 || { WIN_BIN=1; }
+
+WIN_BIN=1
+if [ `uname -s` == "Linux" ]; then
+ WIN_BIN=0
+else
+ WIN_BIN=1
+fi;
+
+if (($WIN_BIN != 0)); then
+ MYSQL=$MT_DIR"/bin/$MYSQL"
+ MYSQLIMPORT=$MT_DIR"/bin/$MYSQLIMPORT"
+ MYSQLDUMP=$MT_DIR"/bin/$MYSQLDUMP"
+fi;
+
+OPTS=
+[ ! -z "$MYSQL_USER" ] && OPTS+=" -u $MYSQL_USER"
+[ ! -z "$MYSQL_PASS" ] && OPTS+=" -p$MYSQL_PASS"
+[ ! -z "$MYSQL_HOST" ] && OPTS+=" -h $MYSQL_HOST"
+[ ! -z "$MYSQL_SOCK" ] && OPTS+=" -S $MYSQL_SOCK"