]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change to new execution directory structure
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 Oct 2009 01:44:22 +0000 (01:44 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 13 Oct 2009 01:44:22 +0000 (01:44 +0000)
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

.Makefile.inc
.inspircd.inc
conf/inspircd.conf.example
configure
include/configreader.h
src/configreader.cpp
src/helperfuncs.cpp
src/inspircd.cpp
src/modules/m_xline_db.cpp

index 526779d801821475fced72004b45d335f45ff468..9f51019e031e6d69f0de6259faca4ac9bf5fba94 100644 (file)
@@ -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)
index 518d823a75a773e4e56b2faad6f967d30719b193..486e4cec2ab262c87236bdafe0e184f13bcb1c8f 100644 (file)
@@ -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 {
index dcfaf428ef4581bf9927411489c6bcfebaf8c764..dab2519fb0d8f4df06730c49059db16aa05e0b68 100644 (file)
 
 # 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 -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 #                                                                     #
 # 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">
 
 
 #########################################################################
index cd21375b5dd06557f0d977a858a982a6bb51d28b..41b0cd0ee82e190aa68876627a1c8e847cd24323 100755 (executable)
--- a/configure
+++ b/configure
@@ -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)
 {
index bc5a09f02fca98ce067c5bff6db2a45dcf9c68ea..cd8d66849c7285255117253e741526d6a99284e7 100644 (file)
@@ -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
index 540653567ae46170b85f851a206c6e17e9716e27..70c99e8ae4f7257a7a28a6b315b336d91bc43dfb 100644 (file)
@@ -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;
index 6c2ceabb273d50ceac2be072572fcb071e693837..cd173b55ffb1148fe22ab32013a957552815ab09 100644 (file)
@@ -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)
index a932b95e10fe9aeabf4bd162527bd12d32d31370..4956cfa8cca384f61de6b65b898a3eefc7fb5e82 100644 (file)
@@ -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;
index 329fc8e27c6363bb7591152d25bf9409937bd28e..c4225d4394a2955a5ad432da4efe0ada70c2eb9d 100644 (file)
@@ -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)