utils/ap51-flash: import from old-packages and update
authorRussell Senior <redacted>
Mon, 17 Oct 2016 11:34:49 +0000 (04:34 -0700)
committerRussell Senior <redacted>
Mon, 17 Oct 2016 11:37:54 +0000 (04:37 -0700)
Signed-off-by: Russell Senior <redacted>
utils/ap51-flash/Makefile [new file with mode: 0644]
utils/ap51-flash/files/ap51-flash.config [new file with mode: 0644]
utils/ap51-flash/files/ap51-flash.init [new file with mode: 0644]
utils/ap51-flash/files/ap51-flash.sh [new file with mode: 0755]

diff --git a/utils/ap51-flash/Makefile b/utils/ap51-flash/Makefile
new file mode 100644 (file)
index 0000000..a30fa5d
--- /dev/null
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ap51-flash
+PKG_VERSION:=2016-10-16
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://dev.cloudtrax.com/ap51-flash.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=48b3fbac1c30c5968b2608eb09b53ea37c310a24
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
+PKG_MAINTAINER:=Russell Senior <russell@personaltelco.net>
+
+include $(INCLUDE_DIR)/package.mk
+
+ifeq ($(CONFIG_BIG_ENDIAN),y)
+  STAMP_BUILT:=$(STAMP_BUILT)_big
+endif
+
+define Package/ap51-flash
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=A tool for flashing (nearly) all ap51/ap61 based routers
+  URL:=http://dev.cloudtrax.com/wiki/ap51-flash-station
+endef
+
+TARGET_EXTRA_CFLAGS:=-DFLASH_FROM_FILE -DNO_LIBPCAP -D_GNU_SOURCE -DIPPORT_TFTP=69
+ifeq ($(CONFIG_BIG_ENDIAN),y)
+       TARGET_EXTRA_CFLAGS:=$(TARGET_EXTRA_CFLAGS) -DUIP_CONF_BYTE_ORDER=1234
+endif
+
+# pass optimization flags
+MAKE_FLAGS += \
+       OFLAGS="$(TARGET_CFLAGS)" \
+       EXTRA_CFLAGS="$(TARGET_EXTRA_CFLAGS)" \
+       REVISION="$(PKG_VERSION)" \
+       ap51-flash
+
+define Package/ap51-flash/install
+       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d $(1)/usr/sbin \
+               $(1)/usr/lib/ap51-flash
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ap51-flash $(1)/usr/sbin/
+       $(INSTALL_BIN) ./files/ap51-flash.init $(1)/etc/init.d/ap51-flash
+       $(INSTALL_BIN) ./files/ap51-flash.sh $(1)/usr/lib/ap51-flash/ap51-flash.sh
+       $(INSTALL_DATA) ./files/ap51-flash.config $(1)/etc/config/ap51-flash
+endef
+
+define Package/ap51-flash/conffiles
+/etc/config/ap51-flash
+endef
+
+$(eval $(call BuildPackage,ap51-flash))
diff --git a/utils/ap51-flash/files/ap51-flash.config b/utils/ap51-flash/files/ap51-flash.config
new file mode 100644 (file)
index 0000000..f66973f
--- /dev/null
@@ -0,0 +1,6 @@
+#config flash
+#      option ifname   eth0.1
+#      option rootfs   /tmp/images/openwrt-atheros-root.squashfs
+#      option kernel   /tmp/images/openwrt-atheros-vmlinux.lzma
+#      option ubnt     /tmp/images/openwrt-atheros-ubnt5-squashfs.bin
+##     option loop     '1'
diff --git a/utils/ap51-flash/files/ap51-flash.init b/utils/ap51-flash/files/ap51-flash.init
new file mode 100644 (file)
index 0000000..1633ac4
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010 OpenWrt.org
+
+START=20
+
+NAME=ap51-flash
+
+start_daemon() {
+       local cfg="$1"
+
+       config_get_bool loop "$cfg" loop
+       config_get ifname "$cfg" ifname
+       config_get rootfs "$cfg" rootfs
+       config_get kernel "$cfg" kernel
+       config_get ubnt "$cfg" ubnt
+       [ "$loop" != "1" ] && loop=0
+       if [ -n "$ifname" -a -n "$rootfs" -a -n "$kernel" ] || \
+          [ -n "$ifname" -a -n "$ubnt" ]; then
+               PID="`cat /var/run/$NAME.sh-$ifname.pid 2> /dev/null`"
+               [ -z "`ps | grep "^.[ ]*$PID "`" ] && \
+                       rm /var/run/$NAME.sh-$ifname.pid
+               [ -n "`ls /var/run/$NAME.sh-$ifname.pid 2> /dev/null`" ] && {
+                       echo "Can't start more than one ap51-flash for interface $ifname!"
+                       return 0
+               }
+               start-stop-daemon -S -b -m -p /var/run/$NAME.sh-$ifname.pid -n $NAME.sh \
+                       -x /usr/lib/ap51-flash/$NAME.sh -- "$loop" "$ifname" "$rootfs" "$kernel" "$ubnt"
+       fi
+}
+
+start() {
+       config_load ap51-flash
+       config_foreach start_daemon flash
+}
+
+stop() {
+       # Terminating all ap51-flash processes
+       echo "WARNING: Going to teminate all ap51-flash processes! (hope you made sure that they're not flashing right now)"
+       echo "OR you can stop this with Ctrl+c within 10 seconds"
+       sleep 10
+       local pidfile
+       for pidfile in `ls /var/run/${NAME}.sh-*.pid 2> /dev/null`; do
+               start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}.sh" >/dev/null
+               rm -f "${pidfile}"
+       done
+       for pidfile in `ls /var/run/${NAME}-*.pid 2> /dev/null`; do
+               start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}" >/dev/null
+               rm -f "${pidfile}"
+       done
+}
diff --git a/utils/ap51-flash/files/ap51-flash.sh b/utils/ap51-flash/files/ap51-flash.sh
new file mode 100755 (executable)
index 0000000..9ac33ee
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+NAME=ap51-flash
+rootfs=""
+kernel=""
+ubnt=""
+
+[ $1 -eq "1" ] && loop="1"
+ifname="$2"
+[ -n "$3" ] && rootfs="--rootfs $3"
+[ -n "$4" ] && kernel="--kernel $4"
+[ -n "$5" ] && ubnt="--ubnt $5"
+
+while [ 1 ]; do
+       start-stop-daemon -S -m -p /var/run/$NAME-$ifname.pid -n $NAME \
+               -x /usr/sbin/$NAME -- --flash-from-file $rootfs $kernel $ubnt $ifname
+       
+       rm /var/run/$NAME-$ifname.pid
+       [ "$loop" != "1" ] && break
+       sleep 15
+done
git clone https://git.99rst.org/PROJECT