now pushes var=value to the environment when dhcpcd-run-hooks is run.
This allows the possibility to set env vars that hook scripts can work off.
A good example of this is 30-hostname so that force_hostname=YES can set
the hostname regardless of the current hostname.
--reconfigure now takes the short option -g.
need_hostname()
{
- case "$(hostname)" in
+ local hostname=""
+
+ case "$force_hostname" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) ;;
+ *) hostname="$(hostname)";;
+ esac
+ case "$hostname" in
""|"(none)"|localhost|localhost.localdomain)
[ -n "$new_host_name" -o -n "$new_fqdn_name" ];;
"$old_host_name"|"$old_fqdn_name")
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 25, 2009
+.Dd July 26, 2009
.Dt DHCPCD 8 SMM
.Os
.Sh NAME
.Nd an RFC 2131 compliant DHCP client
.Sh SYNOPSIS
.Nm
-.Op Fl bdeknpqABDEGKLTV
+.Op Fl bdgknpqABDEGKLTV
.Op Fl c , -script Ar script
+.Op Fl e , -env Ar value
.Op Fl f , -config Ar file
.Op Fl h , -hostname Ar hostname
.Op Fl i , -vendorclassid Ar vendorclassid
.Xr resolvconf 8 ,
if available, otherwise directly to
.Pa /etc/resolv.conf .
-If the hostname is currenly blank, (null) or localhost then
+If the hostname is currenly blank, (null) or localhost, or
+.Va force_hostname
+is YES or TRUE or 1 then
.Nm
sets the hostname to the one supplied by the DHCP server.
.Nm
Subsequent debug options stop
.Nm
from daemonising.
-.It Fl e , -reconfigure
+.It Fl e , -env Ar value
+Push
+.Ar value
+to the environment for use in
+.Xr dhcpcd-run-hooks 8 .
+For example, you can force the hostname hook to always set the hostname with
+.Fl e
+.Va force_hostname=YES .
+.It Fl g , -reconfigure
.Nm
will re-apply IP address, routing and run
.Xr dhcpcd-run-hooks 8
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{
switch (opt) {
- case 'e':
+ case 'g':
do_reconf = 1;
break;
case 'k':
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{
switch (opt) {
- case 'e':
- sig = SIGUSR1;
- break;
case 'f':
cffile = optarg;
break;
+ case 'g':
+ sig = SIGUSR1;
+ break;
case 'k':
sig = SIGHUP;
break;
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 25, 2009
+.Dd July 26, 2009
.Dt DHCPCD.CONF 5 SMM
.Os
.Sh NAME
is ignored if
.Ic whitelist
is set.
+.It Ic env Ar value
+Push
+.Ar value
+to the environment for use in
+.Xr dhcpcd-run-hooks 8 .
+For example, you can force the hostname hook to always set the hostname with
+.Ic env
+.Va force_hostname=YES .
.It Ic clientid Ar string
Send the
.Ar clientid .
{"background", no_argument, NULL, 'b'},
{"script", required_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'd'},
- {"reconfigure", no_argument, NULL, 'e'},
+ {"env", required_argument, NULL, 'e'},
{"config", required_argument, NULL, 'f'},
+ {"reconfigure", no_argument, NULL, 'g'},
{"hostname", optional_argument, NULL, 'h'},
{"vendorclassid", optional_argument, NULL, 'i'},
{"release", no_argument, NULL, 'k'},
struct rt *rt;
switch(opt) {
- case 'e': /* FALLTHROUGH */
+ case 'g': /* FALLTHROUGH */
case 'n': /* FALLTHROUGH */
case 'x': /* FALLTHROUGH */
case 'T': /* We need to handle non interface options */
case 'd':
ifo->options |= DHCPCD_DEBUG;
break;
+ case 'e':
+ add_environ(ifo, arg, 1);
+ break;
case 'h':
if (arg) {
s = parse_string(ifo->hostname,
/* Don't set any optional arguments here so we retain POSIX
* compatibility with getopt */
-#define IF_OPTS "bc:def:h:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:"
+#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:"
#define DEFAULT_TIMEOUT 30
#define DEFAULT_REBOOT 10