diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 01:44:22 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-13 01:44:22 +0000 |
commit | d1ddbd62f91d4b9453447b5d25f5e41e807b0010 (patch) | |
tree | 89ee0a02bab93e38f35195d236e13f3e22906932 | |
parent | 547e7e9b382255b1699ff897f40fb4ed659c3360 (diff) |
Change to new execution directory structure
Don't change CWD into bin/
Remove path-resolution hacks from configuration
Store pidfile and xline DBs in data, logs in logs.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11866 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | .Makefile.inc | 2 | ||||
-rw-r--r-- | .inspircd.inc | 4 | ||||
-rw-r--r-- | conf/inspircd.conf.example | 14 | ||||
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | include/configreader.h | 10 | ||||
-rw-r--r-- | src/configreader.cpp | 89 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 16 | ||||
-rw-r--r-- | src/inspircd.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_xline_db.cpp | 6 |
9 files changed, 28 insertions, 138 deletions
diff --git a/.Makefile.inc b/.Makefile.inc index 526779d80..9f51019e0 100644 --- a/.Makefile.inc +++ b/.Makefile.inc @@ -140,6 +140,8 @@ finishmessage: target install: target@EXTRA_DIR@ @-install -d -m $(INSTMODE) $(BASE) + @-install -d -m $(INSTMODE) $(BASE)/data + @-install -d -m $(INSTMODE) $(BASE)/logs @-install -d -m $(INSTMODE) $(BINPATH) @-install -d -m $(INSTMODE) $(CONPATH) @-install -d -m $(INSTMODE) $(MODPATH) diff --git a/.inspircd.inc b/.inspircd.inc index 518d823a7..486e4cec2 100644 --- a/.inspircd.inc +++ b/.inspircd.inc @@ -18,7 +18,7 @@ use Fcntl; my $basepath = "@BASE_DIR@"; my $confpath = "@CONFIG_DIR@/"; my $binpath = "@BINARY_DIR@"; -my $runpath = "@BINARY_DIR@"; +my $runpath = "@BASE_DIR@"; my $valgrindlogpath = "$basepath/valgrindlogs"; my $executable = "@EXECUTABLE@"; my $version = "@VERSION@"; @@ -372,7 +372,7 @@ sub getpidfile } # End of includes / No includes found. Using default. - $pidfile = $confpath . "inspircd.pid"; + $pidfile = $runpath . "/data/inspircd.pid"; } sub getstatus { diff --git a/conf/inspircd.conf.example b/conf/inspircd.conf.example index dcfaf428e..dab2519fb 100644 --- a/conf/inspircd.conf.example +++ b/conf/inspircd.conf.example @@ -344,22 +344,22 @@ # This file has all the information about oper classes, types and o:lines. # You *MUST* edit it. -<include file="opers.conf.example"> +<include file="conf/opers.conf.example"> # This file has all the information about server links and ulined servers. # You *MUST* edit it if you intend to link servers. -<include file="links.conf.example"> +<include file="conf/links.conf.example"> #-#-#-#-#-#-#-#-#-#- MISCELLANEOUS CONFIGURATION -#-#-#-#-#-#-#-#-#-# # # <files - # motd: Path to your motd file. Path is relative to the conf directory. - motd="inspircd.motd.example" + # motd: Path to your motd file. Path is relative to the run directory. + motd="conf/inspircd.motd.example" - # rules: Path to your rules file. Path is relative to the conf directory. + # rules: Path to your rules file. Path is relative to the run directory. # This is optional and is displayed when a user does /rules on the network. - rules="inspircd.rules.example"> + rules="conf/inspircd.rules.example"> #-#-#-#-#-#-#-#-#-#-#-# MAXIMUM CHANNELS -#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # # @@ -835,7 +835,7 @@ # provide almost all the features of InspIRCd. :) # # # # The default does nothing -- we include it for simplicity for you. # -<include file="modules.conf.example"> +<include file="conf/modules.conf.example"> ######################################################################### @@ -46,8 +46,7 @@ our ($opt_use_gnutls, $opt_rebuild, $opt_use_openssl, $opt_nointeractive, $opt_p $opt_epoll, $opt_kqueue, $opt_noports, $opt_noepoll, $opt_nokqueue, $opt_noipv6, $opt_maxbuf, $opt_disable_debug, $opt_freebsd_port); -our ($opt_cc, $opt_base_dir, $opt_config_dir, $opt_module_dir, $opt_binary_dir, - $opt_library_dir); +our ($opt_cc, $opt_base_dir, $opt_config_dir, $opt_module_dir, $opt_binary_dir); sub list_extras (); @@ -77,7 +76,6 @@ GetOptions ( 'config-dir=s' => \$opt_config_dir, 'module-dir=s' => \$opt_module_dir, 'binary-dir=s' => \$opt_binary_dir, - 'library-dir=s' => \$opt_library_dir, 'disable-debuginfo' => sub { $opt_disable_debug = 1 }, 'help' => sub { showhelp(); }, 'update' => sub { update(); }, @@ -101,7 +99,6 @@ if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) { } our $non_interactive = ( - (defined $opt_library_dir) || (defined $opt_base_dir) || (defined $opt_config_dir) || (defined $opt_module_dir) || @@ -127,9 +124,9 @@ chomp(our $topdir = getcwd()); our $this = resolve_directory($topdir); # PWD, Regardless. our @modlist = (); # Declare for Module List.. our %config = (); # Initiate Configuration Hash.. -$config{ME} = resolve_directory($topdir); # Present Working Directory +$config{ME} = resolve_directory($topdir); # Present Working Directory -$config{BASE_DIR} = $config{ME}; +$config{BASE_DIR} = $config{ME}."/run"; if (defined $opt_base_dir) { diff --git a/include/configreader.h b/include/configreader.h index bc5a09f02..cd8d66849 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -318,11 +318,6 @@ class CoreExport ServerConfig : public classbase */ std::string ModPath; - /** The full pathname to the executable, as - * given in argv[0] when the program starts. - */ - std::string MyExecutable; - /** The file handle of the logfile. If this * value is NULL, the log file is not open, * probably due to a permissions error on @@ -669,11 +664,6 @@ class CoreExport ServerConfig : public classbase bool ApplyDisabledCommands(const std::string& data); - /** Returns the fully qualified path to the inspircd directory - * @return The full program directory - */ - std::string GetFullProgDir(); - /** Clean a filename, stripping the directories (and drives) from string. * @param name Directory to tidy * @return The cleaned filename diff --git a/src/configreader.cpp b/src/configreader.cpp index 540653567..70c99e8ae 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1661,32 +1661,12 @@ bool ServerConfig::StartsWithWindowsDriveLetter(const std::string &path) bool ServerConfig::DoInclude(const std::string &file, bool allowexeinc) { - std::string confpath; - std::string newfile; - std::string::size_type pos; - - confpath = ServerInstance->ConfigFileName; - newfile = file; - - std::replace(newfile.begin(),newfile.end(),'\\','/'); - std::replace(confpath.begin(),confpath.end(),'\\','/'); - - if ((newfile[0] != '/') && (!StartsWithWindowsDriveLetter(newfile))) - { - pos = confpath.rfind("/"); - if(pos != std::string::npos) - { - /* Leaves us with just the path */ - newfile = confpath.substr(0, pos) + std::string("/") + newfile; - } - } - - FILE* conf = fopen(newfile.c_str(), "r"); + FILE* conf = fopen(file.c_str(), "r"); bool ret = false; if (conf) { - ret = LoadConf(conf, newfile, allowexeinc); + ret = LoadConf(conf, file, allowexeinc); fclose(conf); } else @@ -1889,29 +1869,9 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) F.clear(); - if ((*fname != '/') && (*fname != '\\') && (!StartsWithWindowsDriveLetter(fname))) - { - std::string::size_type pos; - std::string confpath = ServerInstance->ConfigFileName; - std::string newfile = fname; - - if (((pos = confpath.rfind("/"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("/") + fname; - else if (((pos = confpath.rfind("\\"))) != std::string::npos) - newfile = confpath.substr(0, pos) + std::string("\\") + fname; - - ServerInstance->Logs->Log("config", DEBUG, "Filename: %s", newfile.c_str()); - - if (!FileExists(newfile.c_str())) - return false; - file = fopen(newfile.c_str(), "r"); - } - else - { - if (!FileExists(fname)) - return false; - file = fopen(fname, "r"); - } + if (!FileExists(fname)) + return false; + file = fopen(fname, "r"); if (file) { @@ -1942,8 +1902,8 @@ bool ServerConfig::FileExists(const char* file) if ((sb.st_mode & S_IFDIR) > 0) return false; - FILE *input; - if ((input = fopen (file, "r")) == NULL) + FILE *input = fopen(file, "r"); + if (input == NULL) return false; else { @@ -1960,41 +1920,6 @@ const char* ServerConfig::CleanFilename(const char* name) } -std::string ServerConfig::GetFullProgDir() -{ - char buffer[PATH_MAX]; -#ifdef WINDOWS - /* Windows has specific api calls to get the exe path that never fail. - * For once, windows has something of use, compared to the POSIX code - * for this, this is positively neato. - */ - if (GetModuleFileName(NULL, buffer, MAX_PATH)) - { - std::string fullpath = buffer; - std::string::size_type n = fullpath.rfind("\\inspircd.exe"); - return std::string(fullpath, 0, n); - } -#else - // Get the current working directory - if (getcwd(buffer, PATH_MAX)) - { - std::string remainder = this->argv[0]; - - /* Does argv[0] start with /? its a full path, use it */ - if (remainder[0] == '/') - { - std::string::size_type n = remainder.rfind("/inspircd"); - return std::string(remainder, 0, n); - } - - std::string fullpath = std::string(buffer) + "/" + remainder; - std::string::size_type n = fullpath.rfind("/inspircd"); - return std::string(fullpath, 0, n); - } -#endif - return "/"; -} - std::string ServerConfig::GetSID() { return sid; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 6c2ceabb2..cd173b55f 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -281,20 +281,6 @@ bool InspIRCd::OpenLog(char**, int) { this->Logs->SetupNoFork(); } - Config->MyDir = Config->GetFullProgDir(); - - /* Attempt to find home directory, portable to windows */ - const char* home = getenv("HOME"); - if (!home) - { - /* No $HOME, log to %USERPROFILE% */ - home = getenv("USERPROFILE"); - if (!home) - { - /* Nothing could be found at all, log to current dir */ - Config->logpath = "./startup.log"; - } - } if (!Config->writelog) return true; // Skip opening default log if -nolog @@ -302,7 +288,7 @@ bool InspIRCd::OpenLog(char**, int) { if (Config->logpath.empty()) { - Config->logpath = "./startup.log"; + Config->logpath = "logs/startup.log"; } if (!Config->log_file) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a932b95e1..4956cfa8c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -286,18 +286,9 @@ bool InspIRCd::DaemonSeed() void InspIRCd::WritePID(const std::string &filename) { - std::string fname = (filename.empty() ? "inspircd.pid" : filename); - std::replace(fname.begin(), fname.end(), '\\', '/'); - if ((fname[0] != '/') && (!Config->StartsWithWindowsDriveLetter(filename))) - { - std::string::size_type pos; - std::string confpath = this->ConfigFileName; - if ((pos = confpath.rfind("/")) != std::string::npos) - { - /* Leaves us with just the path */ - fname = confpath.substr(0, pos) + std::string("/") + fname; - } - } + std::string fname(filename); + if (fname.empty()) + fname = "data/inspircd.pid"; std::ofstream outfile(fname.c_str()); if (outfile.is_open()) { @@ -470,7 +461,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : WSAStartup(MAKEWORD(2,0), &wsadata); ChangeWindowsSpecificPointers(); #endif - Config->MyExecutable = argv[0]; /* Set the finished argument values */ Config->nofork = do_nofork; diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index 329fc8e27..c4225d439 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -92,7 +92,7 @@ class ModuleXLineDB : public Module * -- w00t */ ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Opening temporary database"); - f = fopen("xline.db.new", "w"); + f = fopen("data/xline.db.new", "w"); if (!f) { ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Cannot create database! %s (%d)", strerror(errno), errno); @@ -133,7 +133,7 @@ class ModuleXLineDB : public Module } // Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash. - if (rename("xline.db.new", "xline.db") < 0) + if (rename("data/xline.db.new", "data/xline.db") < 0) { ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Cannot move new to old database! %s (%d)", strerror(errno), errno); ServerInstance->SNO->WriteToSnoMask('a', "database: cannot replace old with new db: %s (%d)", strerror(errno), errno); @@ -149,7 +149,7 @@ class ModuleXLineDB : public Module char linebuf[MAXBUF]; unsigned int lineno = 0; - f = fopen("xline.db", "r"); + f = fopen("data/xline.db", "r"); if (!f) { if (errno == ENOENT) |