it is always a bad idea to mix up different languages
in one environment. now we use ash-builtins to get
uptime_in_seconds() instead of using cryptic sed-style.

Signed-off-by: Bastian Bittorf <bittorf at bluebottle.com>
>From a0997188ea3a325db33f9041297ebfea0180e31f Mon Sep 17 00:00:00 2001
From: Bastian Bittorf <bitt...@bluebottle.com>
Date: Wed, 19 Jan 2011 15:51:14 +0100
Subject: [PATCH] hotplug/netstate() get_uptime - clean_code

---
 .../files/etc/hotplug.d/iface/00-netstate          |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/etc/hotplug.d/iface/00-netstate b/package/base-files/files/etc/hotplug.d/iface/00-netstate
index e2e5845..37aab81 100644
--- a/package/base-files/files/etc/hotplug.d/iface/00-netstate
+++ b/package/base-files/files/etc/hotplug.d/iface/00-netstate
@@ -1,5 +1,13 @@
 [ ifup = "$ACTION" ] && {
+
+	uptime_in_seconds()
+	{
+		cut -d'.' -f1 /proc/uptime
+	}
+
 	uci_set_state network "$INTERFACE" up 1 
-	uci_set_state network "$INTERFACE" connect_time $(sed -ne 's![^0-9].*$!!p' /proc/uptime)
-	[ -n "$DEVICE" ] && uci_set_state network "$INTERFACE" ifname "$DEVICE"
+	uci_set_state network "$INTERFACE" connect_time $(uptime_in_seconds)
+
+	[ -n "$DEVICE" ] && \
+		uci_set_state network "$INTERFACE" ifname "$DEVICE"
 }
-- 
1.6.3.3

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to