mirror of
https://github.com/anope/anope.git
synced 2026-07-04 08:03:12 +02:00
BUILD : 1.7.15 (1162) BUGS : 604 NOTES : Added functions to let modules backup their own databases and added this functionality to the bundled modules
git-svn-id: svn://svn.anope.org/anope/trunk@1162 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@884 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
parent
c565a28c43
commit
f11e06eca8
@@ -3,6 +3,7 @@ Anope Version S V N
|
||||
Provided by Anope Dev. <dev@anope.org> - 2006
|
||||
09/10 A Added SASET AUTOOP to NickServ to match SET AUTOOP. [#588]
|
||||
09/11 A Added detection in install.js for the latest PlatformSDK. [#596]
|
||||
09/29 A Ability for modules to backup their databases. [#604]
|
||||
08/09 F Fixed port checking when using command line switches. [#575]
|
||||
08/14 F Fixed db_mysql_query for better robustness. [#585]
|
||||
08/27 F Fixed mod_current_module being incorrect resulting in segfault. [#593]
|
||||
|
||||
@@ -853,6 +853,8 @@ E void modules_core_init(int number, char **list);
|
||||
E void modules_unload_all(boolean fini, boolean unload_proto); /* Read warnings near function source */
|
||||
E void moduleCallBackRun(void);
|
||||
E void moduleCleanStruct(ModuleData **moduleData);
|
||||
E void ModuleDatabaseBackup(char *dbname);
|
||||
E void ModuleRemoveBackups(char *dbname);
|
||||
|
||||
/**** news.c ****/
|
||||
|
||||
|
||||
@@ -711,3 +711,63 @@ void backup_databases(void)
|
||||
send_event(EVENT_DB_BACKUP, 1, EVENT_STOP);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void ModuleDatabaseBackup(char *dbname)
|
||||
{
|
||||
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
|
||||
if (!KeepBackups) {
|
||||
return;
|
||||
}
|
||||
|
||||
time(&t);
|
||||
tm = *localtime(&t);
|
||||
|
||||
if (!curday) {
|
||||
curday = tm.tm_yday;
|
||||
return;
|
||||
}
|
||||
|
||||
if (curday != tm.tm_yday) {
|
||||
|
||||
char ext[9];
|
||||
|
||||
if (debug) {
|
||||
alog("Module Database Backing up %s", dbname);
|
||||
}
|
||||
ModuleRemoveBackups(dbname);
|
||||
curday = tm.tm_yday;
|
||||
strftime(ext, sizeof(ext), "%Y%m%d", &tm);
|
||||
rename_database(dbname, ext);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void ModuleRemoveBackups(char *dbname)
|
||||
{
|
||||
char ext[9];
|
||||
char path[PATH_MAX];
|
||||
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
|
||||
time(&t);
|
||||
t -= (60 * 60 * 24 * KeepBackups);
|
||||
tm = *localtime(&t);
|
||||
strftime(ext, sizeof(ext), "%Y%m%d", &tm);
|
||||
|
||||
snprintf(path, sizeof(path), "backups/%s.%s", dbname, ext);
|
||||
#ifndef _WIN32
|
||||
unlink(path);
|
||||
#else
|
||||
DeleteFile(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ int ns_do_drop(User * u);
|
||||
void hsreq_save_db(void);
|
||||
void hsreq_load_db(void);
|
||||
int hsreqevt_db_saving(int argc, char **argv);
|
||||
int hsreqevt_db_backup(int argc, char **argv);
|
||||
|
||||
void my_load_config(void);
|
||||
void my_add_languages(void);
|
||||
@@ -117,6 +118,9 @@ int AnopeInit(int argc, char **argv)
|
||||
hook = createEventHook(EVENT_DB_SAVING, hsreqevt_db_saving);
|
||||
moduleAddEventHook(hook);
|
||||
|
||||
hook = createEventHook(EVENT_DB_BACKUP, hsreqevt_db_backup);
|
||||
moduleAddEventHook(hook);
|
||||
|
||||
moduleSetHostHelp(hs_help);
|
||||
moduleAddAuthor(AUTHOR);
|
||||
moduleAddVersion(VERSION);
|
||||
@@ -680,6 +684,18 @@ int hsreqevt_db_saving(int argc, char **argv)
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
int hsreqevt_db_backup(int argc, char **argv)
|
||||
{
|
||||
if ((argc >= 1) && (stricmp(argv[0], EVENT_START) == 0)) {
|
||||
if (HSRequestDBName)
|
||||
ModuleDatabaseBackup(HSRequestDBName);
|
||||
else
|
||||
ModuleDatabaseBackup(HSREQ_DEFAULT_DBNAME);
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
void my_load_config(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -55,6 +55,7 @@ void m_AddLanguages(void);
|
||||
|
||||
int mLoadData(void);
|
||||
int mSaveData(int argc, char **argv);
|
||||
int mBackupData(int argc, char **argv);
|
||||
int mLoadConfig();
|
||||
int mEventReload(int argc, char **argv);
|
||||
|
||||
@@ -99,6 +100,9 @@ int AnopeInit(int argc, char **argv)
|
||||
hook = createEventHook(EVENT_DB_SAVING, mSaveData);
|
||||
status = moduleAddEventHook(hook);
|
||||
|
||||
hook = createEventHook(EVENT_DB_BACKUP, mBackupData);
|
||||
status = moduleAddEventHook(hook);
|
||||
|
||||
hook = createEventHook(EVENT_RELOAD, mEventReload);
|
||||
status = moduleAddEventHook(hook);
|
||||
|
||||
@@ -449,6 +453,17 @@ int mSaveData(int argc, char **argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup our databases using the commands provided by Anope
|
||||
* @return MOD_CONT
|
||||
**/
|
||||
int mBackupData(int argc, char **argv)
|
||||
{
|
||||
ModuleDatabaseBackup(OSInfoDBName);
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration directives from Services configuration file.
|
||||
* @return 0 for success
|
||||
|
||||
+5
-1
@@ -9,10 +9,14 @@ VERSION_MAJOR="1"
|
||||
VERSION_MINOR="7"
|
||||
VERSION_PATCH="15"
|
||||
VERSION_EXTRA="-svn"
|
||||
VERSION_BUILD="1161"
|
||||
VERSION_BUILD="1162"
|
||||
|
||||
# $Log$
|
||||
#
|
||||
# BUILD : 1.7.15 (1162)
|
||||
# BUGS : 604
|
||||
# NOTES : Added functions to let modules backup their own databases and added this functionality to the bundled modules
|
||||
#
|
||||
# BUILD : 1.7.15 (1161)
|
||||
# BUGS : 606
|
||||
# NOTES : Fixed Makefile.win32 to fix a typo and `nmake clean` (it now uses spotless)
|
||||
|
||||
Reference in New Issue
Block a user