/* $Header: /CVSROOT/debris/debris.c,v 1.4 2005/08/15 00:47:45 tino Exp $ * * DebRIS: DEBian Remote Install Scripter * Main * * $Log: debris.c,v $ * Revision 1.4 2005/08/15 00:47:45 tino * updates for DebRIS improvements * * Revision 1.3 2005/08/13 22:59:12 tino * additional functions, see ChangeLog * * Revision 1.2 2005/07/25 03:04:18 tino * snprintf usage and minor other changes * * Revision 1.1 2005/06/01 02:12:34 tino * first version. As SirbeD is missing, this just does nothing yet. */ #define _GNU_SOURCE 1 #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include struct dris_config { int debug, verbose; const char *url; const char *pw; char id[100]; unsigned long pid, ppid; int fd; /* monitoring fd */ unsigned long long cnt; int result; struct dris_buf *out, *in; /* drisbuf.h */ int data; /* into in */ } config; #include "debris_version.h" #include "dristool.h" #include "drismd5.h" #include "drisbuf.h" #include "drisexec.h" #include "driscmds.h" #include "drisnext.h" int main(int argc, char **argv) { static const char vers[] = DEBRIS_VERSION; config.debug = 0; if (argc>1 && !strcmp(argv[1], "-d")) { config.debug = 1; argc--; argv++; } config.verbose = 0; if (argc>1 && !strcmp(argv[1], "-v")) { config.verbose = 1; argc--; argv++; } if (argc!=3) { fprintf(stderr, "Usage: ./debris [-d] [-v] url password >/dev/null\n" "\t\tversion %s compiled " __DATE__ "\n" "\t-d switches into debug mode\n" "\t-v switches into verbose mode\n" "\tURL points to a web server running SirbeD\n" "\tPASSWORD is the session password (failsafe proof)\n" "\tset env var all_proxy if to use a proxy\n" , vers ); return 1; } /* some initialization */ signal(SIGALRM, SIG_IGN); /* setup env */ config.url = argv[1]; config.pw = argv[2]; config.cnt = 0; config.pid = getpid(); config.ppid = getppid(); snprintf(config.id, sizeof config.id, "%llu.%llu %lu %lu", (unsigned long long)time(NULL), (unsigned long long)clock(), config.pid, config.ppid); config.out = dris_buf_add_s(dris_buf_new(), vers); /* a really simple command loop */ while (dris_next()) config.result = dris_cmd(); return 0; }