From 436c49a681de263ab25a60035c0e535345ffb00c Mon Sep 17 00:00:00 2001 From: obrien Date: Wed, 10 Feb 1999 23:51:25 +0000 Subject: add -1 option: Try once, if we fail, EXIT Obtained from: OpenBSD --- contrib/isc-dhcp/client/dhclient.8 | 6 ++++++ contrib/isc-dhcp/client/dhclient.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'contrib/isc-dhcp') diff --git a/contrib/isc-dhcp/client/dhclient.8 b/contrib/isc-dhcp/client/dhclient.8 index 625296d..a6f2d55 100644 --- a/contrib/isc-dhcp/client/dhclient.8 +++ b/contrib/isc-dhcp/client/dhclient.8 @@ -45,6 +45,9 @@ dhclient - Dynamic Host Configuration Protocol Client .I port ] [ +.B -1 +] +[ .B -d ] [ @@ -128,6 +131,9 @@ To run force dhclient to always run as a foreground process, the .B -d flag should be specified. This is useful when running dhclient under a debugger, or when running it out of inittab on System V systems. +The +.B -1 +flag cause dhclient to try once to get a lease. If it fails, dhclient exits. .PP .SH CONFIGURATION The syntax of the dhclient.conf(8) file is discussed seperately. diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c index eb4d268..a5fbdba 100644 --- a/contrib/isc-dhcp/client/dhclient.c +++ b/contrib/isc-dhcp/client/dhclient.c @@ -92,6 +92,7 @@ u_int16_t remote_port; int log_priority; int no_daemon; int save_scripts; +int onetry; static void usage PROTO ((void)); @@ -126,6 +127,8 @@ int main (argc, argv, envp) no_daemon = 1; } else if (!strcmp (argv [i], "-D")) { save_scripts = 1; + } else if (!strcmp (argv [i], "-1")) { + onetry = 1; } else if (argv [i][0] == '-') { usage (); } else { @@ -240,7 +243,7 @@ int main (argc, argv, envp) static void usage () { - error ("Usage: dhclient [-c] [-p ] [interface]"); + error ("Usage: dhclient [-1] [-c] [-p ] [interface]"); } void cleanup () @@ -1090,6 +1093,10 @@ void state_panic (ipp) /* No leases were available, or what was available didn't work, so tell the shell script that we failed to allocate an address, and try again later. */ + if (onetry) { + exit(1); + note ("Unable to obtain a lease on first try - exiting.\n"); + } note ("No working leases in persistent database - sleeping.\n"); script_init (ip, "FAIL", (struct string_list *)0); if (ip -> client -> alias) -- cgit v1.1