summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2005-01-04 20:13:47 +0200
committerunknown <jani@ua141d10.elisa.omakaista.fi>2005-01-04 20:13:47 +0200
commitb7322baddee283582b39ec3acc8c76d97e9dff66 (patch)
tree0c8c8b613d9325f9794f856d8ca791f9e10a225d
parent592ffbcd68337c40dd75f2e052ee0479a120f8bd (diff)
downloadmariadb-git-b7322baddee283582b39ec3acc8c76d97e9dff66.tar.gz
Added checking for my.cnf file from environment variable MYSQL_HOME
instead of DATADIR. include/config-win.h: Added checks for environment variable MYSQL_HOME libmysql/Makefile.shared: Added checks for environment variable MYSQL_HOME mysys/Makefile.am: Added checks for environment variable MYSQL_HOME mysys/default.c: Removed checks for my.cnf file in datadir, instead added checking if my.cnf exists in environment variable MYSQL_HOME scripts/mysqld_multi.sh: Added checks for my.cnf file in environment variable MYSQL_HOME, if exists. scripts/mysqld_safe.sh: Added checks for my.cnf file in environment variable MYSQL_HOME, if exists.
-rw-r--r--include/config-win.h3
-rw-r--r--libmysql/Makefile.shared1
-rw-r--r--mysys/Makefile.am1
-rw-r--r--mysys/default.c42
-rw-r--r--scripts/mysqld_multi.sh12
-rw-r--r--scripts/mysqld_safe.sh15
6 files changed, 51 insertions, 23 deletions
diff --git a/include/config-win.h b/include/config-win.h
index 1d54a4bf9ec..cb2c072d056 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -332,6 +332,9 @@ inline double ulonglong2double(ulonglong value)
#define SHAREDIR "share"
#define DEFAULT_CHARSET_HOME "C:/mysql/"
#endif
+#ifndef DEFAULT_HOME_ENV
+#define DEFAULT_HOME_ENV MYSQL_HOME
+#endif
/* File name handling */
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 9664fb0abef..c7ce0273707 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -81,6 +81,7 @@ CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
$(target)
DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
+ -DDEFAULT_HOME_ENV=MYSQL_HOME \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
# The automatic dependencies miss this
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index b0ca1b402ee..4698d06d8c3 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -66,6 +66,7 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
+ -DDEFAULT_HOME_ENV=MYSQL_HOME \
@DEFS@
libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
diff --git a/mysys/default.c b/mysys/default.c
index d6d84f65d8b..3de134d936f 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -45,23 +45,8 @@ char *defaults_extra_file=0;
/* Which directories are searched for options (and in which order) */
-const char *default_directories[]= {
-#ifdef __WIN__
-"C:/",
-#elif defined(__NETWARE__)
-"sys:/etc/",
-#else
-"/etc/",
-#endif
-#ifdef DATADIR
-DATADIR,
-#endif
-"", /* Place for defaults_extra_dir */
-#if !defined(__WIN__) && !defined(__NETWARE__)
-"~/",
-#endif
-NullS,
-};
+#define MAX_DEFAULT_DIRS 4
+const char *default_directories[MAX_DEFAULT_DIRS + 1];
#ifdef __WIN__
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
@@ -89,6 +74,7 @@ static int search_default_file_with_ext(Process_option_func func,
void *func_ctx,
const char *dir, const char *ext,
const char *config_file);
+static void init_default_directories();
static char *remove_end_comment(char *ptr);
@@ -319,6 +305,7 @@ int load_defaults(const char *conf_file, const char **groups,
struct handle_option_ctx ctx;
DBUG_ENTER("load_defaults");
+ init_default_directories();
init_alloc_root(&alloc,512,0);
if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
{
@@ -652,6 +639,7 @@ void print_defaults(const char *conf_file, const char **groups)
char name[FN_REFLEN], **ext;
const char **dirs;
+ init_default_directories();
puts("\nDefault options are read from the following files in the given order:");
if (dirname_length(conf_file))
@@ -714,3 +702,23 @@ void print_defaults(const char *conf_file, const char **groups)
}
#include <help_end.h>
+
+static void init_default_directories()
+{
+ const char *env, **ptr= default_directories;
+
+#ifdef __WIN__
+ *ptr++= "C:/";
+#elif defined(__NETWARE__)
+ *ptr++= "sys:/etc/";
+#else
+ *ptr++= "/etc/";
+#endif
+ if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV))))
+ *ptr++= env;
+ *ptr++= ""; /* Place for defaults_extra_file */
+#if !defined(__WIN__) && !defined(__NETWARE__)
+ *ptr++= "~/";;
+#endif
+ *ptr= 0; /* end marker */
+}
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index ba46fd6fa29..ee873a86c8d 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -4,7 +4,7 @@ use Getopt::Long;
use POSIX qw(strftime);
$|=1;
-$VER="2.11";
+$VER="2.12";
$opt_config_file = undef();
$opt_example = 0;
@@ -430,6 +430,16 @@ sub find_groups
{
$data[$i] = $line;
}
+ if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" &&
+ -r "$ENV{MYSQL_HOME}/my.cnf")
+ {
+ open(MY_CNF, "<$ENV{MYSQL_HOME}/my.cnf") && (@tmp=<MY_CNF>) &&
+ close(MY_CNF);
+ }
+ for (; ($line = shift @tmp); $i++)
+ {
+ $data[$i] = $line;
+ }
if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf")
{
open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 1f4d17f8885..0e18f137c5a 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -52,11 +52,7 @@ parse_arguments() {
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
- # err-log should be removed in 5.0
- --err-log=*) err_log=`echo "$arg" | sed -e "s;--err-log=;;"` ;;
--log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;;
- # QQ The --open-files should be removed in 5.0
- --open-files=*) open_files=`echo "$arg" | sed -e "s;--open-files=;;"` ;;
--open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;;
--core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;;
--timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;;
@@ -94,7 +90,7 @@ then
DATADIR=$MY_BASEDIR_VERSION/data
if test -z "$defaults"
then
- defaults="--defaults-extra-file=$MY_BASEDIR_VERSION/data/my.cnf"
+ defaults="--defaults-extra-file=$DATADIR/my.cnf"
fi
# Check if this is a 'moved install directory'
elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
@@ -106,8 +102,17 @@ then
else
MY_BASEDIR_VERSION=@prefix@
DATADIR=@localstatedir@
+ if test -z "$MYSQL_HOME"
+ then
+ MYSQL_HOME=$DATADIR # Installation in a not common path
+ fi
ledir=@libexecdir@
fi
+if test -z "$MYSQL_HOME"
+then
+ MYSQL_HOME=$MY_BASEDIR_VERSION
+fi
+export MYSQL_HOME
user=@MYSQLD_USER@
niceness=0