1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 14:13:12 +02:00

Fixed restarting Anope when it is started from outside of the services binary dir

This commit is contained in:
Adam
2010-10-05 19:46:33 -04:00
parent 64a3bda235
commit 9ab50eedf2
5 changed files with 12 additions and 17 deletions
+1
View File
@@ -168,6 +168,7 @@ E void InitLogChannels(ServerConfig *);
/**** main.c ****/
E Anope::string services_dir;
E Anope::string services_bin;
E int debug;
E bool readonly;
E bool nofork;
-1
View File
@@ -20,7 +20,6 @@
#cmakedefine HAVE_EVENTFD 1
#cmakedefine GETTEXT_FOUND 1
#cmakedefine RUNGROUP "@RUNGROUP@"
#cmakedefine SERVICES_BIN "@SERVICES_BIN@"
#cmakedefine HAVE_UINT8_T 1
#cmakedefine HAVE_U_INT8_T 1
-1
View File
@@ -88,7 +88,6 @@ add_dependencies(${PROGRAM_NAME} language headers)
# Get the filename of the Anope executable as it is in on this system
get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
set(SERVICES_BIN "${SERVICES_BINARY}")
# Add the Anope executable to the list of files for CPack to ignore
add_to_cpack_ignored_files("${SERVICES_BINARY}$" TRUE)
+1 -1
View File
@@ -225,7 +225,7 @@ void Init(int ac, char **av)
{
Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build();
Log(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)";
Log(LOG_TERMINAL) << "Usage ./" << SERVICES_BIN << " [options] ...";
Log(LOG_TERMINAL) << "Usage ./" << services_bin << " [options] ...";
Log(LOG_TERMINAL) << "-c, --config=filename.conf";
Log(LOG_TERMINAL) << "-d, --debug[=level]";
Log(LOG_TERMINAL) << " --dir=services_directory";
+10 -14
View File
@@ -186,6 +186,7 @@ void do_restart_services()
delete UplinkSock;
ModuleManager::UnloadAll();
chdir(binary_dir.c_str());
my_av[0] = const_cast<char *>(("./" + services_bin).c_str());
execve(services_bin.c_str(), my_av, my_envp);
if (!readonly)
{
@@ -309,7 +310,7 @@ Anope::string GetFullProgDir(const Anope::string &argv0)
if (GetModuleFileName(NULL, buffer, PATH_MAX))
{
Anope::string fullpath = buffer;
Anope::string::size_type n = fullpath.rfind("\\" SERVICES_BIN);
Anope::string::size_type n = fullpath.rfind("\\");
services_bin = fullpath.substr(n + 1, fullpath.length());
return fullpath.substr(0, n);
}
@@ -319,20 +320,15 @@ Anope::string GetFullProgDir(const Anope::string &argv0)
{
Anope::string remainder = argv0;
/* Does argv[0] start with /? If so, it's a full path, use it */
if (remainder[0] == '/')
{
Anope::string::size_type n = remainder.rfind("/" SERVICES_BIN);
services_bin = remainder.substr(n + 1, remainder.length());
return remainder.substr(0, n);
}
services_bin = remainder;
if (services_bin.substr(0, 2).equals_cs("./"))
services_bin = services_bin.substr(2);
Anope::string fullpath = Anope::string(buffer) + "/" + remainder;
Anope::string::size_type n = fullpath.rfind("/" SERVICES_BIN);
return fullpath.substr(0, n);
Anope::string::size_type n = services_bin.rfind("/");
Anope::string fullpath;
if (services_bin[0] == '/')
fullpath = services_bin.substr(0, n);
else
fullpath = Anope::string(buffer) + "/" + services_bin.substr(0, n);
services_bin = services_bin.substr(n + 1, remainder.length());
return fullpath;
}
#endif
return "/";