From 877ab89dabc3819bccbb1ccf87e9b1efec6e2cb9 Mon Sep 17 00:00:00 2001 From: mirko Date: Wed, 12 Dec 2012 12:38:31 +0000 Subject: remove function find_mtd_part() from /lib/functions.sh Since all scripts using this function include /lib/functions/boot.sh - where this function is defined as well - it can be dropped from /lib/functions.sh. Also avoids further confusion about this function being declared and defined in two different places. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34641 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 9 --------- 1 file changed, 9 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index b3a3885f2..2ed353b2a 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -220,15 +220,6 @@ include() { done } -find_mtd_part() { - local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" - local PREFIX=/dev/mtdblock - - PART="${PART##mtd}" - [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ - echo "${PART:+$PREFIX$PART}" -} - strtok() { # { [] ... } local tmp local val="$1" -- cgit v1.2.3 From feb7e4aff9207e8904c067947369e2ae868ba5e9 Mon Sep 17 00:00:00 2001 From: mirko Date: Wed, 12 Dec 2012 13:41:56 +0000 Subject: Revert "remove function find_mtd_part() from /lib/functions.sh" Reverting commit 34641. Function find_mtd_part() is needed by some scripts deployed for certain targets but not including boot.sh after all. Still, all this certainly needs some love. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34642 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 2ed353b2a..b3a3885f2 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -220,6 +220,15 @@ include() { done } +find_mtd_part() { + local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local PREFIX=/dev/mtdblock + + PART="${PART##mtd}" + [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ + echo "${PART:+$PREFIX$PART}" +} + strtok() { # { [] ... } local tmp local val="$1" -- cgit v1.2.3 From ab15bfa483e78630ab657a1eaabc7564ba81e2ae Mon Sep 17 00:00:00 2001 From: juhosg Date: Wed, 12 Dec 2012 16:49:50 +0000 Subject: base-files: add mtd_find_chardev helper Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34648 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index b3a3885f2..b924fce28 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -220,13 +220,27 @@ include() { done } -find_mtd_part() { +find_mtd_index() { local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local INDEX="${PART##mtd}" + + echo ${INDEX} +} + +find_mtd_part() { + local INDEX=$(find_mtd_index "$1") local PREFIX=/dev/mtdblock - PART="${PART##mtd}" [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ - echo "${PART:+$PREFIX$PART}" + echo "${INDEX:+$PREFIX$INDEX}" +} + +find_mtd_chardev() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtd + + [ -d /dev/mtd ] && PREFIX=/dev/mtd/ + echo "${INDEX:+$PREFIX$INDEX}" } strtok() { # { [] ... } -- cgit v1.2.3 From 2e65184ccaa50b2fb24f8380631d24723499902b Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 16 Dec 2012 18:22:02 +0000 Subject: base-files: various enhancements to network.sh - support reading inactive gateways and DNS information in network_get_gateway(), network_get_dnsserver() and network_get_dnssearch() by passing "true" as optional last argument - internally cache fetched values to speed up subsequent accesses to the same data, introduce network_flush_cache() to clear them - add some inline function documentation git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34722 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 183 ++++++++++++++++++---- 1 file changed, 153 insertions(+), 30 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index a4652569b..9366e5937 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -1,11 +1,40 @@ . /usr/share/libubox/jshn.sh +__network_switch_inactive() +{ + local __tmp + + if [ "$1" = 0 ] || [ "$1" = false ]; then + return 1 + fi + + json_get_type __tmp "inactive" + + if [ "$__tmp" = object ]; then + json_select "inactive" + fi +} + +__network_set_cache() +{ + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + eval "__NETWORK_CV_$1='\$$2'" +} + +__network_get_cache() +{ + eval "[ -n \"\${__NETWORK_CV_$1+x}\" ] && export -- \"$2=\$__NETWORK_CV_$1\"" +} + __network_ipaddr() { local __var="$1" local __iface="$2" local __family="$3" - local __prefix="${4:-0}" + local __prefix="$4" + local __key="ipaddr_${2}_${3}_${4}" + + __network_get_cache "$__key" "$__var" && return 0 local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" @@ -27,6 +56,7 @@ __network_ipaddr() eval "export -- \"$__var=\${$__var}/$__tmp\"" } + __network_set_cache "$__key" "$__var" return 0 fi fi @@ -34,10 +64,24 @@ __network_ipaddr() return 1 } +# determine IPv4 address of given logical interface +# 1: destination variable +# 2: interface network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; } + +# determine IPv6 address of given logical interface +# 1: destination variable +# 2: interface network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; } +# determine IPv4 subnet of given logical interface +# 1: destination variable +# 2: interface network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } + +# determine IPv6 subnet of given logical interface +# 1: destination variable +# 2: interface network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } @@ -46,79 +90,127 @@ __network_gateway() local __var="$1" local __iface="$2" local __family="$3" + local __key="gateway_${2}_${3}" + + __network_get_cache "$__key" "$__var" && return 0 local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" - local __idx=1 json_load "${__tmp:-{}}" - if json_get_type __tmp route && [ "$__tmp" = array ]; then + for __tmp in 0 1; do - json_select route + if json_get_type __tmp route && [ "$__tmp" = array ]; then - while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do + json_select route - json_select "$((__idx++))" - json_get_var __tmp target + local __idx=1 + while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do - case "${__family}/${__tmp}" in - 4/0.0.0.0|6/::) - json_get_var "$__var" nexthop - return $? - ;; - esac + json_select "$((__idx++))" + json_get_var __tmp target + + case "${__family}/${__tmp}" in + 4/0.0.0.0|6/::) + json_get_var "$__var" nexthop + __network_set_cache "$__key" "$__var" + return $? + ;; + esac + + json_select ".." + + done json_select ".." - done - fi + fi + + __network_switch_inactive "$4" || break + + done return 1 } -network_get_gateway() { __network_gateway "$1" "$2" 4; } -network_get_gateway6() { __network_gateway "$1" "$2" 6; } +# determine IPv4 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; } + +# determine IPv6 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; } __network_dns() { local __var="$1" local __iface="$2" local __field="$3" + local __key="dns_${2}_${3}" + + __network_get_cache "$__key" "$__var" && return 0 local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" local __dns="" - local __idx=1 json_load "${__tmp:-{}}" - if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then + for __tmp in 0 1; do - json_select "$__field" + if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then - while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do + json_select "$__field" - json_get_var __tmp "$((__idx++))" - __dns="${__dns:+$__dns }$__tmp" + local __idx=1 + while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do - done - fi + json_get_var __tmp "$((__idx++))" + __dns="${__dns:+$__dns }$__tmp" + + done + + json_select ".." + fi + + __network_switch_inactive "$4" || break + + done - eval "export -- \"$__var=$__dns\"" - [ -n "$__dns" ] + if [ -n "$__dns" ]; then + eval "export -- \"$__var=$__dns\"" + __network_set_cache "$__key" "$__var" + fi } -network_get_dnsserver() { __network_dns "$1" "$2" dns_server; } -network_get_dnssearch() { __network_dns "$1" "$2" dns_search; } +# determine the DNS servers of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive servers if "true" (optional) +network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; } + +# determine the domains of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive servers if "true" (optional) +network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; } __network_wan() { local __var="$1" local __family="$2" + local __key="wan_${2}" local __iface + __network_get_cache "$__key" "$__var" && return 0 + for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do if __network_gateway "$__var" "$__iface" "$__family"; then eval "export -- \"$__var=$__iface\"" + __network_set_cache "$__key" "$__var" return 0 fi done @@ -127,7 +219,12 @@ __network_wan() { return 1 } +# find the logical interface which holds the current IPv4 default route +# 1: destination variable network_find_wan() { __network_wan "$1" 4; } + +# find the logical interface which holds the current IPv6 default route +# 1: destination variable network_find_wan6() { __network_wan "$1" 6; } @@ -136,21 +233,33 @@ __network_device() local __var="$1" local __iface="$2" local __field="$3" + local __key="device_${2}_${3}" + + __network_get_cache "$__key" "$__var" && return 0 local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" [ -n "$__tmp" ] || return 1 json_load "$__tmp" - json_get_var "$__var" "$__field" + json_get_var "$__var" "$__field" && __network_set_cache "$__key" "$__var" } +# test whether the given logical interface is running +# 1: interface network_is_up() { local __up __network_device __up "$1" up && [ $__up -eq 1 ] } +# determine the layer 3 linux network device of the given logical interface +# 1: destination variable +# 2: interface network_get_device() { __network_device "$1" "$2" l3_device; } + +# determine the layer 2 linux network device of the given logical interface +# 1: destination variable +# 2: interface network_get_physdev() { __network_device "$1" "$2" device; } @@ -166,5 +275,19 @@ __network_defer() ubus call network.device set_state "$(json_dump)" 2>/dev/null } +# defer netifd actions on the given linux network device +# 1: device name network_defer_device() { __network_defer "$1" 1; } + +# continue netifd actions on the given linux network device +# 1: device name network_ready_device() { __network_defer "$1" 0; } + +# flush the internal value cache to force re-reading values from ubus +network_flush_cache() +{ + local __tmp + for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do + unset "$__tmp" + done +} -- cgit v1.2.3 From a06be29d4e91a4c00c0bd737e5da7c888edebdcc Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 16 Dec 2012 20:17:18 +0000 Subject: base-files: rework cache handling in network.sh to keep the entire parsed ifstatus, use jshn namespaces to support using it concurrently with other jshn users git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34725 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 288 ++++++++++++---------- 1 file changed, 159 insertions(+), 129 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 9366e5937..d242abbe6 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -1,67 +1,153 @@ . /usr/share/libubox/jshn.sh -__network_switch_inactive() +__network_set_cache() { - local __tmp - - if [ "$1" = 0 ] || [ "$1" = false ]; then - return 1 - fi - - json_get_type __tmp "inactive" - - if [ "$__tmp" = object ]; then - json_select "inactive" + if [ -n "$3" ]; then + eval "export -- __NETWORK_CV_$1='$3'" + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + elif json_get_var "__NETWORK_CV_$1" "$2"; then + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" fi } -__network_set_cache() +__network_export() { - __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" - eval "__NETWORK_CV_$1='\$$2'" + local __v="__NETWORK_CV_$2" + eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]" } -__network_get_cache() +__network_parse_ifstatus() { - eval "[ -n \"\${__NETWORK_CV_$1+x}\" ] && export -- \"$2=\$__NETWORK_CV_$1\"" -} + local __iface="$1" + local __key="${__iface}" + local __tmp + local __old_ns -__network_ipaddr() -{ - local __var="$1" - local __iface="$2" - local __family="$3" - local __prefix="$4" - local __key="ipaddr_${2}_${3}_${4}" + __network_export __tmp "${__key}__parsed" && return 0 + __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" + [ -n "$__tmp" ] || return 1 - __network_get_cache "$__key" "$__var" && return 0 + json_set_namespace "network" __old_ns + json_load "$__tmp" - local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" + __network_set_cache "${__key}__parsed" "" "1" - json_load "${__tmp:-{}}" - json_get_type __tmp "ipv${__family}_address" + for __tmp in "" "_inactive"; do - if [ "$__tmp" = array ]; then + __key="${__key}${__tmp}" - json_select "ipv${__family}_address" - json_get_type __tmp 1 + # parse addresses + local __family + for __family in 4 6; do + if json_get_type __tmp "ipv${__family}_address" && [ "$__tmp" = array ]; then - if [ "$__tmp" = object ]; then + json_select "ipv${__family}_address" - json_select 1 - json_get_var $__var address + if json_get_type __tmp 1 && [ "$__tmp" = object ]; then - [ $__prefix -gt 0 ] && { - json_get_var __tmp mask - eval "export -- \"$__var=\${$__var}/$__tmp\"" - } + json_select 1 + __network_set_cache "${__key}_address${__family}" address + __network_set_cache "${__key}_mask${__family}" mask + json_select ".." + + fi + + json_select ".." + + fi + done + + # parse routes + if json_get_type __tmp route && [ "$__tmp" = array ]; then + + json_select "route" + + local __idx=1 + while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do + + json_select "$((__idx++))" + json_get_var __tmp target + + case "${__tmp}" in + 0.0.0.0) + __network_set_cache "${__key}_gateway4" nexthop + ;; + ::) + __network_set_cache "${__key}_gateway6" nexthop + ;; + esac + + json_select ".." + + done + + json_select ".." - __network_set_cache "$__key" "$__var" - return 0 fi + + # parse dns info + local __field + for __field in "dns_server" "dns_search"; do + if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then + + json_select "$__field" + + local __idx=1 + local __dns="" + + while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do + + json_get_var __tmp "$((__idx++))" + __dns="${__dns:+$__dns }$__tmp" + + done + + json_select ".." + + if [ -n "$__dns" ]; then + __network_set_cache "${__key}_${__field}" "" "$__dns" + fi + fi + done + + # parse up state, device and physdev + for __field in "up" "l3_device" "device"; do + if json_get_type __tmp "$__field"; then + __network_set_cache "${__key}_${__field}" "$__field" + fi + done + + # descend into inactive table + json_get_type __tmp "inactive" && [ "$__tmp" = object ] && json_select "inactive" + + done + + json_cleanup + json_set_namespace "$__old_ns" + + return 0 +} + + +__network_ipaddr() +{ + local __var="$1" + local __iface="$2" + local __family="$3" + local __prefix="$4" + local __tmp + + __network_parse_ifstatus "$__iface" || return 1 + + if [ $__prefix -eq 1 ]; then + __network_export __tmp "${__iface}_mask${__family}" && \ + __network_export "$__var" "${__iface}_address${__family}" "/$__tmp" + return $? fi - return 1 + __network_export "$__var" "${__iface}_address${__family}" + return $? + } # determine IPv4 address of given logical interface @@ -90,47 +176,17 @@ __network_gateway() local __var="$1" local __iface="$2" local __family="$3" - local __key="gateway_${2}_${3}" - - __network_get_cache "$__key" "$__var" && return 0 - - local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" - - json_load "${__tmp:-{}}" - - for __tmp in 0 1; do - - if json_get_type __tmp route && [ "$__tmp" = array ]; then - - json_select route - - local __idx=1 - while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do - - json_select "$((__idx++))" - json_get_var __tmp target - - case "${__family}/${__tmp}" in - 4/0.0.0.0|6/::) - json_get_var "$__var" nexthop - __network_set_cache "$__key" "$__var" - return $? - ;; - esac - - json_select ".." - - done - - json_select ".." - - fi + local __inactive="$4" - __network_switch_inactive "$4" || break + __network_parse_ifstatus "$__iface" || return 1 - done + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \ + return 0 + fi - return 1 + __network_export "$__var" "${__iface}_gateway${__family}" + return $? } # determine IPv4 gateway of given logical interface @@ -150,40 +206,17 @@ __network_dns() { local __var="$1" local __iface="$2" local __field="$3" - local __key="dns_${2}_${3}" - - __network_get_cache "$__key" "$__var" && return 0 - - local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" - local __dns="" - - json_load "${__tmp:-{}}" + local __inactive="$4" - for __tmp in 0 1; do + __network_parse_ifstatus "$__iface" || return 1 - if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then - - json_select "$__field" - - local __idx=1 - while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do - - json_get_var __tmp "$((__idx++))" - __dns="${__dns:+$__dns }$__tmp" - - done - - json_select ".." - fi - - __network_switch_inactive "$4" || break - - done - - if [ -n "$__dns" ]; then - eval "export -- \"$__var=$__dns\"" - __network_set_cache "$__key" "$__var" + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_${__field}" && \ + return 0 fi + + __network_export "$__var" "${__iface}_${__field}" + return $? } # determine the DNS servers of the given logical interface @@ -195,23 +228,23 @@ network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; } # determine the domains of the given logical interface # 1: destination variable # 2: interface -# 3: consider inactive servers if "true" (optional) +# 3: consider inactive domains if "true" (optional) network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; } -__network_wan() { +__network_wan() +{ local __var="$1" local __family="$2" - local __key="wan_${2}" + local __inactive="$3" local __iface - __network_get_cache "$__key" "$__var" && return 0 - for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do - if __network_gateway "$__var" "$__iface" "$__family"; then - eval "export -- \"$__var=$__iface\"" - __network_set_cache "$__key" "$__var" - return 0 + if [ "$__iface" != loopback ]; then + if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then + eval "export -- \"$__var=$__iface\"" + return 0 + fi fi done @@ -221,11 +254,13 @@ __network_wan() { # find the logical interface which holds the current IPv4 default route # 1: destination variable -network_find_wan() { __network_wan "$1" 4; } +# 2: consider inactive default routes if "true" (optional) +network_find_wan() { __network_wan "$1" 4 "${2:-0}"; } # find the logical interface which holds the current IPv6 default route # 1: destination variable -network_find_wan6() { __network_wan "$1" 6; } +# 2: consider inactive dafault routes if "true" (optional) +network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; } __network_device() @@ -233,15 +268,10 @@ __network_device() local __var="$1" local __iface="$2" local __field="$3" - local __key="device_${2}_${3}" - - __network_get_cache "$__key" "$__var" && return 0 - local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" - [ -n "$__tmp" ] || return 1 - - json_load "$__tmp" - json_get_var "$__var" "$__field" && __network_set_cache "$__key" "$__var" + __network_parse_ifstatus "$__iface" || return 1 + __network_export "$__var" "${__iface}_${__field}" + return $? } # test whether the given logical interface is running -- cgit v1.2.3 From 0cc78c202013a13896d42e9ed3264a3fe84bd1a3 Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 17 Dec 2012 13:07:42 +0000 Subject: base-files: use json_is_a() in network.sh git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34733 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index d242abbe6..424965acb 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -39,11 +39,11 @@ __network_parse_ifstatus() # parse addresses local __family for __family in 4 6; do - if json_get_type __tmp "ipv${__family}_address" && [ "$__tmp" = array ]; then + if json_is_a "ipv${__family}_address" array; then json_select "ipv${__family}_address" - if json_get_type __tmp 1 && [ "$__tmp" = object ]; then + if json_is_a 1 object; then json_select 1 __network_set_cache "${__key}_address${__family}" address @@ -58,12 +58,12 @@ __network_parse_ifstatus() done # parse routes - if json_get_type __tmp route && [ "$__tmp" = array ]; then + if json_is_a route array; then json_select "route" local __idx=1 - while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do + while json_is_a "$__idx" object; do json_select "$((__idx++))" json_get_var __tmp target @@ -88,14 +88,14 @@ __network_parse_ifstatus() # parse dns info local __field for __field in "dns_server" "dns_search"; do - if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then + if json_is_a "$__field" array; then json_select "$__field" local __idx=1 local __dns="" - while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do + while json_is_a "$__idx" string; do json_get_var __tmp "$((__idx++))" __dns="${__dns:+$__dns }$__tmp" @@ -118,7 +118,7 @@ __network_parse_ifstatus() done # descend into inactive table - json_get_type __tmp "inactive" && [ "$__tmp" = object ] && json_select "inactive" + json_is_a "inactive" object && json_select "inactive" done -- cgit v1.2.3 From 53edda1e3668752d18b2bbf4c3d6edc7e3ab1b6e Mon Sep 17 00:00:00 2001 From: mirko Date: Wed, 19 Dec 2012 16:07:46 +0000 Subject: Do not overload mount-call - trying to reduce confusion The behaviour of calling 'mount' differed depending on whether it called the busybox-mount, the mount of util-linux, the mount defined in /lib/functions.sh and /lib/functions/boot.sh /etc/preinit even included /lib/functions.sh and /lib/functions/boot.sh, both re-defining 'mount'. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34792 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/lib/firstboot/20_no_fo_mount_jffs | 4 ++-- .../files/lib/firstboot/30_is_rootfs_mounted | 2 +- package/base-files/files/lib/functions.sh | 3 --- package/base-files/files/lib/functions/boot.sh | 26 +++++++++------------- .../base-files/files/lib/preinit/10_check_for_mtd | 2 +- .../base-files/files/lib/preinit/10_essential_fs | 6 ++--- .../files/lib/preinit/20_device_fs_mount | 8 +++---- .../base-files/files/lib/preinit/40_mount_devpts | 2 +- .../base-files/files/lib/preinit/40_mount_jffs2 | 2 +- .../files/lib/preinit/70_pivot_jffs2_root | 2 +- package/base-files/files/lib/upgrade/common.sh | 12 +++++----- 11 files changed, 31 insertions(+), 38 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs index 8a1d4e06d..c03714fa6 100644 --- a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs +++ b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs @@ -5,8 +5,8 @@ no_fo_mount_jffs() { # initialize jffs2 - mount "$mtdpart" /overlay -t jffs2 || exit - + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + # workaround to ensure that union can attach properly sync ls /overlay >/dev/null diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted index e2ba01d50..7233fd903 100644 --- a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted +++ b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted @@ -4,7 +4,7 @@ # Copyright (C) 2010 Vertical Communications skip_if_rootfs_mounted() { - mount "$mtdpart" /rom/overlay -t jffs2 || exit + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit } boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index b924fce28..db59706bc 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -6,9 +6,6 @@ debug () { ${DEBUG:-:} "$@" } -mount() { - busybox mount "$@" -} # newline N=" diff --git a/package/base-files/files/lib/functions/boot.sh b/package/base-files/files/lib/functions/boot.sh index 8c3f27ba4..137c3bf47 100644 --- a/package/base-files/files/lib/functions/boot.sh +++ b/package/base-files/files/lib/functions/boot.sh @@ -2,10 +2,6 @@ # Copyright (C) 2006-2010 OpenWrt.org # Copyright (C) 2010 Vertical Communications -mount() { - /bin/busybox mount -o noatime "$@" -} - boot_hook_splice_start() { export -n PI_HOOK_SPLICE=1 } @@ -112,12 +108,12 @@ dupe() { # } pivot() { # - mount -o move /proc $1/proc && \ + mount -o noatime,move /proc $1/proc && \ pivot_root $1 $1$2 && { - mount -o move $2/dev /dev - mount -o move $2/tmp /tmp - mount -o move $2/sys /sys 2>&- - mount -o move $2/overlay /overlay 2>&- + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/sys /sys 2>&- + mount -o noatime,move $2/overlay /overlay 2>&- return 0 } } @@ -126,16 +122,16 @@ fopivot() { # root=$1 { if grep -q overlay /proc/filesystems; then - mount -t overlayfs -olowerdir=/,upperdir=$1 "overlayfs:$1" /mnt && root=/mnt + mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt elif grep -q mini_fo /proc/filesystems; then - mount -t mini_fo -o base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt + mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt else - mount --bind / /mnt - mount --bind -o union "$1" /mnt && root=/mnt + mount --bind -o noatime / /mnt + mount --bind -o noatime,union "$1" /mnt && root=/mnt fi } || { [ "$3" = "1" ] && { - mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 + mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1 dupe $1 $rom } } @@ -144,7 +140,7 @@ fopivot() { # ramoverlay() { mkdir -p /tmp/root - mount -t tmpfs -o mode=0755 root /tmp/root + mount -t tmpfs -o noatime,mode=0755 root /tmp/root fopivot /tmp/root /rom 1 } diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd index 66f185e1a..6a7bd307f 100644 --- a/package/base-files/files/lib/preinit/10_check_for_mtd +++ b/package/base-files/files/lib/preinit/10_check_for_mtd @@ -5,7 +5,7 @@ mount_no_mtd() { mtd unlock rootfs - mount -o remount,rw /dev/root / + mount -o noatime,remount,rw /dev/root / } check_for_mtd() { diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs index 5d979fd49..fc04eb7ff 100644 --- a/package/base-files/files/lib/preinit/10_essential_fs +++ b/package/base-files/files/lib/preinit/10_essential_fs @@ -3,11 +3,11 @@ # Copyright (C) 2010 Vertical Communications do_mount_procfs() { - mount -t proc proc /proc + mount -o noatime -t proc proc /proc } do_mount_sysfs() { - mount -t sysfs sysfs /sys + mount -o noatime -tsysfs sysfs /sys } calc_tmpfs_size() { @@ -16,7 +16,7 @@ calc_tmpfs_size() { do_mount_tmpfs() { calc_tmpfs_size - mount -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp + mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp } boot_hook_add preinit_essential do_mount_procfs diff --git a/package/base-files/files/lib/preinit/20_device_fs_mount b/package/base-files/files/lib/preinit/20_device_fs_mount index ed59b5b23..7535b3ff9 100644 --- a/package/base-files/files/lib/preinit/20_device_fs_mount +++ b/package/base-files/files/lib/preinit/20_device_fs_mount @@ -6,19 +6,19 @@ do_move_devtmpfs() { local mnt="$(grep devtmpfs /proc/mounts)" mnt="${mnt#* }"; mnt="${mnt%% *}" - [ "$mnt" = "/dev" ] || mount -o move "$mnt" /dev + [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev } do_mount_devfs() { - mount -t devfs devfs /dev + mount -o noatime -t devfs devfs /dev } do_mount_hotplug() { - mount -t tmpfs -o mode=0755,size=512K tmpfs /dev + mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev } do_mount_udev() { - mount -n -t tmpfs -o mode=0755 udev /dev + mount -n -t tmpfs -o noatime,mode=0755 udev /dev } choose_device_fs() { diff --git a/package/base-files/files/lib/preinit/40_mount_devpts b/package/base-files/files/lib/preinit/40_mount_devpts index b75d69287..b55a7f2e8 100644 --- a/package/base-files/files/lib/preinit/40_mount_devpts +++ b/package/base-files/files/lib/preinit/40_mount_devpts @@ -7,7 +7,7 @@ init_devpts() { } do_mount_devpts() { - mount -t devpts devpts /dev/pts + mount -o noatime -t devpts devpts /dev/pts } boot_hook_add preinit_essential init_devpts diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2 index 00f45a890..ded785ed5 100644 --- a/package/base-files/files/lib/preinit/40_mount_jffs2 +++ b/package/base-files/files/lib/preinit/40_mount_jffs2 @@ -4,7 +4,7 @@ find_mount_jffs2() { mkdir -p /tmp/overlay - mount "$(find_mtd_part rootfs_data)" /tmp/overlay -t jffs2 + mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay mtd -qq unlock rootfs_data } diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root index 821bfb14f..b76f111ca 100644 --- a/package/base-files/files/lib/preinit/70_pivot_jffs2_root +++ b/package/base-files/files/lib/preinit/70_pivot_jffs2_root @@ -5,7 +5,7 @@ rootfs_pivot() { check_skip || jffs2_not_mounted || { echo "switching to jffs2" - mount -o move /tmp/overlay /overlay 2>&- + mount -o noatime,move /tmp/overlay /overlay 2>&- fopivot /overlay /rom && pi_mount_skip_next=true } } diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index e6de34849..e796c7bac 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -36,16 +36,16 @@ install_bin() { # [ ... ] pivot() { # mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ - mount -o move /proc $1/proc && \ + mount -o noatime,move /proc $1/proc && \ pivot_root $1 $1$2 || { umount $1 $1 return 1 } - mount -o move $2/sys /sys - mount -o move $2/dev /dev - mount -o move $2/tmp /tmp - mount -o move $2/overlay /overlay 2>&- + mount -o noatime,move $2/sys /sys + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/overlay /overlay 2>&- return 0 } @@ -71,7 +71,7 @@ run_ramfs() { # [...] umount -l /mnt grep /overlay /proc/mounts > /dev/null && { - mount -o remount,ro /overlay + mount -o noatime,remount,ro /overlay umount -l /overlay } -- cgit v1.2.3 From c8e772f18ff31566e342cd44fbd7a6b2bc11efb2 Mon Sep 17 00:00:00 2001 From: mirko Date: Wed, 19 Dec 2012 16:07:53 +0000 Subject: merge /lib/functions/boot.sh and /lib/functions.sh git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34794 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 137 +++++++++++++++++++++++ package/base-files/files/lib/functions/boot.sh | 146 ------------------------- 2 files changed, 137 insertions(+), 146 deletions(-) delete mode 100644 package/base-files/files/lib/functions/boot.sh (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index db59706bc..54e69b833 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -348,4 +348,141 @@ pi_include() { return 0 } +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +boot_hook_splice_start() { + export -n PI_HOOK_SPLICE=1 +} + +boot_hook_splice_finish() { + local hook + for hook in $PI_STACK_LIST; do + local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook" + export -n "${hook}=${v% }" + export -n "${hook}_splice=" + done + export -n PI_HOOK_SPLICE= +} + +boot_hook_init() { + local hook="${1}_hook" + export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook" + export -n "$hook=" +} + +boot_hook_add() { + local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}" + local func="${2}" + + [ -n "$func" ] && { + local v; eval "v=\$$hook" + export -n "$hook=${v:+$v }$func" + } +} + +boot_hook_shift() { + local hook="${1}_hook" + local rvar="${2}" + + local v; eval "v=\$$hook" + [ -n "$v" ] && { + local first="${v%% *}" + + [ "$v" != "${v#* }" ] && \ + export -n "$hook=${v#* }" || \ + export -n "$hook=" + + export -n "$rvar=$first" + return 0 + } + + return 1 +} + +boot_run_hook() { + local hook="$1" + local func + + while boot_hook_shift "$hook" func; do + local ran; eval "ran=\$PI_RAN_$func" + [ -n "$ran" ] || { + export -n "PI_RAN_$func=1" + $func "$1" "$2" + } + done +} + +jffs2_ready () { + mtdpart="$(find_mtd_part rootfs_data)" + [ -z "$mtdpart" ] && return 1 + magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') + [ "$magic" != "deadc0de" ] +} + +dupe() { # + cd $1 + echo -n "creating directories... " + { + cd $2 + find . -xdev -type d + echo "./dev ./overlay ./mnt ./proc ./tmp" + # xdev skips mounted directories + cd $1 + } | xargs mkdir -p + echo "done" + + echo -n "setting up symlinks... " + for file in $(cd $2; find . -xdev -type f;); do + case "$file" in + ./rom/note) ;; #nothing + ./etc/config*|\ + ./usr/lib/opkg/info/*) cp -af $2/$file $file;; + *) ln -sf /rom/${file#./*} $file;; + esac + done + for file in $(cd $2; find . -xdev -type l;); do + cp -af $2/${file#./*} $file + done + echo "done" +} + +pivot() { # + mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 && { + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/sys /sys 2>&- + mount -o noatime,move $2/overlay /overlay 2>&- + return 0 + } +} + +fopivot() { # + root=$1 + { + if grep -q overlay /proc/filesystems; then + mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt + elif grep -q mini_fo /proc/filesystems; then + mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt + else + mount --bind -o noatime / /mnt + mount --bind -o noatime,union "$1" /mnt && root=/mnt + fi + } || { + [ "$3" = "1" ] && { + mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1 + dupe $1 $rom + } + } + pivot $root $2 +} + +ramoverlay() { + mkdir -p /tmp/root + mount -t tmpfs -o noatime,mode=0755 root /tmp/root + fopivot /tmp/root /rom 1 +} + [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh diff --git a/package/base-files/files/lib/functions/boot.sh b/package/base-files/files/lib/functions/boot.sh deleted file mode 100644 index 137c3bf47..000000000 --- a/package/base-files/files/lib/functions/boot.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -boot_hook_splice_start() { - export -n PI_HOOK_SPLICE=1 -} - -boot_hook_splice_finish() { - local hook - for hook in $PI_STACK_LIST; do - local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook" - export -n "${hook}=${v% }" - export -n "${hook}_splice=" - done - export -n PI_HOOK_SPLICE= -} - -boot_hook_init() { - local hook="${1}_hook" - export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook" - export -n "$hook=" -} - -boot_hook_add() { - local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}" - local func="${2}" - - [ -n "$func" ] && { - local v; eval "v=\$$hook" - export -n "$hook=${v:+$v }$func" - } -} - -boot_hook_shift() { - local hook="${1}_hook" - local rvar="${2}" - - local v; eval "v=\$$hook" - [ -n "$v" ] && { - local first="${v%% *}" - - [ "$v" != "${v#* }" ] && \ - export -n "$hook=${v#* }" || \ - export -n "$hook=" - - export -n "$rvar=$first" - return 0 - } - - return 1 -} - -boot_run_hook() { - local hook="$1" - local func - - while boot_hook_shift "$hook" func; do - local ran; eval "ran=\$PI_RAN_$func" - [ -n "$ran" ] || { - export -n "PI_RAN_$func=1" - $func "$1" "$2" - } - done -} - -find_mtd_part() { - local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" - local PREFIX=/dev/mtdblock - - PART="${PART##mtd}" - [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ - echo "${PART:+$PREFIX$PART}" -} - -jffs2_ready () { - mtdpart="$(find_mtd_part rootfs_data)" - [ -z "$mtdpart" ] && return 1 - magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') - [ "$magic" != "deadc0de" ] -} - -dupe() { # - cd $1 - echo -n "creating directories... " - { - cd $2 - find . -xdev -type d - echo "./dev ./overlay ./mnt ./proc ./tmp" - # xdev skips mounted directories - cd $1 - } | xargs mkdir -p - echo "done" - - echo -n "setting up symlinks... " - for file in $(cd $2; find . -xdev -type f;); do - case "$file" in - ./rom/note) ;; #nothing - ./etc/config*|\ - ./usr/lib/opkg/info/*) cp -af $2/$file $file;; - *) ln -sf /rom/${file#./*} $file;; - esac - done - for file in $(cd $2; find . -xdev -type l;); do - cp -af $2/${file#./*} $file - done - echo "done" -} - -pivot() { # - mount -o noatime,move /proc $1/proc && \ - pivot_root $1 $1$2 && { - mount -o noatime,move $2/dev /dev - mount -o noatime,move $2/tmp /tmp - mount -o noatime,move $2/sys /sys 2>&- - mount -o noatime,move $2/overlay /overlay 2>&- - return 0 - } -} - -fopivot() { # - root=$1 - { - if grep -q overlay /proc/filesystems; then - mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt - elif grep -q mini_fo /proc/filesystems; then - mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt - else - mount --bind -o noatime / /mnt - mount --bind -o noatime,union "$1" /mnt && root=/mnt - fi - } || { - [ "$3" = "1" ] && { - mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1 - dupe $1 $rom - } - } - pivot $root $2 -} - -ramoverlay() { - mkdir -p /tmp/root - mount -t tmpfs -o noatime,mode=0755 root /tmp/root - fopivot /tmp/root /rom 1 -} - -- cgit v1.2.3 From 5ca25ac981296646898bc8810dd31e01ebaf84d1 Mon Sep 17 00:00:00 2001 From: mirko Date: Fri, 21 Dec 2012 12:10:21 +0000 Subject: [package/base-files] hot-fix nameclash in sysupgrade: rename pivot() to supivot() in sysupgrade Sysupgrade defines its very own pivot() function. Prior merging boot.sh and functions.sh sysupgrade just included boot.sh, now it includes functions.sh which defines pivot() as well, however slightly different which causes sysupgrade to fail. This is a hot-fix to unbreak sysupgrade, however those two pivot() functions should actually get merged. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34815 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/upgrade/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index e796c7bac..2e123ab3c 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -33,7 +33,7 @@ install_bin() { # [ ... ] }; done } -pivot() { # +supivot() { # mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ mount -o noatime,move /proc $1/proc && \ @@ -62,7 +62,7 @@ run_ramfs() { # [...] done install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA - pivot $RAM_ROOT /mnt || { + supivot $RAM_ROOT /mnt || { echo "Failed to switch over to ramfs. Please reboot." exit 1 } -- cgit v1.2.3 From 593cc2f133ba84688e0bc15be79e1b2b752cf67a Mon Sep 17 00:00:00 2001 From: cyrus Date: Thu, 27 Dec 2012 14:10:01 +0000 Subject: base-files: Fix a typo in config_list_foreach git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34893 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 54e69b833..ae0257a5c 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -197,7 +197,7 @@ config_list_foreach() { [ -z "$len" ] && return 0 while [ $c -le "$len" ]; do config_get val "${section}" "${option}_ITEM$c" - eval "$function \"\$val\" \"$@\"" + eval "$function \"\$val\" \"\$@\"" c="$(($c + 1))" done } -- cgit v1.2.3 From 04d51e9b5ee038bd5c897964916cdaaf717a67df Mon Sep 17 00:00:00 2001 From: acinonyx Date: Fri, 11 Jan 2013 13:20:51 +0000 Subject: [package] base-files: Don't pass '--set-worker /lib/hotplug2/worker_fork.so' to hotplug2 (#12781) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35095 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/preinit/30_device_fs_daemons | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/preinit/30_device_fs_daemons b/package/base-files/files/lib/preinit/30_device_fs_daemons index 5b3e2ad00..8379e5e74 100644 --- a/package/base-files/files/lib/preinit/30_device_fs_daemons +++ b/package/base-files/files/lib/preinit/30_device_fs_daemons @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # Copyright (C) 2010 Vertical Communications init_devfs() { @@ -8,8 +8,8 @@ init_devfs() { init_hotplug2() { [ -c /dev/console ] || mknod /dev/console c 5 1 - /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger - /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent & + /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger + /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --persistent & } init_udev() { -- cgit v1.2.3 From a9e848f1b73ec05528ca7c01603a80ff87faad97 Mon Sep 17 00:00:00 2001 From: cyrus Date: Tue, 15 Jan 2013 13:07:51 +0000 Subject: base-files: add support for ipv6-prefixes in connection with netifd git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35168 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 424965acb..8f87d1d0b 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -57,6 +57,20 @@ __network_parse_ifstatus() fi done + # parse prefixes + if json_is_a "ipv6_prefix" array; then + json_select "ipv6_prefix" + + if json_is_a 1 object; then + json_select 1 + __network_set_cache "${__key}_prefix6_address" address + __network_set_cache "${__key}_prefix6_mask" mask + json_select ".." + fi + + json_select ".." + fi + # parse routes if json_is_a route array; then @@ -170,6 +184,22 @@ network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } # 2: interface network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } +# determine IPv6 prefix +network_get_prefix6() { + local __prefix="$1" + local __iface="$2" + local __address + local __mask + + __network_parse_ifstatus "$__iface" || return 1 + __network_export __address "${__iface}_prefix6_address" + local return="$?" + [ "$return" -eq 0 ] || return $? + __network_export __mask "${__iface}_prefix6_mask" + eval "$__prefix=$__address/$__mask" + return 0 +} + __network_gateway() { -- cgit v1.2.3 From af83088d4355ae96152c9260844d7a9a6f28d58a Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 21 Jan 2013 18:54:58 +0000 Subject: base-files: network.sh: simplify network_get_prefix6() git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35286 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 8f87d1d0b..86b6fc569 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -186,18 +186,15 @@ network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } # determine IPv6 prefix network_get_prefix6() { - local __prefix="$1" + local __var="$1" local __iface="$2" local __address local __mask __network_parse_ifstatus "$__iface" || return 1 - __network_export __address "${__iface}_prefix6_address" - local return="$?" - [ "$return" -eq 0 ] || return $? - __network_export __mask "${__iface}_prefix6_mask" - eval "$__prefix=$__address/$__mask" - return 0 + __network_export __mask "${__iface}_prefix6_mask" || return 1 + __network_export __var "${__iface}_prefix6_address" "$__mask" + return $? } -- cgit v1.2.3 From 19cb7485b1725013ba6a1e941ac5e8b250de2faf Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 21 Jan 2013 19:02:38 +0000 Subject: base-files: network.sh: fix typo in previous commit git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35287 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 86b6fc569..ff153c6c9 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -193,7 +193,7 @@ network_get_prefix6() { __network_parse_ifstatus "$__iface" || return 1 __network_export __mask "${__iface}_prefix6_mask" || return 1 - __network_export __var "${__iface}_prefix6_address" "$__mask" + __network_export __var "${__iface}_prefix6_address" "/$__mask" return $? } -- cgit v1.2.3 From a95f83769f0d3a51bae6d2597a015cbcf76d7ae4 Mon Sep 17 00:00:00 2001 From: cyrus Date: Tue, 22 Jan 2013 16:47:16 +0000 Subject: base-files: fix network_get_prefix6 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35300 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index ff153c6c9..369fa3dbd 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -193,7 +193,7 @@ network_get_prefix6() { __network_parse_ifstatus "$__iface" || return 1 __network_export __mask "${__iface}_prefix6_mask" || return 1 - __network_export __var "${__iface}_prefix6_address" "/$__mask" + __network_export "$__var" "${__iface}_prefix6_address" "/$__mask" return $? } -- cgit v1.2.3 From 0139b32c8243dc5451a444cffba468c3ea149dc5 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 16 Feb 2013 11:50:19 +0000 Subject: base-files: add mtd_get_mac_{ascii,binary} helpers Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35612 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index ae0257a5c..2022e8a3a 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -240,6 +240,40 @@ find_mtd_chardev() { echo "${INDEX:+$PREFIX$INDEX}" } +mtd_get_mac_ascii() +{ + local mtdname="$1" + local key="$2" + local part + local mac_dirty + + . /lib/functions.sh + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2 + return + fi + + mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p') + # "canonicalize" mac + printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x} +} + +mtd_get_mac_binary() { + local mtdname="$1" + local offset="$2" + local part + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_binary: partition $mtdname not found!" >&2 + return + fi + + dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"' +} + strtok() { # { [] ... } local tmp local val="$1" -- cgit v1.2.3 From ce72a70117e7c04466dd5ddde008d9c718c5f09c Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 16 Feb 2013 11:50:22 +0000 Subject: base-files: add macaddr_{add,2bin,setbit_la} helpers Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35614 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 2022e8a3a..a488f4dc0 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -274,6 +274,30 @@ mtd_get_mac_binary() { dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"' } +macaddr_add() { + local mac=$1 + local val=$2 + local oui=${mac%:*:*:*} + local nic=${mac#*:*:*:} + + nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') + echo $oui:$nic +} + +macaddr_setbit_la() +{ + local mac=$1 + + printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} +} + +macaddr_2bin() +{ + local mac=$1 + + echo -ne \\x${mac//:/\\x} +} + strtok() { # { [] ... } local tmp local val="$1" -- cgit v1.2.3 From 7a5d156dbc4dea3bd1b6db8135365dda384695d8 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sun, 17 Feb 2013 21:47:03 +0000 Subject: base-files: minor cosmetic corrections for functions.sh - update copyright header - remove superfluous shebang left-over from changeset 34794 - unify function declaration [juhosg: keep Vertical Communications' copyright notice] Signed-off-by: Michael Heimpold Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35646 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index a488f4dc0..f51bfea45 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -1,6 +1,7 @@ #!/bin/sh -# Copyright (C) 2006-2011 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # Copyright (C) 2006 Fokus Fraunhofer +# Copyright (C) 2010 Vertical Communications debug () { @@ -406,10 +407,6 @@ pi_include() { return 0 } -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - boot_hook_splice_start() { export -n PI_HOOK_SPLICE=1 } @@ -472,7 +469,7 @@ boot_run_hook() { done } -jffs2_ready () { +jffs2_ready() { mtdpart="$(find_mtd_part rootfs_data)" [ -z "$mtdpart" ] && return 1 magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') -- cgit v1.2.3 From fb1862c487ba175fb3222d3cb0d233e2cf07c597 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 18 Feb 2013 09:56:23 +0000 Subject: base-files: introduce commonly used helper functions for setting leds Currently, most platforms define such helpers in their own diag.sh implementation with almost identical code. By factoring out the common ground it's possible to simplify maintainability and homogenize the haptics over multiple platforms (so far as is reasonably practicable, in a next step). [juhosg: - fix led_set_attr parameters in led_timer - add led_morse and status_led_set_morse helpers - add status_led_blink_{preinit,failsafe} helpers] Signed-off-by: Michael Heimpold Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35648 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/leds.sh | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 package/base-files/files/lib/functions/leds.sh (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/leds.sh b/package/base-files/files/lib/functions/leds.sh new file mode 100644 index 000000000..743c7da78 --- /dev/null +++ b/package/base-files/files/lib/functions/leds.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# Copyright (C) 2013 OpenWrt.org + +led_set_attr() { + [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2" +} + +led_timer() { + led_set_attr $1 "trigger" "timer" + led_set_attr $1 "delay_on" "$2" + led_set_attr $1 "delay_off" "$3" +} + +led_on() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 255 +} + +led_off() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 0 +} + +led_morse() { + led_set_attr $1 "trigger" "morse" + led_set_attr $1 "delay" "$2" + led_set_attr $1 "message" "$3" +} + +status_led_set_timer() { + led_timer $status_led "$1" "$2" + [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2" +} + +status_led_set_heartbeat() { + led_set_attr $status_led "trigger" "heartbeat" +} + +status_led_set_morse() { + led_morse $status_led "$1" "$2" + [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2" +} + +status_led_on() { + led_on $status_led + [ -n "$status_led2" ] && led_on $status_led2 +} + +status_led_off() { + led_off $status_led + [ -n "$status_led2" ] && led_off $status_led2 +} + +status_led_blink_slow() { + led_timer $status_led 1000 1000 +} + +status_led_blink_fast() { + led_timer $status_led 100 100 +} + +status_led_blink_preinit() { + led_timer $status_led 200 200 +} + +status_led_blink_failsafe() { + led_timer $status_led 50 50 +} -- cgit v1.2.3 From 35dde6748e98a2a7725e220c5ea8f63c7d9c185c Mon Sep 17 00:00:00 2001 From: blogic Date: Wed, 13 Mar 2013 18:11:19 +0000 Subject: [base-files] make basefiles aware of procd Signed-off-by: John Crispin git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36003 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/lib/firstboot/99_10_with_fo_cleanup | 2 +- .../base-files/files/lib/preinit/10_essential_fs | 25 --------------- .../files/lib/preinit/10_indicate_preinit | 1 - .../files/lib/preinit/20_device_fs_mount | 37 ---------------------- .../files/lib/preinit/30_device_fs_daemons | 36 --------------------- .../base-files/files/lib/preinit/30_failsafe_wait | 5 ++- package/base-files/files/lib/preinit/40_init_shm | 10 ------ .../base-files/files/lib/preinit/40_mount_devpts | 15 --------- .../base-files/files/lib/preinit/50_choose_console | 31 ------------------ .../files/lib/preinit/50_indicate_regular_preinit | 1 - .../base-files/files/lib/preinit/60_init_hotplug | 10 ------ package/base-files/files/lib/preinit/80_mount_root | 3 +- .../base-files/files/lib/preinit/90_init_console | 14 -------- .../base-files/files/lib/preinit/99_10_run_init | 6 ---- package/base-files/files/lib/upgrade/common.sh | 2 +- 15 files changed, 5 insertions(+), 193 deletions(-) delete mode 100644 package/base-files/files/lib/preinit/10_essential_fs delete mode 100644 package/base-files/files/lib/preinit/20_device_fs_mount delete mode 100644 package/base-files/files/lib/preinit/30_device_fs_daemons delete mode 100644 package/base-files/files/lib/preinit/40_init_shm delete mode 100644 package/base-files/files/lib/preinit/40_mount_devpts delete mode 100644 package/base-files/files/lib/preinit/50_choose_console delete mode 100644 package/base-files/files/lib/preinit/60_init_hotplug delete mode 100644 package/base-files/files/lib/preinit/90_init_console (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup index 0181b39d4..560169901 100644 --- a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup +++ b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup @@ -6,7 +6,7 @@ with_fo_cleanup() { # try to get rid of /tmp/root # this will almost always fail - umount /tmp/root 2>&- + umount -l /tmp/root 2>&- grep -q overlay /proc/filesystems && { cd / ( diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs deleted file mode 100644 index fc04eb7ff..000000000 --- a/package/base-files/files/lib/preinit/10_essential_fs +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_procfs() { - mount -o noatime -t proc proc /proc -} - -do_mount_sysfs() { - mount -o noatime -tsysfs sysfs /sys -} - -calc_tmpfs_size() { - pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)l)?mt-l:s}' /proc/meminfo) -} - -do_mount_tmpfs() { - calc_tmpfs_size - mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp -} - -boot_hook_add preinit_essential do_mount_procfs -boot_hook_add preinit_essential do_mount_sysfs -boot_hook_add preinit_essential do_mount_tmpfs - diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index 4a0109cc1..da70b97c4 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -41,7 +41,6 @@ pi_indicate_led() { } pi_indicate_preinit() { - echo "- preinit -" preinit_net_echo "Doing OpenWRT Preinit\n" pi_indicate_led } diff --git a/package/base-files/files/lib/preinit/20_device_fs_mount b/package/base-files/files/lib/preinit/20_device_fs_mount deleted file mode 100644 index 7535b3ff9..000000000 --- a/package/base-files/files/lib/preinit/20_device_fs_mount +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_move_devtmpfs() { - local mnt="$(grep devtmpfs /proc/mounts)" - mnt="${mnt#* }"; mnt="${mnt%% *}" - - [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev -} - -do_mount_devfs() { - mount -o noatime -t devfs devfs /dev -} - -do_mount_hotplug() { - mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev -} - -do_mount_udev() { - mount -n -t tmpfs -o noatime,mode=0755 udev /dev -} - -choose_device_fs() { - if grep -q devtmpfs /proc/mounts; then - do_move_devtmpfs - elif grep -q devfs /proc/filesystems; then - do_mount_devfs - elif [ -x /sbin/hotplug2 ]; then - do_mount_hotplug - elif [ -x /sbin/udevd ]; then - do_mount_udev - fi -} - -boot_hook_add preinit_essential choose_device_fs - diff --git a/package/base-files/files/lib/preinit/30_device_fs_daemons b/package/base-files/files/lib/preinit/30_device_fs_daemons deleted file mode 100644 index 8379e5e74..000000000 --- a/package/base-files/files/lib/preinit/30_device_fs_daemons +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2013 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_devfs() { - HOTPLUG=/sbin/hotplug-call -} - -init_hotplug2() { - [ -c /dev/console ] || mknod /dev/console c 5 1 - /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger - /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --persistent & -} - -init_udev() { - [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/ - [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1 - [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3 - /sbin/udevd --daemon --resolve-names=never - /sbin/udevadm trigger - /sbin/udevadm settle -} - -init_device_fs() { - HOTPLUG= - if grep -q devfs /proc/filesystems; then - init_devfs - elif [ -x /sbin/hotplug2 ]; then - init_hotplug2 - elif [ -x /sbin/udevd ]; then - init_udev - fi -} - -boot_hook_add preinit_essential init_device_fs - diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index 04dc57df2..808d9731b 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -61,11 +61,10 @@ fs_wait_for_key () { } lock -w $keypress_wait - trap - INT - trap - USR1 - keypressed=1 [ "$(cat $keypress_true)" = "true" ] && keypressed=0 + [ -f "/tmp/failsafe_button" ] && keypressed=1 + rm -f $keypress_true rm -f $keypress_wait rm -f $keypress_sec diff --git a/package/base-files/files/lib/preinit/40_init_shm b/package/base-files/files/lib/preinit/40_init_shm deleted file mode 100644 index 8971116a4..000000000 --- a/package/base-files/files/lib/preinit/40_init_shm +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_shm() { - [ -d /dev/shm ] || mkdir -p /dev/shm -} - -boot_hook_add preinit_essential init_shm - diff --git a/package/base-files/files/lib/preinit/40_mount_devpts b/package/base-files/files/lib/preinit/40_mount_devpts deleted file mode 100644 index b55a7f2e8..000000000 --- a/package/base-files/files/lib/preinit/40_mount_devpts +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_devpts() { - [ -d /dev/pts ] || mkdir -p /dev/pts -} - -do_mount_devpts() { - mount -o noatime -t devpts devpts /dev/pts -} - -boot_hook_add preinit_essential init_devpts -boot_hook_add preinit_essential do_mount_devpts - diff --git a/package/base-files/files/lib/preinit/50_choose_console b/package/base-files/files/lib/preinit/50_choose_console deleted file mode 100644 index ecbc2eaf4..000000000 --- a/package/base-files/files/lib/preinit/50_choose_console +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -choose_console() { - # the shell really doesn't like having stdin/out closed - # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement - # for /dev/console if there's no serial console available - - if grep -q devfs /proc/filesystems; then - M0=/dev/pty/m0 - M1=/dev/pty/m1 - M2=/dev/pty/m1 - elif [ -x /sbin/hotplug2 ]; then - M0=/dev/ptmx - M1=/dev/ptmx - M2=/dev/ptmx - elif [ -x /sbin/udevd ]; then - M0=/dev/pty/ptmx - M1=/dev/pty/ptmx - M2=/dev/pty/ptmx - fi - dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && { - M0=/dev/console - M1=/dev/console - M2=/dev/console - } -} - -boot_hook_add preinit_essential choose_console - diff --git a/package/base-files/files/lib/preinit/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit index 9cc01f219..c200dad67 100644 --- a/package/base-files/files/lib/preinit/50_indicate_regular_preinit +++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit @@ -3,7 +3,6 @@ # Copyright (C) 2010 Vertical Communications indicate_regular_preinit() { - echo "- regular preinit -" preinit_net_echo "Continuing with Regular Preinit\n" pi_indicate_led } diff --git a/package/base-files/files/lib/preinit/60_init_hotplug b/package/base-files/files/lib/preinit/60_init_hotplug deleted file mode 100644 index dc05e0ed0..000000000 --- a/package/base-files/files/lib/preinit/60_init_hotplug +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_hotplug() { - echo "$HOTPLUG" > /proc/sys/kernel/hotplug -} - -boot_hook_add preinit_main init_hotplug - diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root index ad24fb8ac..9a99ee910 100644 --- a/package/base-files/files/lib/preinit/80_mount_root +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -6,5 +6,4 @@ do_mount_root() { boot_run_hook preinit_mount_root } -boot_hook_add preinit_main do_mount_root - +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/90_init_console b/package/base-files/files/lib/preinit/90_init_console deleted file mode 100644 index ca05755fd..000000000 --- a/package/base-files/files/lib/preinit/90_init_console +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -init_console() { - if [ "$pi_suppress_stderr" = "y" ]; then - exec <$M0 >$M1 2>&0 - else - exec <$M0 >$M1 2>$M2 - fi -} - -boot_hook_add preinit_essential init_console - diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init index fef3a503e..a8f330f89 100644 --- a/package/base-files/files/lib/preinit/99_10_run_init +++ b/package/base-files/files/lib/preinit/99_10_run_init @@ -3,13 +3,7 @@ # Copyright (C) 2010 Vertical Communications run_init() { - preinit_echo "- init -" preinit_ip_deconfig - if [ "$pi_init_suppress_stderr" = "y" ]; then - exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0 - else - exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd - fi } boot_hook_add preinit_main run_init diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 2e123ab3c..969aecb7f 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -38,7 +38,7 @@ supivot() { # mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ mount -o noatime,move /proc $1/proc && \ pivot_root $1 $1$2 || { - umount $1 $1 + umount -l $1 $1 return 1 } -- cgit v1.2.3 From 98636ab77d7e7ce6d4f2d1d977708ad0f1d635e0 Mon Sep 17 00:00:00 2001 From: blogic Date: Thu, 14 Mar 2013 18:43:58 +0000 Subject: [base-files] sysupgrade was broken as procd was getting killed Signed-off-by: John Crispin git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36031 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/upgrade/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 969aecb7f..df842bf92 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -99,7 +99,7 @@ kill_remaining() { # [ ] case "$name" in # Skip essential services - *ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;; + *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;; # Killable process *) -- cgit v1.2.3 From fbdb365ec23e45cbb1b68bfcffaad1d220400502 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 22 Mar 2013 10:06:06 +0000 Subject: base-files: sysupgrade fail with eglibc With eglibc, "ldd busybox" give us libcrypt.so.1 => /lib/libcrypt.so.1 (0x774be000) libm.so.6 => /lib/libm.so.6 (0x773e4000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x773c0000) libc.so.6 => /lib/libc.so.6 (0x77276000) /lib/ld.so.1 (0x774fe000) Thus /lib/ld.so.1 is not printed by the libs fonction and isn't copied to the 'new' root before pivot root libs() { ldd $* | awk '{print $3}'; } https://dev.openwrt.org/browser/trunk/package/base-files/files/lib/upgrade/common.sh With uclibc the last line of "ldd busybox" is ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x77ada000) Don't know for musl! This patch replace https://dev.openwrt.org/changeset/19167, as glibc is gone The other way around is to rework libs() Please apply the fix (mine or another) on trunk and AA Might fix https://dev.openwrt.org/ticket/12273 Signed-off-by: Etienne CHAMPETIER Signed-off-by: Florian Fainelli git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36107 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/upgrade/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index df842bf92..fbe54a5ee 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -21,8 +21,8 @@ install_bin() { # [ ... ] files=$1 [ -x "$src" ] && files="$src $(libs $src)" install_file $files - [ -e /lib/ld-linux.so.3 ] && { - install_file /lib/ld-linux.so.3 + [ -e /lib/ld.so.1 ] && { + install_file /lib/ld.so.1 } shift for link in "$@"; do { -- cgit v1.2.3 From 7b026cdf8a8da5c160105cae06813c956766b65c Mon Sep 17 00:00:00 2001 From: cyrus Date: Tue, 9 Apr 2013 08:03:08 +0000 Subject: Adapt default network configuration for IPv6 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36278 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/uci-defaults.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 477c00cfd..959ae5eba 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -150,6 +150,8 @@ set network.loopback.ifname='lo' set network.loopback.proto='static' set network.loopback.ipaddr='127.0.0.1' set network.loopback.netmask='255.0.0.0' +set network.globals='globals' +set network.globals.ula_prefix='auto' EOF } @@ -174,6 +176,7 @@ set network.lan.type='bridge' set network.lan.proto='static' set network.lan.ipaddr='192.168.1.1' set network.lan.netmask='255.255.255.0' +set network.lan.ip6assign='64' EOF } @@ -184,6 +187,9 @@ ucidef_set_interface_wan() { set network.wan='interface' set network.wan.ifname='$ifname' set network.wan.proto='dhcp' +set network.wan6='interface' +set network.wan6.ifname='@wan' +set network.wan6.proto='dhcpv6' EOF } -- cgit v1.2.3 From c37a21d752af2af20e31fde9235c85161a8c5e8a Mon Sep 17 00:00:00 2001 From: cyrus Date: Mon, 22 Apr 2013 19:40:16 +0000 Subject: Change default IPv6 config to enable DHCPv6-PD git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36384 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/uci-defaults.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 959ae5eba..bf6fe1e30 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -176,7 +176,7 @@ set network.lan.type='bridge' set network.lan.proto='static' set network.lan.ipaddr='192.168.1.1' set network.lan.netmask='255.255.255.0' -set network.lan.ip6assign='64' +set network.lan.ip6assign='60' EOF } -- cgit v1.2.3 From b5367474cba180d7b2555e4e30421a7340f63264 Mon Sep 17 00:00:00 2001 From: blogic Date: Thu, 25 Apr 2013 19:02:32 +0000 Subject: mount_root: prepare base-files Signed-off-by: John Crispin git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36429 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/lib/firstboot/05_firstboot_skip | 10 ----- .../files/lib/firstboot/10_determine_parts | 46 ---------------------- .../files/lib/firstboot/10_no_fo_clear_overlay | 17 -------- .../files/lib/firstboot/10_reset_has_mini_fo | 12 ------ .../base-files/files/lib/firstboot/20_has_mini_fo | 13 ------ .../files/lib/firstboot/20_no_fo_mount_jffs | 15 ------- .../files/lib/firstboot/20_reset_clear_jffs | 14 ------- .../files/lib/firstboot/30_is_rootfs_mounted | 10 ----- .../base-files/files/lib/firstboot/30_no_fo_pivot | 11 ------ .../files/lib/firstboot/30_reset_copy_rom | 13 ------ .../files/lib/firstboot/40_copy_ramoverlay | 15 ------- .../files/lib/firstboot/40_no_fo_copy_ramoverlay | 14 ------- package/base-files/files/lib/firstboot/50_pivot | 17 -------- .../files/lib/firstboot/99_10_no_fo_cleanup | 13 ------ .../files/lib/firstboot/99_10_with_fo_cleanup | 25 ------------ package/base-files/files/lib/preinit/05_mount_skip | 13 ------ .../base-files/files/lib/preinit/10_check_for_mtd | 20 ---------- .../files/lib/preinit/20_check_jffs2_ready | 19 --------- .../base-files/files/lib/preinit/40_mount_jffs2 | 26 ------------ .../files/lib/preinit/41_merge_overlay_hooks | 24 ----------- .../files/lib/preinit/70_pivot_jffs2_root | 14 ------- package/base-files/files/lib/preinit/80_mount_root | 11 +++++- .../base-files/files/lib/preinit/90_mount_no_jffs2 | 12 ------ .../base-files/files/lib/preinit/90_restore_config | 17 -------- .../files/lib/preinit/99_10_mount_no_mtd | 12 ------ 25 files changed, 10 insertions(+), 403 deletions(-) delete mode 100644 package/base-files/files/lib/firstboot/05_firstboot_skip delete mode 100644 package/base-files/files/lib/firstboot/10_determine_parts delete mode 100644 package/base-files/files/lib/firstboot/10_no_fo_clear_overlay delete mode 100644 package/base-files/files/lib/firstboot/10_reset_has_mini_fo delete mode 100644 package/base-files/files/lib/firstboot/20_has_mini_fo delete mode 100644 package/base-files/files/lib/firstboot/20_no_fo_mount_jffs delete mode 100644 package/base-files/files/lib/firstboot/20_reset_clear_jffs delete mode 100644 package/base-files/files/lib/firstboot/30_is_rootfs_mounted delete mode 100644 package/base-files/files/lib/firstboot/30_no_fo_pivot delete mode 100644 package/base-files/files/lib/firstboot/30_reset_copy_rom delete mode 100644 package/base-files/files/lib/firstboot/40_copy_ramoverlay delete mode 100644 package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay delete mode 100644 package/base-files/files/lib/firstboot/50_pivot delete mode 100644 package/base-files/files/lib/firstboot/99_10_no_fo_cleanup delete mode 100644 package/base-files/files/lib/firstboot/99_10_with_fo_cleanup delete mode 100644 package/base-files/files/lib/preinit/05_mount_skip delete mode 100644 package/base-files/files/lib/preinit/10_check_for_mtd delete mode 100644 package/base-files/files/lib/preinit/20_check_jffs2_ready delete mode 100644 package/base-files/files/lib/preinit/40_mount_jffs2 delete mode 100644 package/base-files/files/lib/preinit/41_merge_overlay_hooks delete mode 100644 package/base-files/files/lib/preinit/70_pivot_jffs2_root delete mode 100644 package/base-files/files/lib/preinit/90_mount_no_jffs2 delete mode 100644 package/base-files/files/lib/preinit/90_restore_config delete mode 100644 package/base-files/files/lib/preinit/99_10_mount_no_mtd (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/firstboot/05_firstboot_skip b/package/base-files/files/lib/firstboot/05_firstboot_skip deleted file mode 100644 index 5f44df621..000000000 --- a/package/base-files/files/lib/firstboot/05_firstboot_skip +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -check_skip() { - if [ "$firstboot_skip_next" = "true" ]; then - return 0 - else - return 1 - fi -} - diff --git a/package/base-files/files/lib/firstboot/10_determine_parts b/package/base-files/files/lib/firstboot/10_determine_parts deleted file mode 100644 index 3f56e32a8..000000000 --- a/package/base-files/files/lib/firstboot/10_determine_parts +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -set_mtd_part() { - partname="rootfs_data" - mtdpart="$(find_mtd_part $partname)" -} - -set_rom_part() { - rom=$(awk '/squashfs/ {print $2}' /proc/mounts) -} - -set_jffs_part() { - jffs=$(awk '/jffs2/ {print $2}' /proc/mounts) -} - -determine_mtd_part() { - set_mtd_part - if [ -z "$mtdpart" ]; then - echo "MTD partition not found." - exit 1 - fi -} - -determine_rom_part() { - check_skip || { - set_rom_part - if [ -z "$rom" ]; then - echo "You do not have a squashfs partition; aborting" - echo "(firstboot cannot be run on jffs2 based firmwares)" - exit 1 - fi - } -} - -determine_jffs2_part() { - check_skip || { - set_jffs_part - } -} - -boot_hook_add switch2jffs determine_mtd_part -boot_hook_add jffs2reset determine_mtd_part -boot_hook_add switch2jffs determine_rom_part -boot_hook_add jffs2reset determine_rom_part -boot_hook_add switch2jffs determine_jffs2_part -boot_hook_add jffs2reset determine_jffs2_part diff --git a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay deleted file mode 100644 index 8a7d9b066..000000000 --- a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -no_fo_clear_overlay() { - # switch back to squashfs temporarily - pivot /rom /mnt - - # get rid of the old overlay - umount -l /mnt - - # another umount to get rid of the bind from /tmp/root - umount -l /mnt -} - -boot_hook_add no_fo no_fo_clear_overlay diff --git a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo deleted file mode 100644 index 4e285840a..000000000 --- a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -reset_check_for_overlay() { - if grep -qE '(mini_fo|overlay)' /proc/filesystems; then - reset_has_fo=true - fi -} - -boot_hook_add jffs2reset reset_check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_has_mini_fo b/package/base-files/files/lib/firstboot/20_has_mini_fo deleted file mode 100644 index 8ca6a4fe5..000000000 --- a/package/base-files/files/lib/firstboot/20_has_mini_fo +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -check_for_overlay() { - if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then - boot_run_hook no_fo - exit 1 - fi -} - -boot_hook_add switch2jffs check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs deleted file mode 100644 index c03714fa6..000000000 --- a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -no_fo_mount_jffs() { - # initialize jffs2 - mount -o noatime "$mtdpart" /overlay -t jffs2 || exit - - # workaround to ensure that union can attach properly - sync - ls /overlay >/dev/null -} - -boot_hook_add no_fo no_fo_mount_jffs diff --git a/package/base-files/files/lib/firstboot/20_reset_clear_jffs b/package/base-files/files/lib/firstboot/20_reset_clear_jffs deleted file mode 100644 index a3cd24fe9..000000000 --- a/package/base-files/files/lib/firstboot/20_reset_clear_jffs +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -reset_clear_jffs() { - [ "$reset_has_fo" = "true" ] && { - rm -rf $jffs/* 2>&- - mount -o remount $jffs / 2>&- - exit 0 - } || reset_has_fo=false -} - -boot_hook_add jffs2reset reset_clear_jffs diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted deleted file mode 100644 index 7233fd903..000000000 --- a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -skip_if_rootfs_mounted() { - mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit -} - -boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/firstboot/30_no_fo_pivot b/package/base-files/files/lib/firstboot/30_no_fo_pivot deleted file mode 100644 index b5c2601ee..000000000 --- a/package/base-files/files/lib/firstboot/30_no_fo_pivot +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -no_fo_pivot() { - # switch to the new (empty) jffs2 - fopivot /overlay /rom 1 -} - -boot_hook_add no_fo no_fo_pivot diff --git a/package/base-files/files/lib/firstboot/30_reset_copy_rom b/package/base-files/files/lib/firstboot/30_reset_copy_rom deleted file mode 100644 index d91c68947..000000000 --- a/package/base-files/files/lib/firstboot/30_reset_copy_rom +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -reset_copy_rom() { - [ "$reset_has_fo" != "true" ] && { - dupe $jffs $rom - exit 0 - } -} - -boot_hook_add jffs2reset reset_copy_rom diff --git a/package/base-files/files/lib/firstboot/40_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_copy_ramoverlay deleted file mode 100644 index 39c2edacb..000000000 --- a/package/base-files/files/lib/firstboot/40_copy_ramoverlay +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -copy_ramoverlay() { - # try to avoid fs changing while copying - mount -o remount,ro none / 2>&- - # copy ramoverlay to jffs2 - echo -n "copying files ... " - cp -a /tmp/root/* /rom/overlay 2>&- - echo "done" -} - -boot_hook_add switch2jffs copy_ramoverlay diff --git a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay deleted file mode 100644 index ced7c1b66..000000000 --- a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -no_fo_copy_ramoverlay() { - # copy ramoverlay to jffs2, must be done after switching - # to the new rootfs to avoid creating opaque directories - echo -n "copying files ... " - cp -a /tmp/root/* / >/dev/null 2>&1 - sync -} - -boot_hook_add no_fo no_fo_ramoverlay diff --git a/package/base-files/files/lib/firstboot/50_pivot b/package/base-files/files/lib/firstboot/50_pivot deleted file mode 100644 index 53801d7a8..000000000 --- a/package/base-files/files/lib/firstboot/50_pivot +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -with_fo_pivot() { - # switch back to squashfs (temporarily) - # and park the ramdisk ontop of /tmp/root - pivot /rom /mnt - mount -o move /mnt /tmp/root - - # /overlay is the overlay - # /rom is the readonly - fopivot /overlay /rom -} - -boot_hook_add switch2jffs with_fo_pivot diff --git a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup deleted file mode 100644 index 6dedcb1e8..000000000 --- a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -no_fo_cleanup() { - echo "done" - umount -l /overlay - umount -l /tmp/root - exit 0 -} - -boot_hook_add no_fo no_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup deleted file mode 100644 index 560169901..000000000 --- a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -with_fo_cleanup() { - # try to get rid of /tmp/root - # this will almost always fail - umount -l /tmp/root 2>&- - grep -q overlay /proc/filesystems && { - cd / - ( - cd /overlay - find -type l - ) | while read FILE; do - [ -z "$FILE" ] && break - if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then - rm -f "$FILE" - fi - done - } - exit 0 -} - -boot_hook_add switch2jffs with_fo_cleanup diff --git a/package/base-files/files/lib/preinit/05_mount_skip b/package/base-files/files/lib/preinit/05_mount_skip deleted file mode 100644 index c2b7ee79d..000000000 --- a/package/base-files/files/lib/preinit/05_mount_skip +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -check_skip() { - if [ "$pi_mount_skip_next" = "true" ]; then - return 0 - else - return 1 - fi -} - diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd deleted file mode 100644 index 6a7bd307f..000000000 --- a/package/base-files/files/lib/preinit/10_check_for_mtd +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -mount_no_mtd() { - mtd unlock rootfs - mount -o noatime,remount,rw /dev/root / -} - -check_for_mtd() { - check_skip || { - grep -qs rootfs_data /proc/mtd || { - mount_no_mtd && pi_mount_skip_next=true - } - } -} - -boot_hook_add preinit_mount_root check_for_mtd - diff --git a/package/base-files/files/lib/preinit/20_check_jffs2_ready b/package/base-files/files/lib/preinit/20_check_jffs2_ready deleted file mode 100644 index 3c5cf67e8..000000000 --- a/package/base-files/files/lib/preinit/20_check_jffs2_ready +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -mount_no_jffs2() { - echo "jffs2 not ready yet; using ramdisk" - ramoverlay -} - -check_for_jffs2() { - check_skip || { - jffs2_ready || { - mount_no_jffs2 && pi_mount_skip_next=true - } - } -} - -boot_hook_add preinit_mount_root check_for_jffs2 - diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2 deleted file mode 100644 index ded785ed5..000000000 --- a/package/base-files/files/lib/preinit/40_mount_jffs2 +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -find_mount_jffs2() { - mkdir -p /tmp/overlay - mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay - mtd -qq unlock rootfs_data -} - -jffs2_not_mounted() { - if [ "$pi_jffs2_mount_success" != "true" ]; then - return 0 - else - return 1 - fi -} - -do_mount_jffs2() { - check_skip || { - find_mount_jffs2 && pi_jffs2_mount_success=true - } -} - -boot_hook_add preinit_mount_root do_mount_jffs2 - diff --git a/package/base-files/files/lib/preinit/41_merge_overlay_hooks b/package/base-files/files/lib/preinit/41_merge_overlay_hooks deleted file mode 100644 index 4ca6877be..000000000 --- a/package/base-files/files/lib/preinit/41_merge_overlay_hooks +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Copyright (C) 2010 OpenWrt.org - -merge_overlay_hooks() { - jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || { - echo "- merge overlay components -" - - mkdir -p /tmp/preinit-hook-merge - ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/ - - boot_hook_splice_start - - local pipart - for pipart in /tmp/preinit-hook-merge/*; do - . $pipart - done - - boot_hook_splice_finish - - rm -rf /tmp/preinit-hook-merge - } -} - -boot_hook_add preinit_mount_root merge_overlay_hooks diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root deleted file mode 100644 index b76f111ca..000000000 --- a/package/base-files/files/lib/preinit/70_pivot_jffs2_root +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -rootfs_pivot() { - check_skip || jffs2_not_mounted || { - echo "switching to jffs2" - mount -o noatime,move /tmp/overlay /overlay 2>&- - fopivot /overlay /rom && pi_mount_skip_next=true - } -} - -boot_hook_add preinit_mount_root rootfs_pivot - diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root index 9a99ee910..0292d82d4 100644 --- a/package/base-files/files/lib/preinit/80_mount_root +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -3,7 +3,16 @@ # Copyright (C) 2010 Vertical Communications do_mount_root() { - boot_run_hook preinit_mount_root + mount_root + boot_run_hook preinit_mount_root + [ -f /sysupgrade.tgz ] && { + echo "- config restore -" + cd / + mv sysupgrade.tgz /tmp + tar xzf /tmp/sysupgrade.tgz + rm -f /tmp/sysupgrade.tgz + sync + } } [ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/90_mount_no_jffs2 b/package/base-files/files/lib/preinit/90_mount_no_jffs2 deleted file mode 100644 index d8ad4ae11..000000000 --- a/package/base-files/files/lib/preinit/90_mount_no_jffs2 +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_no_jffs2() { - check_skip || { - mount_no_jffs2 && pi_mount_skip_next=true - } -} - -boot_hook_add preinit_mount_root do_mount_no_jffs2 - diff --git a/package/base-files/files/lib/preinit/90_restore_config b/package/base-files/files/lib/preinit/90_restore_config deleted file mode 100644 index 210bf6184..000000000 --- a/package/base-files/files/lib/preinit/90_restore_config +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -restore_config() { - [ -f /sysupgrade.tgz ] && { - echo "- config restore -" - cd / - mv sysupgrade.tgz /tmp - tar xzf /tmp/sysupgrade.tgz - rm -f /tmp/sysupgrade.tgz - sync - } -} - -boot_hook_add preinit_main restore_config - diff --git a/package/base-files/files/lib/preinit/99_10_mount_no_mtd b/package/base-files/files/lib/preinit/99_10_mount_no_mtd deleted file mode 100644 index c4f38e415..000000000 --- a/package/base-files/files/lib/preinit/99_10_mount_no_mtd +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications - -do_mount_no_mtd() { - check_skip || { - mount_no_mtd - } -} - -boot_hook_add preinit_mount_root do_mount_no_mtd - -- cgit v1.2.3 From e8ac3affe018cbf45e8a8354631bfa600421fac0 Mon Sep 17 00:00:00 2001 From: blogic Date: Thu, 25 Apr 2013 19:02:37 +0000 Subject: preinit: move cmdline failsafe= handling ot the generic code Signed-off-by: John Crispin git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36430 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/preinit/30_failsafe_wait | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index 808d9731b..bcf24f8bb 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -74,10 +74,13 @@ fs_wait_for_key () { failsafe_wait() { FAILSAFE= - pi_failsafe_net_message=true - preinit_net_echo "Please press button now to enter failsafe" - pi_failsafe_net_message=false - fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + pi_failsafe_net_message=true + preinit_net_echo "Please press button now to enter failsafe" + pi_failsafe_net_message=false + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + fi } boot_hook_add preinit_main failsafe_wait -- cgit v1.2.3 From 6b897bcdc144439050e38d82e506fc9d8d1827d3 Mon Sep 17 00:00:00 2001 From: blogic Date: Sun, 5 May 2013 12:41:42 +0000 Subject: sysupgrade: fixes broken pipe error during sysupgade Signed-off-by: John Crispin git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36548 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/upgrade/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index fbe54a5ee..6bb36db48 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -157,14 +157,14 @@ get_image() { # [ ] *) cmd="cat";; esac if [ -z "$conc" ]; then - local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" + local magic="$(eval $cmd $from 2>/dev/null | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" case "$magic" in 1f8b) conc="zcat";; 425a) conc="bzcat";; esac fi - eval "$cmd $from ${conc:+| $conc}" + eval "$cmd $from 2>/dev/null ${conc:+| $conc}" } get_magic_word() { -- cgit v1.2.3 From bd4ec4d567494ce433865557e7896a2072f16707 Mon Sep 17 00:00:00 2001 From: jow Date: Mon, 6 May 2013 09:33:56 +0000 Subject: base-files: change network_find_wan() procedure to ignore default gateways in different routing tables git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36553 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'package/base-files/files/lib') diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 369fa3dbd..d86a504bf 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -80,16 +80,20 @@ __network_parse_ifstatus() while json_is_a "$__idx" object; do json_select "$((__idx++))" - json_get_var __tmp target - - case "${__tmp}" in - 0.0.0.0) - __network_set_cache "${__key}_gateway4" nexthop - ;; - ::) - __network_set_cache "${__key}_gateway6" nexthop - ;; - esac + json_get_var __tmp table + + if [ -z "$__tmp" ]; then + json_get_var __tmp target + + case "${__tmp}" in + 0.0.0.0) + __network_set_cache "${__key}_gateway4" nexthop + ;; + ::) + __network_set_cache "${__key}_gateway6" nexthop + ;; + esac + fi json_select ".." -- cgit v1.2.3