[Zrouter-src] ZRouter.org: push to ZRouter profiles/lua_web_ui/files/etc/rc.d/...

zrouter-src at zrouter.org zrouter-src at zrouter.org
Mon Sep 24 11:23:49 UTC 2012


details:   http://zrouter.org/hg/zrouter//rev/261ba8d412dd
changeset: 461:261ba8d412dd
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Mon Sep 24 14:01:14 2012 +0300
description:
Add script which start UPGRADE mode if WPS button hold during rc stage.

diffstat:

 profiles/lua_web_ui/files/etc/rc.d/UPGRADE_MODE |  50 +++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diffs (54 lines):

diff -r bf8653674ede -r 261ba8d412dd profiles/lua_web_ui/files/etc/rc.d/UPGRADE_MODE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/profiles/lua_web_ui/files/etc/rc.d/UPGRADE_MODE	Mon Sep 24 14:01:14 2012 +0300
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# PROVIDE: UPGRADE_MODE
+# BEFORE: MAIN
+# REQUIRE: ADAPTATION FILESYSTEMS
+
+. /etc/rc.subr
+. /etc/network.subr
+
+name="UPGRADE_MODE"
+start_cmd="upgrade_mode_start"
+
+upgrade_mode_start()
+{
+	WPS_PIN=$(kenv WPS_PIN)
+	WPS_PIN_INVERT=$(kenv WPS_PIN_INVERT)
+	if [ ! -z "${WPS_PIN}" ] ; then
+		WPS_PIN_VAL=$(gpioctl -f /dev/gpioc0 -q -g ${WPS_PIN});
+		if [ -z "${WPS_PIN_INVERT}" -o "${WPS_PIN_INVERT}" != "1" ] ; then
+			WPS_PIN_INVERT=0;
+		fi
+		WPS_PIN_VAL=$(( ${WPS_PIN_VAL} ^ ${WPS_PIN_INVERT} ));
+		echo "UPGRADE_MODE: WPS pin[${WPS_PIN}]^${WPS_PIN_INVERT} value = \"${WPS_PIN_VAL}\"";
+		if [ "${WPS_PIN_VAL}" = "1" ] ; then
+			if [ -c /dev/led/wps  ]; then
+				echo m---... > /dev/led/wps
+			fi
+			/etc/rc.d/switchctl enablelan;
+			sleep 5; # Wait for linkup event # XXX better to read devctl
+			echo "RUN UPGRADE MODE";
+			# XXX: Run shell for now
+			ifconfig lan0 192.168.0.1/24
+			ifconfig lan0 down
+			ifconfig lan0 up
+			MD_DEV=$(mdconfig -a -t malloc -o reserve -s8M)
+			printf "http\tstream\ttcp\tnowait\troot\t\
+/sbin/upgrade\t\
+upgrade -l /dev/console -h \
+-H YWRtaW46YWRtaW4= -M \"Secure Area\" \
+-f /dev/%s -d /dev/map/upgrade\n" ${MD_DEV} >> /etc/inetd.conf
+			inetd -wW;
+			sh
+		fi
+	fi
+
+}
+
+load_rc_config $name
+
+run_rc_command $*


More information about the Zrouter-src mailing list