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 <bitt...@bluebottle.com>
>From 00c9af1c15d9a9f1959651a0fd7eac014e4e9808 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf <bitt...@bluebottle.com>
Date: Wed, 19 Jan 2011 08:52:07 +0100
Subject: [PATCH] hotplug/netstate: uptime_in_seconds with ash-builtins

---
 .../files/etc/hotplug.d/iface/00-netstate          |   18 ++++++++++++++++--
 1 files changed, 16 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..f3b0d3e 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,19 @@
 [ ifup = "$ACTION" ] && {
+
+	uptime_in_seconds()
+	{
+		local uptime dummy
+
+		IFS='. '
+		read uptime dummy </proc/uptime
+		unset IFS
+
+		echo $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