mysql-fixperms
[hcoop/domtool2.git] / src / main.sml
index 3b54316..d57b867 100644 (file)
@@ -680,6 +680,21 @@ fun requestSmtpLog domain =
        OpenSSL.close bio
     end
 
+fun requestMysqlFixperms () =
+    let
+       val (_, bio) = requestBio (fn () => ())
+    in
+       Msg.send (bio, MsgMysqlFixperms);
+       case Msg.recv bio of
+           NONE => print "Server closed connection unexpectedly.\n"
+         | SOME m =>
+           case m of
+               MsgOk => print "Permissions granted.\n"
+             | MsgError s => print ("Failed: " ^ s ^ "\n")
+             | _ => print "Unexpected server reply.\n";
+       OpenSSL.close bio
+    end
+
 fun requestApt {node, pkg} =
     let
        val (user, context) = requestContext (fn () => ())
@@ -1433,6 +1448,16 @@ fun service () =
                                                  NONE)))
                                      (fn () => ())
 
+                              | MsgMysqlFixperms =>
+                                doIt (fn () => if OS.Process.isSuccess
+                                                      (OS.Process.system "/usr/bin/sudo -H /afs/hcoop.net/common/etc/scripts/mysql-grant-table-drop") then
+                                                   ("Requested mysql-fixperms",
+                                                    NONE)
+                                                else
+                                                    ("Requested mysql-fixperms, but execution failed!",
+                                                     SOME "Script execution failed."))
+                                     (fn () => ())
+
                               | _ =>
                                 doIt (fn () => ("Unexpected command",
                                                 SOME "Unexpected command"))