From ae1479386628436613a664b6601f6ca833dd6b2d Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 22 Dec 2006 00:16:19 +0000 Subject: [PATCH] Add MySQL skeleton --- Makefile | 1 + configDefault/mysql.cfg | 6 ++++++ configDefault/mysql.cfs | 1 + configDefault/mysql.csg | 6 ++++++ src/plugins/domtool-mysql | 13 +++++++++++++ src/plugins/mysql.sig | 23 +++++++++++++++++++++++ src/plugins/mysql.sml | 38 ++++++++++++++++++++++++++++++++++++++ src/sources | 3 +++ 8 files changed, 91 insertions(+) create mode 100644 configDefault/mysql.cfg create mode 100644 configDefault/mysql.cfs create mode 100644 configDefault/mysql.csg create mode 100755 src/plugins/domtool-mysql create mode 100644 src/plugins/mysql.sig create mode 100644 src/plugins/mysql.sml diff --git a/Makefile b/Makefile index 1f780a4..33f7683 100644 --- 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 src/plugins/domtool-mysql /usr/local/sbin/ .PHONY: grab_lib diff --git a/configDefault/mysql.cfg b/configDefault/mysql.cfg new file mode 100644 index 0000000..c199248 --- /dev/null +++ b/configDefault/mysql.cfg @@ -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 index 0000000..987609c --- /dev/null +++ b/configDefault/mysql.cfs @@ -0,0 +1 @@ +structure MySQL : MYSQL_CONFIG diff --git a/configDefault/mysql.csg b/configDefault/mysql.csg new file mode 100644 index 0000000..7a05d02 --- /dev/null +++ b/configDefault/mysql.csg @@ -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 index 0000000..9d02fc4 --- /dev/null +++ b/src/plugins/domtool-mysql @@ -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 | createdb ]" + ;; +esac diff --git a/src/plugins/mysql.sig b/src/plugins/mysql.sig new file mode 100644 index 0000000..9386c51 --- /dev/null +++ b/src/plugins/mysql.sig @@ -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 index 0000000..a273875 --- /dev/null +++ b/src/plugins/mysql.sml @@ -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 diff --git a/src/sources b/src/sources index f5043b5..44126a3 100644 --- a/src/sources +++ b/src/sources @@ -80,6 +80,9 @@ plugins/hcoop.sml plugins/postgres.sig plugins/postgres.sml +plugins/mysql.sig +plugins/mysql.sml + order.sig order.sml -- 2.20.1