2004-10-23 09:32:52 +02:00
|
|
|
/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
2003-08-16 19:44:24 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2005-09-23 20:28:56 +02:00
|
|
|
#if defined(__GNUC__) && defined(USE_PRAGMA_IMPLEMENTATION)
|
2004-10-23 09:32:52 +02:00
|
|
|
#pragma implementation
|
2003-08-19 17:55:20 +02:00
|
|
|
#endif
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
#include "options.h"
|
|
|
|
|
2005-03-22 00:04:14 +01:00
|
|
|
#include "priv.h"
|
2005-08-05 20:44:52 +02:00
|
|
|
#include "portability.h"
|
2003-08-16 19:44:24 +02:00
|
|
|
#include <my_sys.h>
|
|
|
|
#include <my_getopt.h>
|
2005-02-11 12:21:59 +01:00
|
|
|
#include <m_string.h>
|
|
|
|
#include <mysql_com.h>
|
2003-08-16 19:44:24 +02:00
|
|
|
|
|
|
|
#define QUOTE2(x) #x
|
|
|
|
#define QUOTE(x) QUOTE2(x)
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2005-08-05 12:35:30 +02:00
|
|
|
#ifdef __WIN__
|
2005-07-20 17:55:40 +02:00
|
|
|
char Options::install_as_service;
|
|
|
|
char Options::remove_service;
|
2005-09-13 21:53:19 +02:00
|
|
|
char Options::stand_alone;
|
2005-08-09 15:57:37 +02:00
|
|
|
char windows_config_file[FN_REFLEN];
|
|
|
|
char default_password_file_name[FN_REFLEN];
|
|
|
|
char default_log_file_name[FN_REFLEN];
|
|
|
|
const char *Options::config_file= windows_config_file;
|
2005-08-05 12:35:30 +02:00
|
|
|
#else
|
|
|
|
char Options::run_as_service;
|
|
|
|
const char *Options::user= 0; /* No default value */
|
2005-08-09 15:57:37 +02:00
|
|
|
const char *default_password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
|
|
|
|
const char *default_log_file_name= QUOTE(DEFAULT_LOG_FILE_NAME);
|
2005-08-05 12:35:30 +02:00
|
|
|
const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
|
2006-05-06 11:57:56 +02:00
|
|
|
const char *Options::angel_pid_file_name= NULL;
|
2005-08-09 15:57:37 +02:00
|
|
|
#endif
|
2005-07-20 17:55:40 +02:00
|
|
|
const char *Options::log_file_name= default_log_file_name;
|
2003-08-16 19:44:24 +02:00
|
|
|
const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
|
|
|
|
const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
|
2005-07-20 17:55:40 +02:00
|
|
|
const char *Options::password_file_name= default_password_file_name;
|
2004-10-23 09:32:52 +02:00
|
|
|
const char *Options::default_mysqld_path= QUOTE(DEFAULT_MYSQLD_PATH);
|
2005-02-05 12:04:49 +01:00
|
|
|
const char *Options::bind_address= 0; /* No default value */
|
2004-10-23 09:32:52 +02:00
|
|
|
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
|
|
|
|
uint Options::port_number= DEFAULT_PORT;
|
2005-02-03 18:48:58 +01:00
|
|
|
/* just to declare */
|
2005-08-09 15:57:37 +02:00
|
|
|
char **Options::saved_argv= NULL;
|
2006-02-10 00:15:55 +01:00
|
|
|
/* Remember if the config file was forced */
|
|
|
|
bool Options::is_forced_default_file= 0;
|
2006-04-12 20:14:56 +02:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
const char *Options::default_dbug_option= "d:t:i:O,im.trace";
|
|
|
|
#endif
|
2003-08-16 19:44:24 +02:00
|
|
|
|
2006-05-06 11:57:56 +02:00
|
|
|
static const char * const ANGEL_PID_FILE_SUFFIX= ".angel.pid";
|
|
|
|
static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX);
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
/*
|
|
|
|
List of options, accepted by the instance manager.
|
|
|
|
List must be closed with empty option.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum options {
|
|
|
|
OPT_LOG= 256,
|
|
|
|
OPT_PID_FILE,
|
|
|
|
OPT_SOCKET,
|
2004-10-23 09:32:52 +02:00
|
|
|
OPT_PASSWORD_FILE,
|
|
|
|
OPT_MYSQLD_PATH,
|
2005-07-20 17:55:40 +02:00
|
|
|
#ifndef __WIN__
|
2004-10-23 09:32:52 +02:00
|
|
|
OPT_RUN_AS_SERVICE,
|
|
|
|
OPT_USER,
|
2006-05-06 11:57:56 +02:00
|
|
|
OPT_ANGEL_PID_FILE,
|
2005-07-20 17:55:40 +02:00
|
|
|
#else
|
|
|
|
OPT_INSTALL_SERVICE,
|
|
|
|
OPT_REMOVE_SERVICE,
|
2005-09-13 21:53:19 +02:00
|
|
|
OPT_STAND_ALONE,
|
2005-07-20 17:55:40 +02:00
|
|
|
#endif
|
2004-10-23 09:32:52 +02:00
|
|
|
OPT_MONITORING_INTERVAL,
|
|
|
|
OPT_PORT,
|
2006-02-21 13:32:52 +01:00
|
|
|
OPT_WAIT_TIMEOUT,
|
2004-10-23 09:32:52 +02:00
|
|
|
OPT_BIND_ADDRESS
|
2003-08-16 19:44:24 +02:00
|
|
|
};
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
static struct my_option my_long_options[] =
|
|
|
|
{
|
|
|
|
{ "help", '?', "Display this help and exit.",
|
|
|
|
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
2006-05-06 11:57:56 +02:00
|
|
|
#ifndef __WIN__
|
|
|
|
{ "angel-pid-file", OPT_ANGEL_PID_FILE, "Pid file for angel process.",
|
|
|
|
(gptr *) &Options::angel_pid_file_name,
|
|
|
|
(gptr *) &Options::angel_pid_file_name,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
#endif
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2004-11-15 12:53:30 +01:00
|
|
|
{ "bind-address", OPT_BIND_ADDRESS, "Bind address to use for connection.",
|
2004-10-23 09:32:52 +02:00
|
|
|
(gptr *) &Options::bind_address, (gptr *) &Options::bind_address,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
2006-04-12 20:14:56 +02:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
{"debug", '#', "Debug log.",
|
|
|
|
(gptr*) &Options::default_dbug_option, (gptr*) &Options::default_dbug_option,
|
|
|
|
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
|
|
|
#endif
|
|
|
|
|
2004-11-15 12:53:30 +01:00
|
|
|
{ "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL"
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
" Server binary.",
|
|
|
|
(gptr *) &Options::default_mysqld_path,
|
|
|
|
(gptr *) &Options::default_mysqld_path,
|
2006-02-10 00:15:55 +01:00
|
|
|
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 },
|
2006-04-12 21:08:50 +02:00
|
|
|
#ifdef __WIN__
|
|
|
|
{ "install", OPT_INSTALL_SERVICE, "Install as system service.",
|
|
|
|
(gptr *) &Options::install_as_service, (gptr*) &Options::install_as_service,
|
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
|
|
|
|
#endif
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
{ "log", OPT_LOG, "Path to log file. Used only with --run-as-service.",
|
|
|
|
(gptr *) &Options::log_file_name, (gptr *) &Options::log_file_name,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
{ "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor"
|
|
|
|
" instances in seconds.",
|
|
|
|
(gptr *) &Options::monitoring_interval,
|
|
|
|
(gptr *) &Options::monitoring_interval,
|
|
|
|
0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,
|
|
|
|
0, 0, 0, 0, 0 },
|
2003-08-16 19:44:24 +02:00
|
|
|
|
2005-02-11 12:21:59 +01:00
|
|
|
{ "passwd", 'P', "Prepare entry for passwd file and exit.", 0, 0, 0,
|
|
|
|
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
2005-09-10 23:01:26 +02:00
|
|
|
{ "password-file", OPT_PASSWORD_FILE, "Look for Instance Manager users"
|
2004-10-23 09:32:52 +02:00
|
|
|
" and passwords here.",
|
|
|
|
(gptr *) &Options::password_file_name,
|
|
|
|
(gptr *) &Options::password_file_name,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
2006-04-12 21:08:50 +02:00
|
|
|
{ "pid-file", OPT_PID_FILE, "Pid file to use.",
|
|
|
|
(gptr *) &Options::pid_file_name, (gptr *) &Options::pid_file_name,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
|
|
|
{ "port", OPT_PORT, "Port number to use for connections",
|
|
|
|
(gptr *) &Options::port_number, (gptr *) &Options::port_number,
|
|
|
|
0, GET_UINT, REQUIRED_ARG, DEFAULT_PORT, 0, 0, 0, 0, 0 },
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2005-07-20 17:55:40 +02:00
|
|
|
#ifdef __WIN__
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
{ "remove", OPT_REMOVE_SERVICE, "Remove system service.",
|
|
|
|
(gptr *)&Options::remove_service, (gptr*) &Options::remove_service,
|
2005-07-20 17:55:40 +02:00
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0},
|
|
|
|
#else
|
2003-08-16 19:44:24 +02:00
|
|
|
{ "run-as-service", OPT_RUN_AS_SERVICE,
|
|
|
|
"Daemonize and start angel process.", (gptr *) &Options::run_as_service,
|
|
|
|
0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
|
2006-04-12 21:08:50 +02:00
|
|
|
#endif
|
2003-08-16 19:44:24 +02:00
|
|
|
|
2006-04-12 21:08:50 +02:00
|
|
|
{ "socket", OPT_SOCKET, "Socket file to use for connection.",
|
|
|
|
(gptr *) &Options::socket_file_name, (gptr *) &Options::socket_file_name,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
{ "standalone", OPT_STAND_ALONE, "Run the application in stand alone mode.",
|
|
|
|
(gptr *)&Options::stand_alone, (gptr*) &Options::stand_alone,
|
|
|
|
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0},
|
|
|
|
#else
|
2005-02-05 12:04:49 +01:00
|
|
|
{ "user", OPT_USER, "Username to start mysqlmanager",
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
(gptr *) &Options::user,
|
|
|
|
(gptr *) &Options::user,
|
|
|
|
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
|
2005-07-20 17:55:40 +02:00
|
|
|
#endif
|
2006-04-12 21:08:50 +02:00
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
{ "version", 'V', "Output version information and exit.", 0, 0, 0,
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
2003-08-16 19:44:24 +02:00
|
|
|
|
2006-02-21 13:32:52 +01:00
|
|
|
{ "wait-timeout", OPT_WAIT_TIMEOUT, "The number of seconds IM waits "
|
|
|
|
"for activity on a connection before closing it.",
|
|
|
|
(gptr *) &net_read_timeout, (gptr *) &net_read_timeout, 0, GET_ULONG,
|
|
|
|
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0 },
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void version()
|
|
|
|
{
|
2004-10-23 09:32:52 +02:00
|
|
|
printf("%s Ver %s for %s on %s\n", my_progname, mysqlmanager_version,
|
2003-08-16 19:44:24 +02:00
|
|
|
SYSTEM_TYPE, MACHINE_TYPE);
|
|
|
|
}
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2005-04-11 15:08:34 +02:00
|
|
|
static const char *default_groups[]= { "manager", 0 };
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
static void usage()
|
|
|
|
{
|
|
|
|
version();
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
printf("Copyright (C) 2003, 2004 MySQL AB\n"
|
|
|
|
"This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
|
|
|
|
"and you are welcome to modify and redistribute it under the GPL license\n");
|
|
|
|
printf("Usage: %s [OPTIONS] \n", my_progname);
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
my_print_help(my_long_options);
|
2005-07-21 20:40:53 +02:00
|
|
|
printf("\nThe following options may be given as the first argument:\n"
|
|
|
|
"--print-defaults Print the program argument list and exit\n"
|
|
|
|
"--defaults-file=# Only read manager configuration and instance\n"
|
|
|
|
" setings from the given file #. The same file\n"
|
|
|
|
" will be used to modify configuration of instances\n"
|
|
|
|
" with SET commands.\n");
|
2004-10-23 09:32:52 +02:00
|
|
|
my_print_variables(my_long_options);
|
2003-08-16 19:44:24 +02:00
|
|
|
}
|
|
|
|
|
2005-02-11 12:21:59 +01:00
|
|
|
|
|
|
|
static void passwd()
|
|
|
|
{
|
2005-02-18 13:23:55 +01:00
|
|
|
char user[1024], *p;
|
|
|
|
const char *pw1, *pw2;
|
|
|
|
char pw1msg[]= "Enter password: ";
|
|
|
|
char pw2msg[]= "Re-type password: ";
|
2005-02-11 12:21:59 +01:00
|
|
|
char crypted_pw[SCRAMBLED_PASSWORD_CHAR_LENGTH + 1];
|
|
|
|
|
|
|
|
fprintf(stderr, "Creating record for new user.\n");
|
|
|
|
fprintf(stderr, "Enter user name: ");
|
2005-05-15 23:54:02 +02:00
|
|
|
if (!fgets(user, sizeof(user), stdin))
|
2005-02-11 12:21:59 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Unable to read user.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((p= strchr(user, '\n'))) *p= 0;
|
|
|
|
|
2005-02-18 13:23:55 +01:00
|
|
|
pw1= get_tty_password(pw1msg);
|
|
|
|
pw2= get_tty_password(pw2msg);
|
|
|
|
|
|
|
|
if (strcmp(pw1, pw2))
|
2005-02-11 12:21:59 +01:00
|
|
|
{
|
2005-02-18 13:23:55 +01:00
|
|
|
fprintf(stderr, "Sorry, passwords do not match.\n");
|
2005-02-11 12:21:59 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-18 13:23:55 +01:00
|
|
|
make_scrambled_password(crypted_pw, pw1);
|
2005-02-11 12:21:59 +01:00
|
|
|
printf("%s:%s\n", user, crypted_pw);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-16 19:44:24 +02:00
|
|
|
C_MODE_START
|
|
|
|
|
|
|
|
static my_bool
|
|
|
|
get_one_option(int optid,
|
|
|
|
const struct my_option *opt __attribute__((unused)),
|
2006-04-12 20:14:56 +02:00
|
|
|
char *argument)
|
2003-08-16 19:44:24 +02:00
|
|
|
{
|
|
|
|
switch(optid) {
|
|
|
|
case 'V':
|
|
|
|
version();
|
|
|
|
exit(0);
|
2005-02-11 12:21:59 +01:00
|
|
|
case 'P':
|
|
|
|
passwd();
|
|
|
|
exit(0);
|
2003-08-16 19:44:24 +02:00
|
|
|
case '?':
|
|
|
|
usage();
|
|
|
|
exit(0);
|
2006-04-12 20:14:56 +02:00
|
|
|
case '#':
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
DBUG_SET(argument ? argument : Options::default_dbug_option);
|
|
|
|
DBUG_SET_INITIAL(argument ? argument : Options::default_dbug_option);
|
|
|
|
#endif
|
|
|
|
break;
|
2003-08-16 19:44:24 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
C_MODE_END
|
|
|
|
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
/*
|
2005-07-21 12:21:23 +02:00
|
|
|
- Process argv of original program: get tid of --defaults-extra-file
|
|
|
|
and print a message if met there.
|
|
|
|
- call load_defaults to load configuration file section and save the pointer
|
|
|
|
for free_defaults.
|
2004-10-23 09:32:52 +02:00
|
|
|
- call handle_options to assign defaults and command-line arguments
|
2005-07-21 12:21:23 +02:00
|
|
|
to the class members.
|
|
|
|
if either of these function fail, return the error code.
|
2003-08-16 19:44:24 +02:00
|
|
|
*/
|
|
|
|
|
2005-02-15 02:38:33 +01:00
|
|
|
int Options::load(int argc, char **argv)
|
2003-08-16 19:44:24 +02:00
|
|
|
{
|
2005-07-21 20:40:53 +02:00
|
|
|
if (argc >= 2)
|
2005-02-18 12:58:30 +01:00
|
|
|
{
|
2005-07-21 20:40:53 +02:00
|
|
|
if (is_prefix(argv[1], "--defaults-file="))
|
2005-07-21 12:21:23 +02:00
|
|
|
{
|
2005-07-21 20:40:53 +02:00
|
|
|
Options::config_file= strchr(argv[1], '=') + 1;
|
2006-02-10 00:15:55 +01:00
|
|
|
Options::is_forced_default_file= 1;
|
2005-07-21 12:21:23 +02:00
|
|
|
}
|
2005-07-21 20:40:53 +02:00
|
|
|
if (is_prefix(argv[1], "--defaults-extra-file=") ||
|
|
|
|
is_prefix(argv[1], "--no-defaults"))
|
2005-07-21 12:21:23 +02:00
|
|
|
{
|
|
|
|
/* the log is not enabled yet */
|
2005-07-21 20:40:53 +02:00
|
|
|
fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
" are not supported by\n"
|
|
|
|
"Instance Manager. Program aborted.\n");
|
2005-07-21 20:40:53 +02:00
|
|
|
goto err;
|
2005-07-21 12:21:23 +02:00
|
|
|
}
|
2005-02-18 12:58:30 +01:00
|
|
|
}
|
|
|
|
|
2005-08-04 16:33:44 +02:00
|
|
|
#ifdef __WIN__
|
2005-08-09 15:57:37 +02:00
|
|
|
if (setup_windows_defaults())
|
|
|
|
goto err;
|
2005-08-04 16:33:44 +02:00
|
|
|
#endif
|
2005-08-29 21:29:35 +02:00
|
|
|
/* load_defaults will reset saved_argv with a new allocated list */
|
|
|
|
saved_argv= argv;
|
2005-07-20 17:55:40 +02:00
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
/* config-file options are prepended to command-line ones */
|
2005-07-21 20:40:53 +02:00
|
|
|
load_defaults(config_file, default_groups, &argc,
|
2005-07-21 12:21:23 +02:00
|
|
|
&saved_argv);
|
|
|
|
|
2005-07-21 20:40:53 +02:00
|
|
|
if ((handle_options(&argc, &saved_argv, my_long_options,
|
|
|
|
get_one_option)) != 0)
|
2005-07-21 12:21:23 +02:00
|
|
|
goto err;
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2006-05-06 11:57:56 +02:00
|
|
|
#ifndef __WIN__
|
|
|
|
if (Options::run_as_service)
|
|
|
|
{
|
|
|
|
if (Options::angel_pid_file_name == NULL)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Calculate angel pid file on the IM pid file basis: replace the
|
|
|
|
extension (everything after the last dot) of the pid file basename to
|
|
|
|
'.angel.pid'.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *angel_pid_file_name;
|
|
|
|
char *base_name_ptr;
|
|
|
|
char *ext_ptr;
|
|
|
|
|
|
|
|
angel_pid_file_name= (char *) malloc(strlen(Options::pid_file_name) +
|
|
|
|
ANGEL_PID_FILE_SUFFIX_LEN);
|
|
|
|
|
|
|
|
strcpy(angel_pid_file_name, Options::pid_file_name);
|
|
|
|
|
|
|
|
base_name_ptr= strrchr(angel_pid_file_name, '/');
|
|
|
|
|
|
|
|
if (!base_name_ptr)
|
|
|
|
base_name_ptr= angel_pid_file_name + 1;
|
|
|
|
|
|
|
|
ext_ptr= strrchr(base_name_ptr, '.');
|
|
|
|
if (ext_ptr)
|
|
|
|
*ext_ptr= 0;
|
|
|
|
|
|
|
|
strcat(angel_pid_file_name, ANGEL_PID_FILE_SUFFIX);
|
|
|
|
|
|
|
|
Options::angel_pid_file_name= angel_pid_file_name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Options::angel_pid_file_name= strdup(Options::angel_pid_file_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-02-15 02:38:33 +01:00
|
|
|
return 0;
|
2005-07-21 12:21:23 +02:00
|
|
|
|
|
|
|
err:
|
2005-07-21 20:40:53 +02:00
|
|
|
return 1;
|
2003-08-16 19:44:24 +02:00
|
|
|
}
|
|
|
|
|
2005-02-03 18:48:58 +01:00
|
|
|
void Options::cleanup()
|
|
|
|
{
|
|
|
|
/* free_defaults returns nothing */
|
2005-08-09 15:57:37 +02:00
|
|
|
if (Options::saved_argv != NULL)
|
|
|
|
free_defaults(Options::saved_argv);
|
2006-05-06 11:57:56 +02:00
|
|
|
|
2006-05-10 16:53:28 +02:00
|
|
|
#ifndef __WIN__
|
2006-05-06 11:57:56 +02:00
|
|
|
if (Options::run_as_service)
|
|
|
|
free((void *) Options::angel_pid_file_name);
|
2006-05-10 16:53:28 +02:00
|
|
|
#endif
|
2005-02-03 18:48:58 +01:00
|
|
|
}
|
2005-07-20 17:55:40 +02:00
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
|
2005-08-09 15:57:40 +02:00
|
|
|
int Options::setup_windows_defaults()
|
2005-07-20 17:55:40 +02:00
|
|
|
{
|
2005-08-09 15:57:37 +02:00
|
|
|
if (!GetModuleFileName(NULL, default_password_file_name,
|
|
|
|
sizeof(default_password_file_name)))
|
2005-08-09 15:57:40 +02:00
|
|
|
return 1;
|
2005-08-09 15:57:38 +02:00
|
|
|
char *filename= strstr(default_password_file_name, ".exe");
|
2005-08-09 15:57:37 +02:00
|
|
|
strcpy(filename, ".passwd");
|
2005-08-09 15:57:40 +02:00
|
|
|
|
2005-08-09 15:57:37 +02:00
|
|
|
if (!GetModuleFileName(NULL, default_log_file_name,
|
|
|
|
sizeof(default_log_file_name)))
|
2005-08-09 15:57:40 +02:00
|
|
|
return 1;
|
2005-08-09 15:57:38 +02:00
|
|
|
filename= strstr(default_log_file_name, ".exe");
|
2005-08-09 15:57:37 +02:00
|
|
|
strcpy(filename, ".log");
|
|
|
|
|
|
|
|
if (!GetModuleFileName(NULL, windows_config_file,
|
|
|
|
sizeof(windows_config_file)))
|
2005-08-09 15:57:40 +02:00
|
|
|
return 1;
|
2005-08-09 15:57:38 +02:00
|
|
|
char *slash= strrchr(windows_config_file, '\\');
|
2005-08-09 15:57:37 +02:00
|
|
|
strcpy(slash, "\\my.ini");
|
|
|
|
return 0;
|
2005-07-20 17:55:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|