base-files: allow users to delect debug level during boot
authorJohn Crispin <john@openwrt.org>
Mon, 25 Nov 2013 08:34:55 +0000 (08:34 +0000)
committerJohn Crispin <john@openwrt.org>
Mon, 25 Nov 2013 08:34:55 +0000 (08:34 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 38909

package/base-files/files/lib/functions.sh
package/base-files/files/lib/preinit/30_failsafe_wait
package/system/procd/Makefile
package/utils/busybox/files/cron
target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom

index 85ebc2aeb16143826ca07c82579d4a4970e1bd70..6f23e0b8b2ea57fedc0cf3ae8d1f300e843a1516 100755 (executable)
@@ -260,6 +260,26 @@ mtd_get_mac_ascii()
        [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
 }
 
+mtd_get_blob()
+{
+       local mtdname="$1"
+       local offset="$2"
+       local count="$3"
+       local firmware="$4"
+       local part
+
+       part=$(find_mtd_part "$mtdname")
+       if [ -z "$part" ]; then
+               echo "mtd_get_blob: partition $mtdname not found!" >&2
+               return 1
+       fi
+
+       dd if=$part of=$firmware bs=1 skip=$offset count=$count 2>/dev/null || {
+               echo "mtd_get_blob: failed to extract $firmware from $part" >&2
+               return 1
+       }
+}
+
 mtd_get_mac_binary() {
        local mtdname="$1"
        local offset="$2"
index 6bce8ae49f3cae68d057f490eac3f616cdd03d73..522565940cccc88ecf30cf1499bda3c8fb3c4deb 100644 (file)
@@ -5,7 +5,7 @@
 fs_wait_for_key () {
     local timeout=$3
     local timer
-    local do_failsafe
+    local do_keypress
     local keypress_true="$(mktemp)"
     local keypress_wait="$(mktemp)"
     local keypress_sec="$(mktemp)"
@@ -40,6 +40,7 @@ fs_wait_for_key () {
     } &
 
     echo "Press the [$1] key and hit [enter] $2"
+    echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level"
     # if we're on the console we wait for input
     { 
        while [ -r $keypress_wait ]; do
@@ -48,14 +49,22 @@ fs_wait_for_key () {
            [ -n "$timer" ] || timer=1
            timer="${timer%%\ *}"
            [ $timer -ge 1 ] || timer=1
-           do_failsafe=""
+           do_keypress=""
            {
-               read -t "$timer" do_failsafe
-               if [ "$do_failsafe" = "$1" ]; then
-                   echo "true" >$keypress_true
-                   lock -u $keypress_wait
-                   rm -f $keypress_wait
-               fi
+               read -t "$timer" do_keypress
+               case "$do_keypress" in
+               $1)
+                       echo "true" >$keypress_true
+                       ;;
+               1 | 2 | 3 | 4)
+                       echo "$do_keypress" >/tmp/debug_level
+                       ;;
+               *)
+                       continue;
+                       ;;
+               esac
+               lock -u $keypress_wait
+               rm -f $keypress_wait
            }
        done
     }
index 6414f3cce97ad09c9420deeb150213180a18b711..3d4cedc353bedca661d5a88e085226067341a94a 100644 (file)
@@ -1,14 +1,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=procd
-PKG_VERSION:=2013-11-20
+PKG_VERSION:=2013-11-22
 
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=21d307367eb991f7494ce43087a5edb94288d08f
+PKG_SOURCE_VERSION:=dc3988c38546c37a02030af8201048272caa7ded
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
 CMAKE_INSTALL:=1
 
index 5e6b4bf3feb52b372feaba2ca58765c55bd69510..8f54527805ed44dd3048d98936617a5071eb038f 100755 (executable)
@@ -6,10 +6,24 @@ START=50
 USE_PROCD=1
 PROG=/usr/sbin/crond
 
+validate_cron_section() {
+       uci_validate_section system system "${1}" \
+               'cronloglevel:uinteger'
+}
+
 start_service () {
        [ -z "$(ls /etc/crontabs/)" ] && return 1
 
        loglevel=$(uci_get "system.@system[0].cronloglevel")
+
+       [ -z "${loglevel}" ] || {
+               /sbin/validate_data uinteger "${loglevel}"
+               [ "$?" -eq 0 ] || {
+                       echo "validation failed"
+                       return 1
+               }
+       }
+
        mkdir -p /var/spool/cron
        ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
 
@@ -17,3 +31,8 @@ start_service () {
        procd_set_param command "$PROG" -f -c /etc/crontabs -l ${loglevel:-5}
        procd_close_instance
 }
+
+service_triggers()
+{
+       procd_add_validation validate_cron_section
+}
index 40e17968cd8d713061de0fdc9fe4823418bbfd52..d3e024235544c09d8e6d452cd76ea07b6a5d0d06 100644 (file)
@@ -21,7 +21,8 @@ rt2x00_eeprom_extract() {
                rt2x00_eeprom_die "failed to extract from $mtd"
 }
 
-[ -e /lib/firmware/$FIRMWARE ] && exit 0
+FW="/lib/firmware/$FIRMWARE"
+[ -e "$FW" ] && exit 0
 
 . /lib/ramips.sh