local cfgtype="$1"
local name="$2"
- export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$((CONFIG_NUM_SECTIONS + 1))
name="${name:-cfg$CONFIG_NUM_SECTIONS}"
append CONFIG_SECTIONS "$name"
export ${NO_EXPORT:+-n} CONFIG_SECTION="$name"
config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
[ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
- len=$(($len + 1))
+ len=$((len + 1))
config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP"
# config_get <variable> <section> <option> [<default>]
# config_get <section> <option>
config_get() {
- case "$3" in
- "") eval echo "\"\${CONFIG_${1}_${2}:-\${4}}\"";;
- *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
+ case "$2${3:-$1}" in
+ *[^A-Za-z0-9_]*) : ;;
+ *)
+ case "$3" in
+ "") eval echo "\"\${CONFIG_${1}_${2}:-\${4}}\"";;
+ *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
+ esac
+ ;;
esac
}
[ -z "$CONFIG_SECTIONS" ] && return 0
for section in ${CONFIG_SECTIONS}; do
config_get cfgtype "$section" TYPE
- [ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue
+ [ -n "$___type" ] && [ "x$cfgtype" != "x$___type" ] && continue
eval "$___function \"\$section\" \"\$@\""
done
}
while [ $c -le "$len" ]; do
config_get val "${section}" "${option}_ITEM$c"
eval "$function \"\$val\" \"\$@\""
- c="$(($c + 1))"
+ c="$((c + 1))"
done
}
ret=$?
fi
- local shell="$(which bash)"
+ local shell="$(command -v bash)"
for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
if [ -n "$root" ]; then
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable
fi
if grep -m1 -q -s "^/etc/uci-defaults/" "$filelist"; then
- . /lib/functions/system.sh
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
for i in $(grep -s "^/etc/uci-defaults/" "$filelist"); do
( [ -f "$i" ] && cd "$(dirname $i)" && . "$i" ) && rm -f "$i"
rm -f /tmp/luci-indexcache
fi
- local shell="$(which bash)"
+ local shell="$(command -v bash)"
for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
if [ -n "$root" ]; then
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable
echo $gid
return
fi
- gids=$(cat ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
+ gids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/group)
gid=65536
- while [ -n "$(echo "$gids" | grep "^$gid$")" ] ; do
- gid=$((gid + 1))
+ while echo "$gids" | grep -q "^$gid$"; do
+ gid=$((gid + 1))
done
group_add $1 $gid
echo $gid
group_add_user() {
local grp delim=","
grp=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group)
- [ -z "$(echo $grp | cut -d: -f4 | grep $2)" ] || return
- [ -n "$(echo $grp | grep ":$")" ] && delim=""
+ echo "$grp" | cut -d: -f4 | grep -q $2 && return
+ echo "$grp" | grep -q ":$" && delim=""
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
sed -i "s/$grp/$grp$delim$2/g" ${IPKG_INSTROOT}/etc/group
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
local shell="${6:-/bin/false}"
local rc
[ -z "$uid" ] && {
- uids=$(cat ${IPKG_INSTROOT}/etc/passwd | cut -d: -f3)
+ uids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/passwd)
uid=65536
- while [ -n "$(echo "$uids" | grep "^$uid$")" ] ; do
- uid=$((uid + 1))
+ while echo "$uids" | grep -q "^$uid$"; do
+ uid=$((uid + 1))
done
}
[ -z "$gid" ] && gid=$uid
[ -e /tmp/sysinfo/board_name ] && cat /tmp/sysinfo/board_name || echo "generic"
}
-[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
+[ -z "$IPKG_INSTROOT" ] && [ -f /lib/config/uci.sh ] && . /lib/config/uci.sh