Skip to content

Commit

Permalink
create config on windows install; don't fixup paths in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
glookka committed Feb 20, 2023
1 parent 02ffaf5 commit f381ad2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 51 deletions.
25 changes: 25 additions & 0 deletions dist/build_dockers/nsis/nsisscript.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ Fail1:
Ok:
FunctionEnd

Function createConfig
StrCpy $R0 "$INSTDIR\etc\manticoresearch\manticore.conf"
FileOpen $0 $R0 w
FileWrite $0 "searchd$\n"
FileWrite $0 "{$\n"
FileWrite $0 " listen = 127.0.0.1:9312$\n"
FileWrite $0 " listen = 127.0.0.1:9306:mysql$\n"
FileWrite $0 " listen = 127.0.0.1:9308:http$\n"
FileWrite $0 " log = $INSTDIR/var/log/manticore/searchd.log$\n"
FileWrite $0 " query_log = $INSTDIR/var/log/manticore/query.log$\n"
FileWrite $0 " pid_file = $INSTDIR/var/run/manticore/searchd.pid$\n"
FileWrite $0 " data_dir = $INSTDIR/var/data$\n"
FileWrite $0 " query_log_format = sphinxql$\n"
FileWrite $0 "}$\n"
IfErrors Fail1
Goto Ok

Fail1:
MessageBox MB_OK "Error! Unable to write to $R0!"
Abort

Ok:
FunctionEnd

Section "Manticore Search"
SectionIn RO
Expand All @@ -76,6 +99,8 @@ Section "Manticore Search"
CreateDirectory "$INSTDIR\var\data"
CreateDirectory "$INSTDIR\var\log\manticore"
CreateDirectory "$INSTDIR\var\run\manticore"

Call createConfig

; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\Manticore Software LTD" "manticore" "$INSTDIR"
Expand Down
4 changes: 0 additions & 4 deletions src/indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,10 +1582,6 @@ bool SendRotate ( const CSphConfig & hConf, bool bForce )

CSphString sPidFile = hSearchd["pid_file"].cstr();

#if _WIN32
sPidFile = AppendWinInstallDir(sPidFile);
#endif

// read in PID
FILE * fp = fopen ( sPidFile.cstr(), "r" );
if ( !fp )
Expand Down
22 changes: 3 additions & 19 deletions src/searchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19228,18 +19228,6 @@ static void ConfigureAndPreloadOnStartup ( const CSphConfig & hConf, const StrVe
}


static CSphString FixupFilename ( const CSphString & sFilename )
{
CSphString sFixed = sFilename;

#if _WIN32
sFixed = AppendWinInstallDir(sFixed);
#endif

return sFixed;
}


void OpenDaemonLog ( const CSphConfigSection & hSearchd, bool bCloseIfOpened=false )
{
CSphString sLog = "searchd.log";
Expand All @@ -19257,8 +19245,7 @@ void OpenDaemonLog ( const CSphConfigSection & hSearchd, bool bCloseIfOpened=fal
#else
g_bLogSyslog = true;
#endif
} else
sLog = FixupFilename ( hSearchd["log"].cstr() );
}
}

umask ( 066 );
Expand Down Expand Up @@ -19332,7 +19319,7 @@ void StopOrStopWaitAnother ( CSphVariant * v, bool bWait ) REQUIRES ( MainThread
if ( !v )
sphFatal ( "stop: option 'pid_file' not found in '%s' section 'searchd'", g_sConfigFile.cstr () );

CSphString sPidFile = FixupFilename ( v->cstr () );
CSphString sPidFile = v->cstr();
FILE * fp = fopen ( sPidFile.cstr(), "r" );
if ( !fp )
sphFatal ( "stop: pid file '%s' does not exist or is not readable", sPidFile.cstr() );
Expand Down Expand Up @@ -19801,7 +19788,7 @@ int WINAPI ServiceMain ( int argc, char **argv ) EXCLUDES (MainThread)
// create the pid
if ( bOptPIDFile )
{
g_sPidFile = FixupFilename ( hSearchdpre["pid_file"].cstr() );
g_sPidFile = hSearchdpre["pid_file"].cstr();

g_iPidFD = ::open ( g_sPidFile.scstr(), O_CREAT | O_WRONLY, S_IREAD | S_IWRITE );
if ( g_iPidFD<0 )
Expand Down Expand Up @@ -19856,9 +19843,6 @@ int WINAPI ServiceMain ( int argc, char **argv ) EXCLUDES (MainThread)
g_bQuerySyslog = true;
else
{
#if _WIN32
sQueryLog = AppendWinInstallDir(sQueryLog);
#endif
g_iQueryLogFile = open ( sQueryLog.cstr(), O_CREAT | O_RDWR | O_APPEND, S_IREAD | S_IWRITE );
if ( g_iQueryLogFile<0 )
sphFatal ( "failed to open query log file '%s': %s", sQueryLog.cstr(), strerrorm(errno) );
Expand Down
4 changes: 0 additions & 4 deletions src/searchdconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,6 @@ static bool SetupConfiglessMode ( const CSphConfig & hConf, const CSphString & s

g_sDataDir = hSearchd["data_dir"].strval();

#if _WIN32
g_sDataDir = AppendWinInstallDir(g_sDataDir);
#endif

if ( !sphDirExists ( g_sDataDir.cstr(), &sError ) )
{
sError.SetSprintf ( "%s; make sure it is accessible or remove data_dir from the config file", sError.cstr() );
Expand Down
23 changes: 0 additions & 23 deletions src/sphinxutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,29 +1615,6 @@ CSphString GetWinInstallDir()
{
return g_sWinInstallPath;
}


CSphString AppendWinInstallDir ( const CSphString & sDir )
{
if ( GetWinInstallDir().IsEmpty() )
return sDir;

CSphString sPath1 = sphNormalizePath ( sDir );
CSphString sPath2 = sphNormalizePath ( GetWinInstallDir() );
sPath1.ToLower();
sPath2.ToLower();

if ( sPath1.Begins ( sPath2.cstr() ) && sPath1.cstr()[sPath2.Length()]=='/' )
return sDir;

const char * DEFAULT_INSTALL_PATH = "c:/manticore/";
if ( !sPath1.Begins(DEFAULT_INSTALL_PATH) )
return sDir;

CSphString sCut = sPath1.SubString ( strlen(DEFAULT_INSTALL_PATH)-1, sPath1.Length()-strlen(DEFAULT_INSTALL_PATH)+1 );
sCut.SetSprintf ( "%s%s", sPath2.cstr(), sCut.cstr() );
return sCut;
}
#endif

/////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion src/sphinxutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ BYTE Pearson8 ( const BYTE * pBuf, int iLen );
#if _WIN32
void CheckWinInstall();
CSphString GetWinInstallDir();
CSphString AppendWinInstallDir ( const CSphString & sDir );
#endif

#endif // _sphinxutils_

0 comments on commit f381ad2

Please # to comment.