work on make install.

This commit is contained in:
mwells
2014-05-11 12:48:56 -07:00
parent aa76b36bf0
commit 70016ec3a3
7 changed files with 106 additions and 28 deletions

@ -466,6 +466,20 @@ Msg6a.o:
geo_ip_table.o: geo_ip_table.cpp geo_ip_table.h
$(CC) $(DEFS) -m32 -Wall -pipe -c $*.cpp
install:
# gigablast will copy over the necessary files. it has a list of the
# necessary files and that list changes over time so it is better to let gb
# deal with it.
mkdir /var/gigablast/
mkdir /var/gigablast/shard0/
./gb copyfiles /var/gigablast/shard0/
# if user types 'gb' it will use the binary in /var/gigablast/shard0/
ln -s /var/gigablast/shard0/gb /usr/bin/gb
# if machine restarts
ln -s /var/gigablast/shard0/gb /etc/init.d/gb
# it will start up gb
ln -s /etc/init.d/gb /etc/rc3.d/S99gb
.cpp.o:
$(CC) $(DEFS) $(CPPFLAGS) -c $*.cpp

@ -5458,7 +5458,7 @@ void Parms::init ( ) {
m->m_cgi = "live";
m->m_off = (char *)&g_conf.m_isLive - g;
m->m_type = TYPE_BOOL;
m->m_def = "0";
m->m_def = "1";
m->m_flags = PF_HIDDEN | PF_NOSAVE;
m++;

@ -150,25 +150,22 @@ char *g_files[] = {
"antiword-dir/koi8-r.txt",
"antiword-dir/koi8-u.txt",
"antiword-dir/roman.txt",
// . thumbnail generation
// . use 'apt-get install netpbm' to install
//"/usr/bin/giftopnm",
//"/usr/bin/tifftopnm",
//"/usr/bin/pngtopnm",
//"/usr/bin/jpegtopnm",
//"/usr/bin/bmptopnm",
//"/usr/bin/pnmscale",
//"/usr/bin/ppmtojpeg",
//"/usr/sbin/smartctl",
//"giftopnm",
//"tifftopnm",
//"pngtopnm",
//"jpegtopnm",
//"bmptopnm",
//"pnmscale",
//"ppmtojpeg",
// . thumbnail generation
// . i used 'apt-get install netpbm' to install
"bmptopnm",
"giftopnm",
"jpegtopnm",
"libjpeg.so.62",
"libnetpbm.so.10",
"libpng12.so.0",
"libtiff.so.4",
"libz.so.1",
"LICENSE",
"pngtopnm",
"pnmscale",
"ppmtojpeg",
"tifftopnm",
//"smartctl",
@ -188,6 +185,25 @@ char *g_files[] = {
};
bool Process::getFilesToCopy ( char *srcDir , SafeBuf *buf ) {
// sanirty
long slen = gbstrlen(srcDir);
if ( srcDir[slen-1] != '/' ) { char *xx=NULL;*xx=0; }
for ( long i = 0 ; i < (long)sizeof(g_files)/4 ; i++ ) {
// terminate?
if ( ! g_files[i] ) break;
// if not first
if ( i > 0 ) buf->pushChar(' ');
// append it
buf->safePrintf("%s%s"
, srcDir
, g_files[i] );
}
return true;
}
bool Process::checkFiles ( char *dir ) {
@ -265,6 +281,11 @@ bool Process::checkFiles ( char *dir ) {
}
if ( needsFiles ) {
log("db: Missing files. See above. Exiting.");
return false;
}
//if ( needsFiles ) {
// log("db: use 'apt-get install -y netpbm' to install "
// "pnmfiles");
@ -286,12 +307,16 @@ bool Process::checkFiles ( char *dir ) {
if ( ! g_conf.m_isLive ) return true;
m_swapEnabled = 0;
// first check to make sure swap is off
SafeBuf psb;
if ( psb.fillFromFile("/proc/swaps") < 0 ) {
log("gb: failed to read /proc/swaps");
if ( ! g_errno ) g_errno = EBADENGINEER;
return true;
//if ( ! g_errno ) g_errno = EBADENGINEER;
//return true;
// if we don't know if swap is enabled or not, use -1
m_swapEnabled = -1;
}
/*
@ -307,9 +332,15 @@ bool Process::checkFiles ( char *dir ) {
mstrerror(g_errno));
buf[size] = '\0';
*/
char *buf = psb.getBufStart();
if ( strstr ( buf,"dev" ) )
return log("gb: can not start live gb with swap enabled.");
// we should redbox this! or at least be on the optimizations page
if ( m_swapEnabled == 0 ) {
char *buf = psb.getBufStart();
if ( strstr ( buf,"dev" ) )
//return log("gb: can not start live gb with swap "
//"enabled.");
m_swapEnabled = 1;
}
// . make sure elvtune is being set right
// . must be in /etc/rcS.d/S99local
@ -336,6 +367,9 @@ bool Process::checkFiles ( char *dir ) {
mfree ( buf , size+1, "S99" );
*/
// now that we are open source skip the checks below
return true;
// check kernel version
FILE *fd;
fd = fopen ( "/proc/version" , "r" );
@ -377,7 +411,7 @@ bool Process::checkFiles ( char *dir ) {
"MST 2008\n")== 0)
return true;
log("gb: kernel version is not an approved version.");
return false;
//return false;
return true;
}

@ -16,6 +16,7 @@ class Process {
public:
bool getFilesToCopy ( char *srcDir , class SafeBuf *buf ) ;
bool checkFiles ( char *dir );
// . the big save command
@ -94,6 +95,7 @@ class Process {
long m_desiredFanState;
float m_diskUsage;
long long m_diskAvail;
char m_swapEnabled;
};
extern Process g_process;

@ -1039,13 +1039,14 @@ bool Speller::loadUnifiedDict() {
char *tail2 = m_unifiedBuf.getBufStart()+h2-1000;
h = hash64 ( tail1 , 1000 , h );
h = hash64 ( tail2 , 1000 , h );
long long n = 8346765853685546681LL;
//long long n = 8346765853685546681LL;
long long n = -14450509118443930LL;
if ( h != n ) {
log("gb: unifiedDict-buf.txt or "
"unifiedDict-map.dat "
"checksum is not approved for "
"live service (%lli != %lli)" ,h,n);
return false;
//return false;
}
return true;

@ -288,7 +288,7 @@ bool Wiktionary::load() {
log("gb: %s or %s checksum is not approved for "
"live service (%lli != %lli)", ff3, ff4,
h,nn);
return false;
//return false;
}
return true;

@ -181,6 +181,8 @@ bool g_recoveryMode = false;
bool isRecoveryFutile ( ) ;
bool copyFiles ( char *dstDir ) ;
//////
//
// if seo.o is being linked to it needs to override these weak stubs:
@ -1811,6 +1813,12 @@ int main2 ( int argc , char *argv[] ) {
char *cmd = argv[cmdarg+1];
return install ( ifk_dsh2 , -1,NULL,NULL,-1, cmd );
}
// gb copyfiles, like gb install but takes a dir not a host #
if ( strcmp ( cmd , "copyfiles" ) == 0 ) {
if ( cmdarg + 1 >= argc ) goto printHelp;
char *dir = argv[cmdarg+1];
return copyFiles ( dir );
}
// gb install
if ( strcmp ( cmd , "install" ) == 0 ) {
// get hostId to install TO (-1 means all)
@ -16990,3 +16998,22 @@ char *getcwd2 ( char *arg ) {
return s_cwdBuf;
}
bool copyFiles ( char *dstDir ) {
char *srcDir = "./";
SafeBuf fileListBuf;
g_process.getFilesToCopy ( srcDir , &fileListBuf );
SafeBuf tmp;
tmp.safePrintf(
"rcp -pr %s %s"
, fileListBuf.getBufStart()
, dstDir
);
//log(LOG_INIT,"admin: %s", tmp.getBufStart());
fprintf(stderr,"\nRunning cmd: %s\n",tmp.getBufStart());
system ( tmp.getBufStart() );
return true;
}