Merge pull request #892 from belisarius222/fleet-opts

-u <pill url> command-line flag
This commit is contained in:
cgyarvin 2017-10-30 17:52:16 -07:00 committed by GitHub
commit 94cfd1fa17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 38 deletions

View File

@ -7,7 +7,7 @@
/* u3m_boot(): start the u3 system.
*/
void
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c);
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c, c3_c *url_c);
/* u3m_bail(): bail out. Does not return.
**

View File

@ -530,34 +530,35 @@
/* u3_opts: command line configuration.
*/
typedef struct _u3_opts {
c3_c* imp_c; // -I, czar name
c3_c* nam_c; // -n, unix hostname
c3_c* raf_c; // -r, raft flotilla
c3_c* who_c; // -w, begin with ticket
c3_c* tic_c; // -t, ticket value
c3_c* pil_c; // -B, bootstrap from
c3_c* arv_c; // -A, initial sync from
c3_c* gen_c; // -G, czar generator
c3_w kno_w; // -k, kernel version
c3_w fuz_w; // -f, fuzz testing
c3_s por_s; // -p, ames port
c3_s rop_s; // -l, raft port
c3_c* imp_c; // -I, czar name
c3_c* nam_c; // -n, unix hostname
c3_c* pil_c; // -B, bootstrap from
c3_c* raf_c; // -r, raft flotilla
c3_c* tic_c; // -t, ticket value
c3_c* url_c; // -u, pill url
c3_c* who_c; // -w, begin with ticket
c3_o abo; // -a
c3_o bat; // -b, batch create
c3_o gab; // -g
c3_o dem; // -d, daemon
c3_o dry; // -D, dry compute
c3_o tex; // -x, exit after loading
c3_o fog; // -X, skip last event
c3_o fak; // -F, fake carrier
c3_o fog; // -X, skip last event
c3_o gab; // -g, run with garbage collector
c3_o loh; // -L, local-only networking
c3_o pro; // -P, profile
c3_o veb; // -v, verbose (inverse of -q)
c3_o nuu; // -c, new pier
c3_o qui; // -q, quiet
c3_o vno; // -V, replay without reboots
c3_o mem; // -M, memory madness
c3_o nuu; // -c, new pier
c3_o pro; // -P, profile
c3_o qui; // -q, quiet
c3_o rep; // -R, report build info
c3_o tex; // -x, exit after loading
c3_o veb; // -v, verbose (inverse of -q)
c3_o vno; // -V, replay without reboots
c3_s por_s; // -p, ames port
c3_s rop_s; // -l, raft port
c3_w fuz_w; // -f, fuzz testing
c3_w kno_w; // -k, kernel version
} u3_opts;
/* u3_host: entire host.

View File

@ -1502,7 +1502,7 @@ _cm_init(c3_o chk_o)
/* _boot_home(): create ship directory. */
static void
_boot_home(c3_c *dir_c, c3_c *pil_c)
_boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c)
{
c3_c ful_c[2048];
@ -1543,7 +1543,6 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
exit(1);
}
} else {
c3_c *url_c = "https://bootstrap.urbit.org/latest.pill";
CURL *curl;
CURLcode result;
FILE *file;
@ -1575,7 +1574,7 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
/* u3m_boot(): start the u3 system.
*/
void
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c, c3_c *url_c)
{
/* Activate the loom.
*/
@ -1602,7 +1601,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
if ( _(nuu_o) ) {
c3_c ful_c[2048];
_boot_home(dir_c, pil_c);
_boot_home(dir_c, pil_c, url_c);
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);

View File

@ -67,22 +67,22 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.abo = c3n;
u3_Host.ops_u.bat = c3n;
u3_Host.ops_u.dem = c3n;
u3_Host.ops_u.dry = c3n;
u3_Host.ops_u.fak = c3n;
u3_Host.ops_u.fog = c3n;
u3_Host.ops_u.gab = c3n;
u3_Host.ops_u.loh = c3n;
u3_Host.ops_u.dem = c3n;
u3_Host.ops_u.fog = c3n;
u3_Host.ops_u.fak = c3n;
u3_Host.ops_u.tex = c3n;
u3_Host.ops_u.pro = c3n;
u3_Host.ops_u.dry = c3n;
u3_Host.ops_u.veb = c3n;
u3_Host.ops_u.qui = c3n;
u3_Host.ops_u.nuu = c3n;
u3_Host.ops_u.mem = c3n;
u3_Host.ops_u.nuu = c3n;
u3_Host.ops_u.pro = c3n;
u3_Host.ops_u.qui = c3n;
u3_Host.ops_u.rep = c3n;
u3_Host.ops_u.tex = c3n;
u3_Host.ops_u.veb = c3n;
u3_Host.ops_u.kno_w = DefaultKernel;
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:u:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
switch ( ch_i ) {
case 'M': {
u3_Host.ops_u.mem = c3y;
@ -109,6 +109,10 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.nuu = c3y;
break;
}
case 'u': {
u3_Host.ops_u.url_c = strdup(optarg);
break;
}
case 't': {
u3_Host.ops_u.tic_c = _main_presig(optarg);
break;
@ -210,10 +214,10 @@ _main_getopt(c3_i argc, c3_c** argv)
}
if ( u3_Host.ops_u.tic_c == 0 && u3_Host.ops_u.who_c != 0 ) {
c3_c tic_c[29];
printf("your ticket: ~");
scanf("%28s",tic_c);
u3_Host.ops_u.tic_c = _main_presig(tic_c);
c3_c tic_c[29];
printf("your ticket: ~");
scanf("%28s",tic_c);
u3_Host.ops_u.tic_c = _main_presig(tic_c);
}
if ( c3y == u3_Host.ops_u.bat ) {
@ -226,6 +230,13 @@ _main_getopt(c3_i argc, c3_c** argv)
return c3n;
}
if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.url_c != 0) {
fprintf(stderr, "-u only makes sense when bootstrapping a new instance\n");
return c3n;
} else if ( u3_Host.ops_u.nuu == c3y && u3_Host.ops_u.url_c == 0 ) {
u3_Host.ops_u.url_c = "https://bootstrap.urbit.org/latest.pill";
}
if ( u3_Host.ops_u.pil_c != 0 ) {
struct stat s;
if ( stat(u3_Host.ops_u.pil_c, &s) != 0 ) {
@ -302,6 +313,7 @@ u3_ve_usage(c3_i argc, c3_c** argv)
"-r host Initial peer address\n",
"-R Report urbit build info\n",
"-t ticket Use ~ticket automatically\n",
"-u url URL from which to download pill\n",
"-v Verbose\n",
"-w name Immediately upgrade to ~name\n",
"-x Exit immediately\n",
@ -553,7 +565,8 @@ main(c3_i argc,
u3m_boot(u3_Host.ops_u.nuu,
u3_Host.ops_u.gab,
u3_Host.dir_c,
u3_Host.ops_u.pil_c);
u3_Host.ops_u.pil_c,
u3_Host.ops_u.url_c);
/* Start Arvo.
*/