utils/ap51-flash: import from old-packages and update

Signed-off-by: Russell Senior <russell@personaltelco.net>
This commit is contained in:
Russell Senior
2016-10-17 04:34:49 -07:00
parent a3a7e0dd65
commit 5970e1395e
4 changed files with 135 additions and 0 deletions
+6
View File
@@ -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'
+50
View File
@@ -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
}
+21
View File
@@ -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