]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add the -1, --oneshot option which causes dhcpcd to exit once an
authorRoy Marples <roy@marples.name>
Thu, 14 Jan 2016 17:05:16 +0000 (17:05 +0000)
committerRoy Marples <roy@marples.name>
Thu, 14 Jan 2016 17:05:16 +0000 (17:05 +0000)
interface has been configured.

dhcpcd.8.in
dhcpcd.c
if-options.c
if-options.h

index f5039980fbcccbfccc01dc3e66504619b14576d9..890e5a7de3a4de56b6dc06f9632008321ae910cb 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 7, 2016
+.Dd January 14, 2016
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -30,7 +30,7 @@
 .Nd a DHCP client
 .Sh SYNOPSIS
 .Nm
-.Op Fl 46ABbDdEGgHJKLMNPpqTV
+.Op Fl 146ABbDdEGgHJKLMNPpqTV
 .Op Fl C , Fl Fl nohook Ar hook
 .Op Fl c , Fl Fl script Ar script
 .Op Fl e , Fl Fl env Ar value
@@ -569,6 +569,11 @@ However, there are sometimes situations where you don't want the things to be
 configured exactly how the the DHCP server wants.
 Here are some options that deal with turning these bits off.
 .Bl -tag -width indent
+.It Fl 1 , Fl Fl oneshot
+Exit after configuring an interface.
+Use the
+.Fl w , Fl Fl waitip
+option to specify which protocol(s) to configure before exiting.
 .It Fl 4 , Fl Fl ipv4only
 Configure IPv4 only.
 .It Fl 6 , Fl Fl ipv6only
index 0edc244682d86bf77873172825fedf7144ab8be9..5ca9f321fd88c218be1d6f1136252917ae93881b 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -318,6 +318,12 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
                        return 0;
        }
 
+       if (ctx->options & DHCPCD_ONESHOT) {
+               logger(ctx, LOG_INFO, "exiting due to oneshot");
+               eloop_exit(ctx->eloop, EXIT_SUCCESS);
+               return 0;
+       }
+
        eloop_timeout_delete(ctx->eloop, handle_exit_timeout, ctx);
        if (ctx->options & DHCPCD_DAEMONISED ||
            !(ctx->options & DHCPCD_DAEMONISE))
index de0c3ab724954e69d23d6e288d16903f5449c0bd..9b662aad07d8bde7fdb45abc3af78f2924a1e13f 100644 (file)
@@ -153,6 +153,9 @@ const struct option cf_options[] = {
        {"whitelist",       required_argument, NULL, 'W'},
        {"blacklist",       required_argument, NULL, 'X'},
        {"denyinterfaces",  required_argument, NULL, 'Z'},
+       {"oneshot",         no_argument,       NULL, '1'},
+       {"ipv4only",        no_argument,       NULL, '4'},
+       {"ipv6only",        no_argument,       NULL, '6'},
        {"arping",          required_argument, NULL, O_ARPING},
        {"destination",     required_argument, NULL, O_DESTINATION},
        {"fallback",        required_argument, NULL, O_FALLBACK},
@@ -164,8 +167,6 @@ const struct option cf_options[] = {
        {"ipv6ra_own",      no_argument,       NULL, O_IPV6RA_OWN},
        {"ipv6ra_own_default", no_argument,    NULL, O_IPV6RA_OWN_D},
        {"ipv6ra_accept_nopublic", no_argument, NULL, O_IPV6RA_ACCEPT_NOPUBLIC},
-       {"ipv4only",        no_argument,       NULL, '4'},
-       {"ipv6only",        no_argument,       NULL, '6'},
        {"ipv4",            no_argument,       NULL, O_IPV4},
        {"noipv4",          no_argument,       NULL, O_NOIPV4},
        {"ipv6",            no_argument,       NULL, O_IPV6},
@@ -1178,6 +1179,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                if (ifname == NULL)
                        ctx->ifdv = splitv(ctx, &ctx->ifdc, ctx->ifdv, arg);
                break;
+       case '1':
+               ifo->options |= DHCPCD_ONESHOT;
+               break;
        case '4':
                ifo->options &= ~DHCPCD_IPV6;
                ifo->options |= DHCPCD_IPV4;
index a6a98f8a90a20394f7cc538217a4ea43611d27b9..66b87d8de3324a2f9e31d607f79d5689f0d0fc06 100644 (file)
@@ -41,7 +41,7 @@
 
 /* Don't set any optional arguments here so we retain POSIX
  * compatibility with getopt */
-#define IF_OPTS "46bc:de:f:gh:i:j:kl:m:no:pqr:s:t:u:v:wxy:z:" \
+#define IF_OPTS "146bc:de:f:gh:i:j:kl:m:no:pqr:s:t:u:v:wxy:z:" \
                "ABC:DEF:GHI:JKLMNO:PQ:S:TUVW:X:Z:"
 #define NOERR_IF_OPTS          ":" IF_OPTS
 
 #define DHCPCD_BOOTP                   (1ULL << 57)
 #define DHCPCD_INITIAL_DELAY           (1ULL << 58)
 #define DHCPCD_PRINT_PIDFILE           (1ULL << 59)
+#define DHCPCD_ONESHOT                 (1ULL << 60)
 
 #define DHCPCD_NODROP  (DHCPCD_EXITING | DHCPCD_PERSISTENT)