ctdbd: Default for event_script_dir should use CTDB_BASE
authorMartin Schwenke <martin@meltin.net>
Tue, 15 Oct 2013 03:10:58 +0000 (14:10 +1100)
committerMartin Schwenke <martin@meltin.net>
Tue, 22 Oct 2013 04:37:54 +0000 (15:37 +1100)
Also get rid of ctdb_set_event_script_dir().  It creates an
unnecessary copy of something that will be around for the lifetime of
the process.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 21b4d1aba00902f1eee0cbf4f082b0794fd5b738)

ctdb/include/ctdb_private.h
ctdb/server/ctdb_takeover.c
ctdb/server/ctdbd.c

index 967dd63c9a060ab59e2e9144e9c7f3ea985f56cc..3430f9cd01dfe892e45dbe4338a7ad5c248a0c3e 100644 (file)
@@ -1219,7 +1219,6 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
                              const char *iface,
                              const char *ip);
 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
-int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
                      uint32_t *force_rebalance_nodes,
index ecb0dbe5fabd558a8ff2566d9f660239254b6947..91f30302d777f2adebdd78ec5a14cab654e2a45f 100644 (file)
@@ -1135,16 +1135,6 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
        return 0;
 }
 
-/*
-  setup the event script directory
-*/
-int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir)
-{
-       ctdb->event_script_dir = talloc_strdup(ctdb, script_dir);
-       CTDB_NO_MEMORY(ctdb, ctdb->event_script_dir);
-       return 0;
-}
-
 static void ctdb_check_interfaces_event(struct event_context *ev, struct timed_event *te, 
                                  struct timeval t, void *private_data)
 {
index b04971760d415e1946b539ad91ba145bffe75e5d..f19b48ff2ed06c7719940f5a3063140be43de19f 100644 (file)
@@ -54,7 +54,7 @@ static struct {
 } options = {
        .nlist = NULL,
        .transport = "tcp",
-       .event_script_dir = ETCDIR "/ctdb/events.d",
+       .event_script_dir = NULL,
        .logfile = LOGDIR "/log.ctdb",
        .db_dir = VARDIR "/ctdb",
        .db_dir_persistent = VARDIR "/ctdb/persistent",
@@ -296,10 +296,15 @@ int main(int argc, const char *argv[])
                }
        }
 
-       ret = ctdb_set_event_script_dir(ctdb, options.event_script_dir);
-       if (ret == -1) {
-               DEBUG(DEBUG_ALERT,("Unable to setup event script directory\n"));
-               exit(1);
+       if (options.event_script_dir != NULL) {
+               ctdb->event_script_dir = options.event_script_dir;
+       } else {
+               ctdb->event_script_dir = talloc_asprintf(ctdb, "%s/events.d",
+                                                        getenv("CTDB_BASE"));
+               if (ctdb->event_script_dir == NULL) {
+                       DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+                       exit(1);
+               }
        }
 
        if (options.notification_script != NULL) {