summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-05-06 21:43:50 -0400
committerAdam <Adam@anope.org>2012-05-06 21:43:50 -0400
commit675b113c3e03cf1917b2a731c21fe82b5f1f2b2b (patch)
tree6a80aaeafa829a3cef5c41c938d92ffedd1bdad8 /src
parenteb0e07d5645c06eb034cfcfbf91883158ba9dc00 (diff)
Split up db/conf/lib/locale install directories, and allow alternate ones to be specified at runtime
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/bin/CMakeLists.txt2
-rw-r--r--src/config.cpp2
-rw-r--r--src/init.cpp46
-rw-r--r--src/language.cpp6
-rw-r--r--src/logger.cpp2
-rw-r--r--src/main.cpp10
-rw-r--r--src/module.cpp2
-rw-r--r--src/modulemanager.cpp8
-rw-r--r--src/tools/CMakeLists.txt2
10 files changed, 55 insertions, 27 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 01dc44fbc..13a88bf51 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -124,5 +124,5 @@ add_subdirectory(tools)
# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
- DESTINATION bin
+ DESTINATION ${BIN_DIR}
)
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index cb110edb5..d1cdb5d06 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -2,7 +2,7 @@
if(NOT WIN32)
configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.in ${Anope_BINARY_DIR}/src/bin/anoperc)
install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
- DESTINATION bin
+ DESTINATION ${BIN_DIR}
)
endif(NOT WIN32)
diff --git a/src/config.cpp b/src/config.cpp
index 74ba31bd2..f192eb3cf 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -1064,7 +1064,7 @@ bool ConfigurationFile::IsOpen() const
bool ConfigurationFile::Open()
{
this->Close();
- this->fp = (this->executable ? popen(this->name.c_str(), "r") : fopen(this->name.c_str(), "r"));
+ this->fp = (this->executable ? popen(this->name.c_str(), "r") : fopen((conf_dir + "/" + this->name).c_str(), "r"));
return this->fp != NULL;
}
diff --git a/src/init.cpp b/src/init.cpp
index 08d4aed08..45262c1dd 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -26,6 +26,8 @@
#include <unistd.h>
#include <grp.h>
+Anope::string conf_dir = "conf", db_dir = "data", modules_dir = "lib", locale_dir = "locale", log_dir = "logs";
+
ServerConfig::Uplink *uplink_server;
void introduce_user(const Anope::string &user)
@@ -308,9 +310,13 @@ void Init(int ac, char **av)
Log(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)";
Log(LOG_TERMINAL) << "Usage ./" << services_bin << " [options] ...";
Log(LOG_TERMINAL) << "-c, --config=filename.conf";
+ Log(LOG_TERMINAL) << " --confdir=conf file direcory";
+ Log(LOG_TERMINAL) << " --dbdir=database directory";
Log(LOG_TERMINAL) << "-d, --debug[=level]";
- Log(LOG_TERMINAL) << " --dir=services_directory";
Log(LOG_TERMINAL) << "-h, --help";
+ Log(LOG_TERMINAL) << " --localedir=locale directory";
+ Log(LOG_TERMINAL) << " --logdir=logs directory";
+ Log(LOG_TERMINAL) << " --modulesdir=modules directory";
Log(LOG_TERMINAL) << "-e, --noexpire";
Log(LOG_TERMINAL) << "-n, --nofork";
Log(LOG_TERMINAL) << " --nothird";
@@ -367,11 +373,39 @@ void Init(int ac, char **av)
services_conf = ConfigurationFile(Arg, false);
}
- if (GetCommandLineArgument("dir", 0, Arg))
+ if (GetCommandLineArgument("confdir", 0, Arg))
+ {
+ if (Arg.empty())
+ throw FatalException("The --confdir option requires a path");
+ conf_dir = Arg;
+ }
+
+ if (GetCommandLineArgument("dbdir", 0, Arg))
+ {
+ if (Arg.empty())
+ throw FatalException("The --confdir option requires a path");
+ db_dir = Arg;
+ }
+
+ if (GetCommandLineArgument("localedir", 0, Arg))
+ {
+ if (Arg.empty())
+ throw FatalException("The --localedir option requires a path");
+ locale_dir = Arg;
+ }
+
+ if (GetCommandLineArgument("modulesdir", 0, Arg))
+ {
+ if (Arg.empty())
+ throw FatalException("The --modulesdir option requires a path");
+ modules_dir = Arg;
+ }
+
+ if (GetCommandLineArgument("logdir", 0, Arg))
{
if (Arg.empty())
- throw FatalException("The --dir option requires a directory name");
- services_dir = Arg;
+ throw FatalException("The --logdir option requires a path");
+ log_dir = Arg;
}
/* Chdir to Services data directory. */
@@ -382,9 +416,9 @@ void Init(int ac, char **av)
Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::VersionBuildString();
#ifdef _WIN32
- Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf.GetName();
+ Log(LOG_TERMINAL) << "Using configuration file " << conf_dir << "\\" << services_conf.GetName();
#else
- Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf.GetName();
+ Log(LOG_TERMINAL) << "Using configuration file " << conf_dir << "/" << services_conf.GetName();
#endif
/* Read configuration file; exit if there are problems. */
diff --git a/src/language.cpp b/src/language.cpp
index 8b680077b..2b41d755e 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -31,7 +31,7 @@ void InitLanguages()
while (sep.GetToken(language))
{
- if (!IsFile("languages/" + language + "/LC_MESSAGES/anope.mo"))
+ if (!IsFile(locale_dir + "/" + language + "/LC_MESSAGES/anope.mo"))
{
Log() << "Error loading language " << language << ", file does not exist!";
}
@@ -42,10 +42,10 @@ void InitLanguages()
}
}
- if (!bindtextdomain("anope", (services_dir + "/languages/").c_str()))
+ if (!bindtextdomain("anope", locale_dir.c_str()))
Log() << "Error calling bindtextdomain, " << Anope::LastError();
else
- Log(LOG_DEBUG) << "Successfully bound anope to " << services_dir << "/languages/";
+ Log(LOG_DEBUG) << "Successfully bound anope to " << locale_dir;
setlocale(LC_ALL, "");
#else
diff --git a/src/logger.cpp b/src/logger.cpp
index 2b27e1478..1b7c48f78 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -63,7 +63,7 @@ static Anope::string GetLogDate(time_t t = Anope::CurTime)
static inline Anope::string CreateLogName(const Anope::string &file, time_t t = Anope::CurTime)
{
- return "logs/" + file + "." + GetLogDate(t);
+ return log_dir + "/" + file + "." + GetLogDate(t);
}
LogFile::LogFile(const Anope::string &name) : filename(name), stream(name.c_str(), std::ios_base::out | std::ios_base::app)
diff --git a/src/main.cpp b/src/main.cpp
index cacfec814..e3fcb8bb2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,14 +43,13 @@
/* Command-line options: (note that configuration variables are in config.c) */
Anope::string services_dir; /* -dir dirname */
Anope::string services_bin; /* Binary as specified by the user */
-Anope::string orig_cwd; /* Original current working directory */
+Anope::string binary_dir; /* Used to store base path for Anope */
int debug = 0; /* -debug */
bool readonly = false; /* -readonly */
bool nofork = false; /* -nofork */
bool nothird = false; /* -nothrid */
bool noexpire = false; /* -noexpire */
bool protocoldebug = false; /* -protocoldebug */
-Anope::string binary_dir; /* Used to store base path for Anope */
/* Set to 1 if we are to quit */
bool quitting = false;
@@ -366,10 +365,6 @@ Anope::string GetFullProgDir(const Anope::string &argv0)
int main(int ac, char **av, char **envp)
{
- char cwd[PATH_MAX] = "";
- getcwd(cwd, PATH_MAX);
- orig_cwd = cwd;
-
#ifndef _WIN32
/* If we're root, issue a warning now */
if (!getuid() && !getgid())
@@ -387,11 +382,10 @@ int main(int ac, char **av, char **envp)
#ifdef _WIN32
Anope::string::size_type n = binary_dir.rfind('\\');
- services_dir = binary_dir.substr(0, n) + "\\data";
#else
Anope::string::size_type n = binary_dir.rfind('/');
- services_dir = binary_dir.substr(0, n) + "/data";
#endif
+ services_dir = binary_dir.substr(0, n);
/* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */
ModuleManager::CleanupRuntimeDirectory();
diff --git a/src/module.cpp b/src/module.cpp
index 8a253042a..c08d25aff 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -35,7 +35,7 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt
for (unsigned i = 0; i < languages.size(); ++i)
if (IsFile("languages/" + languages[i] + "/LC_MESSAGES/" + modname + ".mo"))
{
- if (!bindtextdomain(this->name.c_str(), (services_dir + "/languages/").c_str()))
+ if (!bindtextdomain(this->name.c_str(), locale_dir.c_str()))
Log() << "Error calling bindtextdomain, " << Anope::LastError();
else
domains.push_back(modname);
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index dd41d3940..57b8f850e 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -22,7 +22,7 @@ std::vector<Module *> ModuleManager::EventHandlers[I_END];
void ModuleManager::CleanupRuntimeDirectory()
{
- Anope::string dirbuf = services_dir + "/modules/runtime";
+ Anope::string dirbuf = modules_dir + "/modules/runtime";
Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait";
@@ -57,7 +57,7 @@ void ModuleManager::CleanupRuntimeDirectory()
*/
static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &output)
{
- Anope::string input = services_dir + "/modules/" + name + ".so";
+ Anope::string input = modules_dir + "/modules/" + name + ".so";
struct stat s;
if (stat(input.c_str(), &s) == -1)
@@ -134,14 +134,14 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
Log(LOG_DEBUG) << "trying to load [" << modname << "]";
/* Generate the filename for the temporary copy of the module */
- Anope::string pbuf = services_dir + "/modules/runtime/" + modname + ".so.XXXXXX";
+ Anope::string pbuf = modules_dir + "/modules/runtime/" + modname + ".so.XXXXXX";
/* Don't skip return value checking! -GD */
ModuleReturn ret = moduleCopyFile(modname, pbuf);
if (ret != MOD_ERR_OK)
{
if (ret == MOD_ERR_NOEXIST)
- Log(LOG_TERMINAL) << "Error while loading " << modname << " (file not exists)";
+ Log(LOG_TERMINAL) << "Error while loading " << modname << " (file does not exist)";
else if (ret == MOD_ERR_FILE_IO)
Log(LOG_TERMINAL) << "Error while loading " << modname << " (file IO error, check file permissions and diskspace)";
return ret;
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 081470766..c69c2fa7d 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -25,7 +25,7 @@ foreach(SRC ${TOOLS_SRCS})
endif(WIN32 AND ${EXE} STREQUAL anopesmtp)
# Set the executable to be installed to the bin directory under the main directory
install(TARGETS ${EXE}
- DESTINATION bin
+ DESTINATION ${BIN_DIR}
)
# Add the executable to the list of files for CPack to ignore
get_target_property(EXE_BINARY ${EXE} LOCATION)