* [Buildroot] [PATCH v2] busybox: udhcpc create leases file
@ 2015-05-26 3:10 Matt Weber
2015-07-13 1:20 ` Matthew Weber
0 siblings, 1 reply; 3+ messages in thread
From: Matt Weber @ 2015-05-26 3:10 UTC (permalink / raw)
To: buildroot
Capture the lease information for use by applications
after a lease is aquired.
Signed-off-by: Matt Weber <matthew.l.weber@gmail.com>
---
Changes v1 -> v2
- Changed from appending to keeping just the last lease
- Adjusted format to pure shell variables instead of
dhclient format.
- Moved location to /var/run instead of /var/lib/misc
---
package/busybox/udhcpc.script | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script
index 50c52e6..e913111 100755
--- a/package/busybox/udhcpc.script
+++ b/package/busybox/udhcpc.script
@@ -61,6 +61,27 @@ case "$1" in
echo adding dns $i
echo "nameserver $i # $interface" >> $RESOLV_CONF
done
+
+ # Record last lease
+ {
+ echo "IFACE=$interface"
+ echo "IP=$ip"
+ [ -n "$subnet" ] && echo "MASK=$subnet"
+ [ -n "$router" ] && echo "ROUTER=$router"
+ [ -n "$dns" ] && echo "DNS=\"$dns\""
+ [ -n "$domain" ] && echo "DOMAIN=$domain"
+ [ -n "$boot_file" ] && echo "BOOT_FILE=$boot_file"
+ echo "DHCP_LEASE_TIME=$lease"
+ echo "DHCP_MSG_TYPE=$dhcptype"
+ echo "DHCP_SERVER_ID=${siaddr:-$serverid}"
+ d=$(expr "$(date "+%Y.%m.%d-%H:%M:%S")" : "\(.*\):")
+ t=$(date -d "$d:$(expr $lease / 2)" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo "DHCP_RENEW=\"$t\""
+ t=$(date -d "$d:$(expr 7 '*' $lease / 8)" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo "DHCP_REBIND=\"$t\""
+ t=$(date -d "$d:$lease" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo "DHCP_EXPIRE=\"$t\""
+ } > /var/run/udhcpc.$interface.leases
;;
esac
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH v2] busybox: udhcpc create leases file
2015-05-26 3:10 [Buildroot] [PATCH v2] busybox: udhcpc create leases file Matt Weber
@ 2015-07-13 1:20 ` Matthew Weber
2015-07-14 22:18 ` Thomas Petazzoni
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Weber @ 2015-07-13 1:20 UTC (permalink / raw)
To: buildroot
All,
On Mon, May 25, 2015 at 10:10 PM, Matt Weber <matt@thewebers.ws> wrote:
> Capture the lease information for use by applications
> after a lease is aquired.
>
> Signed-off-by: Matt Weber <matthew.l.weber@gmail.com>
> ---
>
> Changes v1 -> v2
> - Changed from appending to keeping just the last lease
> - Adjusted format to pure shell variables instead of
> dhclient format.
> - Moved location to /var/run instead of /var/lib/misc
> ---
> package/busybox/udhcpc.script | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script
> index 50c52e6..e913111 100755
> --- a/package/busybox/udhcpc.script
> +++ b/package/busybox/udhcpc.script
> @@ -61,6 +61,27 @@ case "$1" in
> echo adding dns $i
> echo "nameserver $i # $interface" >> $RESOLV_CONF
> done
> +
> + # Record last lease
> + {
> + echo "IFACE=$interface"
> + echo "IP=$ip"
> + [ -n "$subnet" ] && echo "MASK=$subnet"
> + [ -n "$router" ] && echo "ROUTER=$router"
> + [ -n "$dns" ] && echo "DNS=\"$dns\""
> + [ -n "$domain" ] && echo "DOMAIN=$domain"
> + [ -n "$boot_file" ] && echo "BOOT_FILE=$boot_file"
> + echo "DHCP_LEASE_TIME=$lease"
> + echo "DHCP_MSG_TYPE=$dhcptype"
> + echo "DHCP_SERVER_ID=${siaddr:-$serverid}"
> + d=$(expr "$(date "+%Y.%m.%d-%H:%M:%S")" : "\(.*\):")
> + t=$(date -d "$d:$(expr $lease / 2)" "+%w %Y/%m/%d
> %H:%M:%S" 2>/dev/null)
> + [ -n "$t" ] && echo "DHCP_RENEW=\"$t\""
> + t=$(date -d "$d:$(expr 7 '*' $lease / 8)" "+%w
> %Y/%m/%d %H:%M:%S" 2>/dev/null)
> + [ -n "$t" ] && echo "DHCP_REBIND=\"$t\""
> + t=$(date -d "$d:$lease" "+%w %Y/%m/%d %H:%M:%S"
> 2>/dev/null)
> + [ -n "$t" ] && echo "DHCP_EXPIRE=\"$t\""
> + } > /var/run/udhcpc.$interface.leases
> ;;
> esac
>
> --
> 1.9.1
>
>
Since the hook scripts where added for the udhcpc.script, is the preference
to use a hook for something like a record of the last lease?
--
Thanks,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150712/132de537/attachment.html>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH v2] busybox: udhcpc create leases file
2015-07-13 1:20 ` Matthew Weber
@ 2015-07-14 22:18 ` Thomas Petazzoni
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2015-07-14 22:18 UTC (permalink / raw)
To: buildroot
Dear Matthew Weber,
On Sun, 12 Jul 2015 20:20:08 -0500, Matthew Weber wrote:
> Since the hook scripts where added for the udhcpc.script, is the preference
> to use a hook for something like a record of the last lease?
Yes. Your patch looks too much application-specific, so please use the
udhcpc hook mechanism to install your script through your own rootfs
overlay.
I'll mark the patch as Rejected.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-14 22:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 3:10 [Buildroot] [PATCH v2] busybox: udhcpc create leases file Matt Weber
2015-07-13 1:20 ` Matthew Weber
2015-07-14 22:18 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox