diff --git a/src/server/simpleslave.c b/src/server/simpleslave.c --- a/src/server/simpleslave.c +++ b/src/server/simpleslave.c @@ -62,8 +62,9 @@ int main(int argc, char *argv[]) hostname = NULL; char curopt; + int runBenchmark = 0; - while(((char)-1) != (curopt = getopt(argc, argv, "u:th"))) + while(((char)-1) != (curopt = getopt(argc, argv, "u:rh"))) { if(curopt == ':') { @@ -77,17 +78,19 @@ int main(int argc, char *argv[]) } else if(curopt == 'h') { - fprintf(stderr, "Usage: distrenslave [option] \nStarts a distren slave\n\t-u\tset username (run after fresh install)\n\t-t\tEnter test mode\n\t-h\tshow this help\n"); + fprintf(stderr, "Usage: distrenslave [option] \nStarts a distren slave\n\t-u\tset username (run after fresh install)\n\t-r\tRecalculate render power (benchmark)\n\t-h\tshow this help\n"); return 2; } - else if(curopt == 't') + else if(curopt == 'r') { - slaveTest(); - return 0; + runBenchmark = 1; + break; } else if(curopt == 'u') username = strdup(optarg); - fprintf(stderr, "Putting username \"%s\" in distrenslave.conf\n", username); + if(DEBUG) + fprintf(stderr, "Putting username \"%s\" in distrenslave.conf\n", username); + conf_replace("distrenslave.conf", "!username", username); fprintf(stderr, "Please invoke distrenslave with no arguments to run with the username you just set\n"); return 0; @@ -123,13 +126,12 @@ int main(int argc, char *argv[]) } - /* Notifies the user if there no username in .conf */ if(checkUsername(username)) return 1; if(!strncmp(password, "!password",10)) { - fprintf(stderr, "You haven't specified a password. Please edit your distrenslave.conf file appropriately\n"); + fprintf(stderr, "You haven't specified a password. Please edit distrenslave.conf!\n"); return 1; } @@ -157,15 +159,13 @@ int main(int argc, char *argv[]) int haveWork = 0; int quit = 0; - fprintf(stderr,"DistRenSimpleSlave Pre-Alpha\n\t- this version of DistRen is still experimental\n\t so things might go horribly wrong!\n"); + fprintf(stderr,"\nDistRen SimpleSlave Pre-Alpha %s\n- Experimental build: Use at your own risk!\n\n", PACKAGE_VERSION); int benchmarkTime = 0; int renderPower = 0; - char option[1] = ""; - fprintf(stderr,"Do you want to recalculate render power? (y/n): "); - scanf("%s", option); - if(!strcmp(option, "y")) + // @TODO: create _web function to force recalc if !isset($render_power) on server + if(runBenchmark) { if(slaveBenchmark(datadir, &benchmarkTime, &renderPower)) { @@ -177,8 +177,10 @@ int main(int argc, char *argv[]) fprintf(stderr,"Benchmark successful, time taken was %d seconds, giving you a render power of %d.\n", benchmarkTime, renderPower); _web_setrenderpower(slavekey, password, renderPower); + return 0; } } + if(!DEBUG) fprintf(stderr, "Running.."); // Main loop diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -538,7 +538,7 @@ int checkUsername(char *username) { // Log in the user if(login_user(username) == 1){ - fprintf(stderr, "You should now be logged into distren.\n"); + // Logged in OK return 0; } else @@ -727,7 +727,8 @@ void _web_resetframe(int slavekey, char } void _web_startframe(int slavekey, char *slavepass, int jobnum, int framenum){ - fprintf(stderr,"Marking frame %d started on server... ",framenum); + if(DEBUG) + fprintf(stderr,"Marking frame %d started on server... ",framenum); char *url; _distren_asprintf(&url,"http://dev.distren.org/slave/act.php?mode=startframe&slavekey=%d&slavepass=%s&jobnum=%d&framenum=%d", slavekey, slavepass, jobnum, framenum); struct _web_memorystruct data = _web_getrequest(url);