diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -42,9 +42,15 @@ int main(int argc, char *argv[]) int jobnum; char *jobname; int framenum; - +int counter; /* Parses arguments, skips if there are no args */ +for(counter=0; counter \nStarts a distren slave\n\t-h\tshow this help\n\t-c\tregisters a user with [username] and [emailaddr] \n"); + return 2; + } +} if(argc>1 && (strcmp("-c", argv[1]) == 0)) { @@ -53,7 +59,7 @@ int framenum; if(argc != 4) { - fprintf(stderr, "I need more arguments!\n%d is not enough!\n Invoke 'distrenslave -c to register. \n Already registered? Edit your distrenslave.conf file!'", argc - 1); + fprintf(stderr, "I need more arguments!\n%d is not enough!\n Invoke 'distrenslave -c to register. \n Already registered? Edit your distrenslave.conf file!\n'", argc - 1); return 234; } @@ -65,7 +71,7 @@ int framenum; fprintf(stderr, "I want to see an '@' in your email address!\n%s may be good enough for you, but I need more!\n", email); return 235; } - register_user(username, email); // register_user returns a uniquely random url to a key + // register_user(username, email); // register_user returns a uniquely random url to a key */ fprintf(stderr, "You registered, hopefully successfully. Invoke distrenslave with no args now."); } /* End arg parser */ @@ -88,20 +94,22 @@ options_init(argc,argv,&my_cfg, myopts, /* End option getter */ -/* If there's no key or username in the conf, let them know! */ - if(key == NULL || username == NULL){ - fprintf(stderr, "You didn't register! Please register (Invoke '%s -c to register) or add your username to distrenslave.conf\n", argv[0]); +/* If there's no key or username in the conf, or if they're at the default (!key/!username) let the user know! */ + if(key == NULL || username == NULL || strcmp(key, "!key") == 0 || strcmp(username, "!username") == 0 ){ + fprintf(stderr, "\nYou didn't register!\nPlease register or edit your config. (see -h)\nIf this error persists, check distrenslave.conf to ensure all items are filled.\n", argv[0]); } - else if(key != NULL || username != NULL){ + else if(key != NULL && username != NULL || key != "!key" && username != "username" ){ + fprintf(stderr, "Your username is %s, and your key is %s.\n",username, key); loginuser(username); // Logs in user to the server } else{ - fprintf(stderr,"Something is terribly wrong!!!"); + fprintf(stderr,"Something is terribly wrong!!!"); } -/* Rendering code */ +/* Somewhat pseudo Rendering code */ +/* if('slave recieves "start frame#, job#"'){ fprintf(stderr, "Got frame %d in job %d, preparing to render...",framenum,jobnum); get('http://distren.protofusion.org/srv/job%d.tgz', jobnum); // use curl @@ -121,6 +129,7 @@ options_init(argc,argv,&my_cfg, myopts, tell_the_server(DISTREN_REQUEST_DONEFRAME); // AKA "I'm done rendering that frame you sent me" // Slave now becomes idle, doesn't need to tell the server anything, ssh handles this. } +*/ return 0; } diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -22,6 +22,8 @@ * distrenslave -c username email@example.com */ #include +#include + void ssh_keygen(){ // Give me some args! @@ -77,12 +79,13 @@ void registeruser(char *username, char * void loginuser(char *username){ // Logs into sandboxed user on zserver2 as a client, currently does nothing + char *userhost = strcat(username, "@protofusion.org"); // Throws @protofusion.org after the username char buf[10]; struct execio *testrem; char *execargv[] = { "ssh", - "username@protofusion.org", // username must be read from the conf + userhost, // username and hostname "-i", "username.rsa", // Key created from registeruser() "-p", @@ -105,7 +108,8 @@ void loginuser(char *username){ execio_close(testrem); } -/* Replaces username and key in the slave's conf file, currently pseudo */ +/* Replaces username and key in the slave's conf file, currently pseudo, add to .h!!! */ +/* void conf_replace(char *username, char *key){ // Doesn't delete anything! :D mktemp(); // Gets a new file to put data into @@ -116,12 +120,14 @@ void conf_replace(char *username, char * fsync(); // fsync the file we wrote data to rename(); // rename the old file to the new file } +*/ /* Executors */ /* It seems that the client will need to know the job number. Is finish_frame going to be on the client or the server? we gotta figure that out! */ + void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame) { char *frame_str; diff --git a/src/server/slavefuncs.h b/src/server/slavefuncs.h --- a/src/server/slavefuncs.h +++ b/src/server/slavefuncs.h @@ -21,6 +21,7 @@ #define _DISTREN_SLAVEFUNCS_H #include "blendjob.h" +void ssh_keygen(); void registeruser(char *username, char *email); void loginuser(char *username); void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame);