Specifying encoding on database creation
[hcoop/domtool2.git] / src / plugins / domtool-mysql
index f476482..49363b1 100755 (executable)
@@ -35,11 +35,28 @@ case $1 in
                chmod 770 $DIR/$DBNAME
                ln -sf $DIR/$DBNAME /var/lib/mysql/$DBNAME
                fs setacl -dir $DIR/$DBNAME/ -acl system:mysql all
+               sudo -H mysql -e "GRANT CREATE,CREATE TEMPORARY TABLES,SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE VIEW,SHOW VIEW,LOCK TABLES,GRANT OPTION ON TABLE * TO '$USERNAME'@$WHERE;" $DBNAME
 
-               sudo -H mysql -e "GRANT CREATE,SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE VIEW,SHOW VIEW,GRANT OPTION ON TABLE * TO '$USERNAME'@$WHERE;" $DBNAME
                sudo -H mysql -e "FLUSH PRIVILEGES;"
        ;;
+
+       dropdb)
+               USERNAME=$2
+               DBNAME_BASE=$3
+               DBNAME="${USERNAME}_${DBNAME_BASE}"
+
+               sudo -H mysql -e "DROP DATABASE $DBNAME;"
+       ;;
+
+       grant)
+               USERNAME=$2
+               DBNAME_BASE=$3
+               DBNAME="${USERNAME}_${DBNAME_BASE}"
+
+               sudo -H mysql -e "GRANT CREATE,SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE VIEW,SHOW VIEW,LOCK TABLES,GRANT OPTION ON TABLE * TO '$USERNAME'@$WHERE;" $DBNAME
+       ;;
+
        *)
-               echo "Usage: domtool-mysql [adduser <user> <password> | passwd <user> <password> | createdb <user> <table>]"
+               echo "Usage: domtool-mysql [adduser <user> <password> | passwd <user> <password> | createdb <user> <db> | dropdb <user> <db> | grant <user> <db>]"
        ;;
 esac