From 33c861af09aa7a8758716b16c12b7085c2c6283a Mon Sep 17 00:00:00 2001 From: startxfr Date: Fri, 5 Dec 2014 19:19:40 +0100 Subject: fin des modifications sur le template mariadb --- Services/mariadb/sx/mariadb.sh | 10 +++++++--- Services/mariadb/sx/mariadb_run.sh | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Services/mariadb/sx') diff --git a/Services/mariadb/sx/mariadb.sh b/Services/mariadb/sx/mariadb.sh index af6124b..5b2857d 100644 --- a/Services/mariadb/sx/mariadb.sh +++ b/Services/mariadb/sx/mariadb.sh @@ -88,11 +88,11 @@ function update_rootuser { # Find all sqlfiles in /tmp/ and import then using admin user function import_sqlfiles { - local filedir=$1; local p=$MARIADB_ROOTPWD; + local filedir=$1; local p=$MARIADB_ROOTPWD; local del=$2; if [ "$(ls -1 $filedir | wc -l)" -ge "1" ]; then echo "=> Found SQL files to import ..." for filename in "$filedir"; do - import_sqlfile $filename + import_sqlfile $filename $del done; fi; return 0 @@ -100,10 +100,14 @@ function import_sqlfiles { # Find all sqlfiles in /tmp/ and import then using admin user function import_sqlfile { - local filename=$1; local p=$MARIADB_ROOTPWD; + local filename=$1; local p=$MARIADB_ROOTPWD; local del=$2; if [ -f "$filename" ]; then echo "===> Importing sql file : $filename" mysql -u root -p$p < $filename + if [ "$del" = "delete"]; then + rm -f $filename + echo "====> Deleting $filename after import" + fi; else echo "====> Could not find sql file $filename. Skip import..." fi; diff --git a/Services/mariadb/sx/mariadb_run.sh b/Services/mariadb/sx/mariadb_run.sh index 07a4c03..7dcf9b2 100644 --- a/Services/mariadb/sx/mariadb_run.sh +++ b/Services/mariadb/sx/mariadb_run.sh @@ -2,7 +2,6 @@ source /sx/mariadb.sh begin_config - ## if you wan't to add a new user with database #create_userdb 'dbuser1' 'password' ## if you wan't to add a new user with database (generated password) @@ -15,8 +14,8 @@ begin_config #mysql -u root -p$MARIADB_ROOTPWD -e 'select user, host FROM mysql.user;' ## Execute SQL scripts located into a directory #import_sqlfiles /tmp/sql/*.sql -## Execute a single SQL script -#import_sqlfile /tmp/sql/example.sql - +## Execute a single SQL script and delete it +#import_sqlfile /tmp/sql/example.sql delete end_config + start_daemon \ No newline at end of file -- cgit v1.2.3