diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -19,8 +19,8 @@ */ #include "protocol.h" -#include "options.h" /* Confuse, etc. */ -#include "slavefuncs.h" /* Slave functions */ +#include "options.h" +#include "slavefuncs.h" #include "asprintf.h" #include "remoteio.h" @@ -35,49 +35,15 @@ int main(int argc, char *argv[]) int counter; - /* Parses arguments, skips if there are no args */ + /* Parse arguments */ for(counter = 0; counter < argc; counter ++) if(strcmp(argv[counter], "-h") == 0) { - fprintf(stderr, "Usage: distrenslave [option] \nStarts a distren slave\n\t-h\tshow this help\n\t-c\tregisters a user with [username] and [emailaddr] \n"); + fprintf(stderr, "Usage: distrenslave [option] \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)) - { - char *username; - char *email; - - 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!\n'", argc - 1); - return 234; - } - - username = argv[2]; - email = argv[3]; - - if(!strchr(email, '@')) - { - 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; - } - if( register_user(username, email) == 1) - { - // register_user generates a key, too */ - curlpost(SYSCONFDIR "/distren.id_rsa", "http://protofusion.org/distren/keys"); - fprintf(stderr, "Registration successful. You may now invoke distrenslave with no arguments.\n"); - return 0; - } - else - { - fprintf(stderr, "Please try again! :D\n"); - return 0; - } - } - /* End arg parser */ - - /* Option getter: Creates vars to grab stuff from conf, uses the options include to grab this data */ + /* Get conf data */ char *username; char *datadir; cfg_t * my_cfg; @@ -87,27 +53,23 @@ int main(int argc, char *argv[]) CFG_END() }; struct options_common *commonopts; - username = NULL; options_init(argc, argv, &my_cfg, myopts, "slave", &commonopts); - /* End option getter */ + - /* Should _not_ be run every day-ish if the slave is constantly running. */ - /* software_updatecheck(datadir); */ - - /* Notifies the user if there is no username in the conf file */ + /* Notifies the user if there no username in .conf */ if(username == NULL || 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"); + fprintf(stderr, "\nYou didn't register!\nPlease register on the DistRen website.\nIf this error persists, check distrenslave.conf to ensure all items are filled.\n"); else if( username != NULL || strcmp(username, "!username") != 0 ) { - // Logs ya in: + // Log in the user if(login_user(username) == 1){ fprintf(stderr, "You should now be logged into distren.\n"); } else { - fprintf(stderr, "Login failed. I have no clue why. Sorry.\n"); + fprintf(stderr, "Login failed.\n"); return 0; } }