You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
* $Id: mycnfUpgrade.cpp 64 2006-10-12 22:21:51Z dhill $
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************************/
|
||||
/**
|
||||
* @file
|
||||
@ -54,147 +54,170 @@
|
||||
using namespace std;
|
||||
using namespace oam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Oam oam;
|
||||
Oam oam;
|
||||
|
||||
//check for port argument
|
||||
string mysqlPort;
|
||||
if (argc > 1) {
|
||||
mysqlPort = argv[1];
|
||||
//check for port argument
|
||||
string mysqlPort;
|
||||
|
||||
// set mysql password
|
||||
oam.changeMyCnf( "port", mysqlPort );
|
||||
exit (0);
|
||||
}
|
||||
if (argc > 1)
|
||||
{
|
||||
mysqlPort = argv[1];
|
||||
|
||||
//my.cnf file
|
||||
string mycnfFile = startup::StartUp::installDir() + "/mysql/my.cnf";
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
if (!mycnffile) {
|
||||
cerr << "mycnfUpgrade - my.cnf file not found: " << mycnfFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
// set mysql password
|
||||
oam.changeMyCnf( "port", mysqlPort );
|
||||
exit (0);
|
||||
}
|
||||
|
||||
//my.cnf.rpmsave file
|
||||
string mycnfsaveFile = startup::StartUp::installDir() + "/mysql/my.cnf.rpmsave";
|
||||
ifstream mycnfsavefile (mycnfsaveFile.c_str());
|
||||
if (!mycnfsavefile) {
|
||||
cerr << "mycnfUpgrade - my.cnf.rpmsave file not found: " << mycnfsaveFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
//my.cnf file
|
||||
string mycnfFile = startup::StartUp::installDir() + "/mysql/my.cnf";
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
|
||||
//include arguments file
|
||||
string includeFile = startup::StartUp::installDir() + "/bin/myCnf-include-args.text";
|
||||
ifstream includefile (includeFile.c_str());
|
||||
if (!includefile) {
|
||||
cerr << "mycnfUpgrade - my.cnf include argument file not found: " << includeFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
if (!mycnffile)
|
||||
{
|
||||
cerr << "mycnfUpgrade - my.cnf file not found: " << mycnfFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//exclude arguments file
|
||||
string excludeFile = startup::StartUp::installDir() + "/bin/myCnf-exclude-args.text";
|
||||
ifstream excludefile (excludeFile.c_str());
|
||||
if (!excludefile) {
|
||||
cerr << "mycnfUpgrade - my.cnf exclude argument file not found: "<< endl;
|
||||
exit (1);
|
||||
}
|
||||
//my.cnf.rpmsave file
|
||||
string mycnfsaveFile = startup::StartUp::installDir() + "/mysql/my.cnf.rpmsave";
|
||||
ifstream mycnfsavefile (mycnfsaveFile.c_str());
|
||||
|
||||
//go though include list
|
||||
char line[200];
|
||||
string includeArg;
|
||||
while (includefile.getline(line, 200))
|
||||
{
|
||||
includeArg = line;
|
||||
if (!mycnfsavefile)
|
||||
{
|
||||
cerr << "mycnfUpgrade - my.cnf.rpmsave file not found: " << mycnfsaveFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//see if in my.cnf.rpmsave
|
||||
ifstream mycnfsavefile (mycnfsaveFile.c_str());
|
||||
char line[200];
|
||||
string oldbuf;
|
||||
while (mycnfsavefile.getline(line, 200))
|
||||
{
|
||||
oldbuf = line;
|
||||
string::size_type pos = oldbuf.find(includeArg,0);
|
||||
if ( pos != string::npos ) {
|
||||
//found in my.cnf.rpmsave, check if this is commented out
|
||||
if ( line[0] != '#' )
|
||||
{
|
||||
// no, check in my.cnf and replace if exist or add if it doesn't
|
||||
//include arguments file
|
||||
string includeFile = startup::StartUp::installDir() + "/bin/myCnf-include-args.text";
|
||||
ifstream includefile (includeFile.c_str());
|
||||
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
vector <string> lines;
|
||||
char line1[200];
|
||||
string newbuf;
|
||||
bool updated = false;
|
||||
while (mycnffile.getline(line1, 200))
|
||||
{
|
||||
newbuf = line1;
|
||||
string::size_type pos = newbuf.find(includeArg,0);
|
||||
if ( pos != string::npos ) {
|
||||
newbuf = oldbuf;
|
||||
cout << "Updated argument: " << includeArg << endl;
|
||||
updated = true;
|
||||
}
|
||||
//output to temp file
|
||||
lines.push_back(newbuf);
|
||||
}
|
||||
if (!includefile)
|
||||
{
|
||||
cerr << "mycnfUpgrade - my.cnf include argument file not found: " << includeFile << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//write out a new my.cnf
|
||||
mycnffile.close();
|
||||
unlink (mycnfFile.c_str());
|
||||
ofstream newFile (mycnfFile.c_str());
|
||||
|
||||
//create new file
|
||||
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0666);
|
||||
|
||||
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
|
||||
newFile.close();
|
||||
|
||||
close(fd);
|
||||
//exclude arguments file
|
||||
string excludeFile = startup::StartUp::installDir() + "/bin/myCnf-exclude-args.text";
|
||||
ifstream excludefile (excludeFile.c_str());
|
||||
|
||||
if (!updated)
|
||||
{ //not found, so add
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
vector <string> lines;
|
||||
char line1[200];
|
||||
string newbuf;
|
||||
while (mycnffile.getline(line1, 200))
|
||||
{
|
||||
newbuf = line1;
|
||||
string::size_type pos = newbuf.find("[mysqld]",0);
|
||||
if ( pos != string::npos ) {
|
||||
lines.push_back(newbuf);
|
||||
newbuf = oldbuf;
|
||||
cout << "Added argument: " << includeArg << endl;
|
||||
}
|
||||
//output to temp file
|
||||
lines.push_back(newbuf);
|
||||
}
|
||||
if (!excludefile)
|
||||
{
|
||||
cerr << "mycnfUpgrade - my.cnf exclude argument file not found: " << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//write out a new my.cnf
|
||||
mycnffile.close();
|
||||
unlink (mycnfFile.c_str());
|
||||
ofstream newFile (mycnfFile.c_str());
|
||||
|
||||
//create new file
|
||||
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0666);
|
||||
|
||||
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
|
||||
newFile.close();
|
||||
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
//go though include list
|
||||
char line[200];
|
||||
string includeArg;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (includefile.getline(line, 200))
|
||||
{
|
||||
includeArg = line;
|
||||
|
||||
string cmd = "chown mysql:mysql " + mycnfFile;
|
||||
system(cmd.c_str());
|
||||
//see if in my.cnf.rpmsave
|
||||
ifstream mycnfsavefile (mycnfsaveFile.c_str());
|
||||
char line[200];
|
||||
string oldbuf;
|
||||
|
||||
exit (0);
|
||||
while (mycnfsavefile.getline(line, 200))
|
||||
{
|
||||
oldbuf = line;
|
||||
string::size_type pos = oldbuf.find(includeArg, 0);
|
||||
|
||||
if ( pos != string::npos )
|
||||
{
|
||||
//found in my.cnf.rpmsave, check if this is commented out
|
||||
if ( line[0] != '#' )
|
||||
{
|
||||
// no, check in my.cnf and replace if exist or add if it doesn't
|
||||
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
vector <string> lines;
|
||||
char line1[200];
|
||||
string newbuf;
|
||||
bool updated = false;
|
||||
|
||||
while (mycnffile.getline(line1, 200))
|
||||
{
|
||||
newbuf = line1;
|
||||
string::size_type pos = newbuf.find(includeArg, 0);
|
||||
|
||||
if ( pos != string::npos )
|
||||
{
|
||||
newbuf = oldbuf;
|
||||
cout << "Updated argument: " << includeArg << endl;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
//output to temp file
|
||||
lines.push_back(newbuf);
|
||||
}
|
||||
|
||||
//write out a new my.cnf
|
||||
mycnffile.close();
|
||||
unlink (mycnfFile.c_str());
|
||||
ofstream newFile (mycnfFile.c_str());
|
||||
|
||||
//create new file
|
||||
int fd = open(mycnfFile.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
|
||||
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
|
||||
newFile.close();
|
||||
|
||||
close(fd);
|
||||
|
||||
if (!updated)
|
||||
{
|
||||
//not found, so add
|
||||
ifstream mycnffile (mycnfFile.c_str());
|
||||
vector <string> lines;
|
||||
char line1[200];
|
||||
string newbuf;
|
||||
|
||||
while (mycnffile.getline(line1, 200))
|
||||
{
|
||||
newbuf = line1;
|
||||
string::size_type pos = newbuf.find("[mysqld]", 0);
|
||||
|
||||
if ( pos != string::npos )
|
||||
{
|
||||
lines.push_back(newbuf);
|
||||
newbuf = oldbuf;
|
||||
cout << "Added argument: " << includeArg << endl;
|
||||
}
|
||||
|
||||
//output to temp file
|
||||
lines.push_back(newbuf);
|
||||
}
|
||||
|
||||
//write out a new my.cnf
|
||||
mycnffile.close();
|
||||
unlink (mycnfFile.c_str());
|
||||
ofstream newFile (mycnfFile.c_str());
|
||||
|
||||
//create new file
|
||||
int fd = open(mycnfFile.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
|
||||
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
|
||||
newFile.close();
|
||||
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string cmd = "chown mysql:mysql " + mycnfFile;
|
||||
system(cmd.c_str());
|
||||
|
||||
exit (0);
|
||||
}
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
Reference in New Issue
Block a user