Add MySQL skeleton
authorAdam Chlipala <adamc@hcoop.net>
Fri, 22 Dec 2006 00:16:19 +0000 (00:16 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Fri, 22 Dec 2006 00:16:19 +0000 (00:16 +0000)
Makefile
configDefault/mysql.cfg [new file with mode: 0644]
configDefault/mysql.cfs [new file with mode: 0644]
configDefault/mysql.csg [new file with mode: 0644]
src/plugins/domtool-mysql [new file with mode: 0755]
src/plugins/mysql.sig [new file with mode: 0644]
src/plugins/mysql.sml [new file with mode: 0644]
src/sources

index 1f780a4..33f7683 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -121,6 +121,7 @@ install:
        -cp bin/domtool-doc /usr/local/bin/
        -cp bin/dbtool /usr/local/bin/
        cp src/plugins/domtool-postgres /usr/local/sbin/
        -cp bin/domtool-doc /usr/local/bin/
        -cp bin/dbtool /usr/local/bin/
        cp src/plugins/domtool-postgres /usr/local/sbin/
+       cp src/plugins/domtool-mysql /usr/local/sbin/
 
 .PHONY: grab_lib
 
 
 .PHONY: grab_lib
 
diff --git a/configDefault/mysql.cfg b/configDefault/mysql.cfg
new file mode 100644 (file)
index 0000000..c199248
--- /dev/null
@@ -0,0 +1,6 @@
+structure MySQL :> MYSQL_CONFIG = struct
+
+val adduser = "/usr/bin/sudo /usr/local/sbin/domtool-mysql adduser "
+val createdb = "/usr/bin/sudo /usr/local/sbin/domtool-mysql createdb "
+
+end
diff --git a/configDefault/mysql.cfs b/configDefault/mysql.cfs
new file mode 100644 (file)
index 0000000..987609c
--- /dev/null
@@ -0,0 +1 @@
+structure MySQL : MYSQL_CONFIG
diff --git a/configDefault/mysql.csg b/configDefault/mysql.csg
new file mode 100644 (file)
index 0000000..7a05d02
--- /dev/null
@@ -0,0 +1,6 @@
+signature MYSQL_CONFIG = sig
+
+val adduser : string
+val createdb : string
+
+end
diff --git a/src/plugins/domtool-mysql b/src/plugins/domtool-mysql
new file mode 100755 (executable)
index 0000000..9d02fc4
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh -e
+
+case $1 in
+       adduser)
+               echo "I would create MySQL user $2."
+       ;;
+       createdb)
+               echo "I would create MySQL table $2_$3 for user $2."
+       ;;
+       *)
+               echo "Usage: domtool-mysql [adduser <user> | createdb <user> <table>]"
+       ;;
+esac
diff --git a/src/plugins/mysql.sig b/src/plugins/mysql.sig
new file mode 100644 (file)
index 0000000..9386c51
--- /dev/null
@@ -0,0 +1,23 @@
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *)
+
+(* MySQL user/table management *)
+
+signature MYSQL = sig
+
+end
diff --git a/src/plugins/mysql.sml b/src/plugins/mysql.sml
new file mode 100644 (file)
index 0000000..a273875
--- /dev/null
@@ -0,0 +1,38 @@
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *)
+
+(* MySQL user/table management *)
+
+structure MySQL :> MYSQL = struct
+
+fun adduser user =
+    if Slave.shell [Config.MySQL.adduser, user] then
+       NONE
+    else
+       SOME "Error executing CREATE USER script"
+
+fun createdb {user, dbname} =
+    if Slave.shell [Config.MySQL.createdb, user, " ", dbname] then
+       NONE
+    else
+       SOME "Error executing CREATE DATABASE script"
+
+val _ = Dbms.register ("mysql", {adduser = adduser,
+                                createdb = createdb})
+
+end
index f5043b5..44126a3 100644 (file)
@@ -80,6 +80,9 @@ plugins/hcoop.sml
 plugins/postgres.sig
 plugins/postgres.sml
 
 plugins/postgres.sig
 plugins/postgres.sml
 
+plugins/mysql.sig
+plugins/mysql.sml
+
 order.sig
 order.sml
 
 order.sig
 order.sml