1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

call the event script on recovery too

(This used to be ctdb commit 8c43a91cbd6e502c93bd6cc51df1272eae426709)
This commit is contained in:
Andrew Tridgell 2007-05-29 12:55:24 +10:00
parent dfadb60318
commit ead091449b
4 changed files with 27 additions and 21 deletions

View File

@ -447,6 +447,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, TDB_DATA indata,
return -1;
}
ctdb->recovery_mode = recmode;
ctdb_event_script(ctdb, "recovered");
return 0;
}

View File

@ -945,6 +945,6 @@ int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...);
#endif

View File

@ -92,26 +92,6 @@ static void ctdb_control_send_arp(struct event_context *ev, struct timed_event *
}
/*
run the event script
*/
static int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
{
va_list ap;
char *cmdstr;
int ret;
va_start(ap, fmt);
cmdstr = talloc_vasprintf(ctdb, fmt, ap);
va_end(ap);
CTDB_NO_MEMORY(ctdb, cmdstr);
ret = system(cmdstr);
talloc_free(cmdstr);
return ret;
}
/*
take over an ip address
*/

View File

@ -257,3 +257,28 @@ bool ctdb_sys_have_ip(const char *ip)
return ret == 0;
}
/*
run the event script
*/
int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
{
va_list ap;
char *options, *cmdstr;
int ret;
va_start(ap, fmt);
options = talloc_vasprintf(ctdb, fmt, ap);
va_end(ap);
CTDB_NO_MEMORY(ctdb, options);
cmdstr = talloc_asprintf(ctdb, "%s %s", ctdb->takeover.event_script, options);
CTDB_NO_MEMORY(ctdb, cmdstr);
ret = system(cmdstr);
talloc_free(cmdstr);
talloc_free(options);
return ret;
}