Changeset 76b8726 in freewrt for package


Ignore:
Timestamp:
Jul 18, 2006, 2:56:53 PM (19 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
ce3d5c7
Parents:
042eeb3
Message:

remove useless spaces, quoting, {...} blocks,
useless use of cat, etc.

please test

XXX the passwd and group functions could be merged

git-svn-id: svn://www.freewrt.org/trunk/freewrt@284 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package/base-files/default/etc/functions.sh

    r042eeb3 r76b8726  
    44
    55# valid interface?
    6 if_valid () (
     6if_valid() (
    77        ifconfig "$1" >&- 2>&- ||
    8         [ "${1%%[0-9]}" = "br" ] || {
    9                 [ "${1%%[0-9]}" = "vlan" ] && (
     8        [ "${1%%[0-9]}" = br ] || {
     9                [ "${1%%[0-9]}" = vlan ] && (
    1010                        i=${1#vlan}
    1111                        hwname=$(nvram get vlan${i}hwname)
     
    2626        if_proto=$(nvram get ${2}_proto)
    2727        if=$(nvram get ${2}_ifname)
    28         [ "${if%%[0-9]}" = "ppp" ] && if=$(nvram get ${2}_device)
     28        [ "${if%%[0-9]}" = ppp ] && if=$(nvram get ${2}_device)
    2929
    3030        pidfile=/var/run/${if}.pid
    31         [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
     31        [ -f $pidfile ] && $DEBUG kill $(<$pidfile)
    3232
    3333        case $1 in
     
    4242                ${gateway:+$DEBUG route add default gw $gateway}
    4343
    44                 [ -n "$static_route" ] && {
    45                         for route in $static_route; do {
     44                [ -n "$static_route" ] && for route in $static_route; do
    4645                        eval "set $(echo $route | sed 's/:/ /g')"
    47                                 if [ "$2" = "255.255.255.255" ]; then
    48                                         opt="-host"
    49                                 fi
    50                                 $DEBUG route add ${opt:-"-net"} $1 netmask $2 gw $3 metric $4
    51                         } done
    52                 }
     46                        [ "$2" = "255.255.255.255" ] && opt=-host
     47                        $DEBUG route add ${opt:-"-net"} $1 netmask $2 gw $3 metric $4
     48                done
    5349
    5450                [ -f /etc/resolv.conf ] || {
     
    5955                }
    6056
    61                 env -i ACTION="ifup" INTERFACE="${2}" PROTO=static /sbin/hotplug "iface" &
    62         ;;
     57                env -i ACTION=ifup INTERFACE="${2}" PROTO=static /sbin/hotplug iface &
     58                ;;
    6359        dhcp)
    6460                DHCP_IP=$(nvram get ${2}_ipaddr)
     
    7167                DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*}
    7268                [ -z $DHCP_HOSTNAME ] || DHCP_ARGS="$DHCP_ARGS -H $DHCP_HOSTNAME"
    73                 [ "$if_proto" = "pptp" ] && DHCP_ARGS="$DHCP_ARGS -n -q" || DHCP_ARGS="$DHCP_ARGS -R &"
    74                 [ -r $pidfile ] && oldpid=$(cat $pidfile 2>&-)
     69                [ "$if_proto" = pptp ] && DHCP_ARGS="$DHCP_ARGS -n -q" || DHCP_ARGS="$DHCP_ARGS -R &"
     70                [ -r $pidfile ] && oldpid=$(<$pidfile)
    7571                ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
    7672                [ -n "$oldpid" ] && pidof udhcpc | grep "$oldpid" >&- 2>&- && {
     
    7975                }
    8076                # hotplug events are handled by /usr/share/udhcpc/default.script
    81         ;;
     77                ;;
    8278        none|"")
    83         ;;
     79                ;;
    8480        *)
    8581                [ -x "/sbin/ifup.$1" ] && { $DEBUG /sbin/ifup.$1 ${2}; exit; }
    8682                echo "### ifup ${2}: ignored ${2}_proto=\"$1\" (not supported)"
    87         ;;
     83                ;;
    8884        esac
    8985}
     
    139135
    140136get_next_uid() {
    141         uid=$(cat $IPKG_INSTROOT/etc/passwd | grep -v ^nobody \
    142                 | grep -v ^admin | \
    143                 tail -n 1 | awk -F : '{ print $3 }')
    144         let uid=$uid+1
    145         echo $uid
     137        uid=$(grep -v -e ^nobody: -e ^admin: $IPKG_INSTROOT/etc/passwd | \
     138            tail -n 1 | awk -F : '{ print $3 }')
     139        echo $((uid+1))
    146140}
    147141
    148142get_next_gid() {
    149         gid=$(cat $IPKG_INSTROOT/etc/group | grep -v ^nogroup \
    150                 | grep -v ^admin | \
    151                 tail -n 1 | awk -F : '{ print $3 }')
    152         let gid=$gid+1
    153         echo $gid
     143        gid=$(grep -v -e ^nogroup: -e ^admin: $IPKG_INSTROOT/etc/group | \
     144            tail -n 1 | awk -F : '{ print $3 }')
     145        echo $((gid+1))
    154146}
Note: See TracChangeset for help on using the changeset viewer.