Changeset 673

Show
Ignore:
Timestamp:
09/23/06 22:30:38 (2 years ago)
Author:
wbx
Message:

* add a generic network init script which is using busybox ifup/ifdown
* move ifup/ifdown with nvram calls to webif package
* add specific dnsmasq.conf and startup script for dnsmasq for webif
* add version file

This unbreaks DNS/DHCP options in Webif. Even WPA/WPA2 seems possible
if you install broadcom-nas package. I have no WPA/WPA2 enabled box
or operating system to test..

tg@ will add some rc.conf checks so that either webif network
configuration is used or ifup/ifdown from busybox

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/package/base-files/default/etc/functions.sh

    r368 r673  
    1 alias debug=${DEBUG:-:} 
    2  
    3 # valid interface? 
    4 if_valid() ( 
    5         ifconfig "$1" >&- 2>&- || 
    6         [ "${1%%[0-9]}" = br ] || { 
    7                 [ "${1%%[0-9]}" = vlan ] && ( 
    8                         i=${1#vlan} 
    9                         hwname=$(nvram get vlan${i}hwname) 
    10                         hwaddr=$(nvram get ${hwname}macaddr) 
    11                         [ -z "$hwaddr" ] && return 1 
    12  
    13                         vif=$(ifconfig -a | awk \ 
    14                             '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1) 
    15                         debug "# vlan$i => $vif" 
    16  
    17                         $DEBUG ifconfig $vif up 
    18                         $DEBUG vconfig add $vif $i 2>&- 
    19                 ) 
    20         } || { debug "# missing interface '$1' ignored"; false; } 
    21 ) 
    22  
    23 do_ifup() { 
    24         if_proto=$(nvram get ${2}_proto) 
    25         if=$(nvram get ${2}_ifname) 
    26         [ "${if%%[0-9]}" = ppp ] && if=$(nvram get ${2}_device) 
    27  
    28         pidfile=/var/run/${if}.pid 
    29         [ -f $pidfile ] && $DEBUG kill $(<$pidfile) 
    30  
    31         case $1 in 
    32         static) 
    33                 ip=$(nvram get ${2}_ipaddr) 
    34                 netmask=$(nvram get ${2}_netmask) 
    35                 gateway=$(nvram get ${2}_gateway) 
    36                 mtu=$(nvram get ${2}_mtu) 
    37                 static_route=$(nvram get ${2}_static_route) 
    38  
    39                 $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} ${mtu:+mtu $(($mtu))} broadcast + up 
    40                 ${gateway:+$DEBUG route add default gw $gateway} 
    41  
    42                 [ -n "$static_route" ] && for route in $static_route; do 
    43                         eval "set $(echo $route | sed 's/:/ /g')" 
    44                         [ "$2" = "255.255.255.255" ] && opt=-host 
    45                         $DEBUG route add ${opt:-"-net"} $1 netmask $2 gw $3 metric $4 
    46                 done 
    47  
    48                 [ -f /etc/resolv.conf ] || { 
    49                         debug "# --- creating /etc/resolv.conf ---" 
    50                         for dns in $(nvram get ${2}_dns); do 
    51                                 echo "nameserver $dns" >>/etc/resolv.conf 
    52                         done 
    53                 } 
    54  
    55                 env -i ACTION=ifup INTERFACE="${2}" PROTO=static /sbin/hotplug iface & 
    56                 ;; 
    57         dhcp) 
    58                 DHCP_IP=$(nvram get ${2}_ipaddr) 
    59                 DHCP_NETMASK=$(nvram get ${2}_netmask) 
    60                 mtu=$(nvram get ${2}_mtu) 
    61                 $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} ${mtu:+mtu $(($mtu))} broadcast + up 
    62  
    63                 DHCP_ARGS="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile" 
    64                 DHCP_HOSTNAME=$(nvram get ${2}_hostname) 
    65                 DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*} 
    66                 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS="$DHCP_ARGS -H $DHCP_HOSTNAME" 
    67                 [ "$if_proto" = pptp ] && DHCP_ARGS="$DHCP_ARGS -n -q" || DHCP_ARGS="$DHCP_ARGS -R &" 
    68                 [ -r $pidfile ] && oldpid=$(<$pidfile) 
    69                 ${DEBUG:-eval} "udhcpc $DHCP_ARGS" 
    70                 [ -n "$oldpid" ] && pidof udhcpc | grep "$oldpid" >&- 2>&- && { 
    71                         sleep 1 
    72                         kill -9 $oldpid 
    73                 } 
    74                 # hotplug events are handled by /usr/share/udhcpc/default.script 
    75                 ;; 
    76         none|"") 
    77                 ;; 
    78         *) 
    79                 [ -x "/sbin/ifup.$1" ] && { $DEBUG /sbin/ifup.$1 ${2}; exit; } 
    80                 echo "### ifup ${2}: ignored ${2}_proto=\"$1\" (not supported)" 
    81                 ;; 
    82         esac 
    83 } 
    84  
    851load_modules() { 
    862        sed 's/^[^#]/insmod &/' $* | ash 2>&- || : 
  • trunk/freewrt/package/busybox/Makefile

    r609 r673  
    88 
    99PKG_NAME:=              busybox 
    10 PKG_RELEASE:=           3 
     10PKG_RELEASE:=           4 
    1111PKG_VERSION:=           1.1.3 
    1212PKG_MD5SUM:=            19a0b475169335f17e421cf644616fe7 
     
    3434                EXTRA_CFLAGS="$(TARGET_CFLAGS)" -C $(WRKBUILD) install 
    3535        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/init.d/ 
     36        $(INSTALL_BIN) ./files/network.init \ 
     37                $(IDIR_BUSYBOX)/etc/init.d/S40network 
    3638        $(INSTALL_BIN) ./files/crond.init \ 
    3739                $(IDIR_BUSYBOX)/etc/init.d/S$(PKG_INIT)crond 
     40        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/network 
     41        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/network/if-pre-up.d 
     42        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/network/if-pre-down.d 
     43        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/network/if-post-up.d 
     44        $(INSTALL_DIR) $(IDIR_BUSYBOX)/etc/network/if-post-down.d 
    3845        $(RSTRIP) $(IDIR_BUSYBOX) 
    3946        $(IPKG_BUILD) $(IDIR_BUSYBOX) $(PACKAGE_DIR) 
  • trunk/freewrt/package/busybox/ipkg/busybox.postinst

    r609 r673  
    11#!/bin/sh 
    22. $IPKG_INSTROOT/etc/functions.sh 
     3add_rcconf network network YES 
    34add_rcconf crond crond NO 
    45 
  • trunk/freewrt/package/webif/Config.in

    r360 r673  
    33        tristate 
    44        select FWRT_PACKAGE_HASERL 
     5        select FWRT_PACKAGE_BRIDGE_UTILS 
     6        select FWRT_PACKAGE_IPTABLES 
     7        select FWRT_PACKAGE_DNSMASQ 
    58        default n 
    69        help 
    7           A web interface for configuring FreeWRT 
     10          A web interface for configuring FreeWRT as wireless router. 
    811 
  • trunk/freewrt/package/webif/Makefile

    r644 r673  
    3030$(IPKG_WEBIF): 
    3131        cd files; pax -rw www usr $(IDIR_WEBIF)/ 
    32         install -d $(IDIR_WEBIF)/usr/bin 
    33         install -m0755 $(WRKBUILD)/webif-page $(IDIR_WEBIF)/usr/bin/webif-page 
    34         install -m0755 $(WRKBUILD)/bstrip $(IDIR_WEBIF)/usr/bin/bstrip 
     32        $(INSTALL_DIR) $(IDIR_WEBIF)/usr/bin 
     33        $(INSTALL_DIR) $(IDIR_WEBIF)/sbin 
     34        $(INSTALL_BIN) $(WRKBUILD)/webif-page $(IDIR_WEBIF)/usr/bin/webif-page 
     35        $(INSTALL_BIN) $(WRKBUILD)/bstrip $(IDIR_WEBIF)/usr/bin/bstrip 
     36        $(INSTALL_BIN) ./files/ifup $(IDIR_WEBIF)/sbin/ifup.nvram 
     37        $(INSTALL_BIN) ./files/ifdown $(IDIR_WEBIF)/sbin/ifdown.nvram 
    3538        ln -sf /www/index.html $(IDIR_WEBIF)/www/index.asp 
    36         install -d $(IDIR_WEBIF)/etc/init.d 
    37         install -m0755 ./files/httpd.init $(IDIR_WEBIF)/etc/init.d/S50httpd 
     39        $(INSTALL_DIR) $(IDIR_WEBIF)/etc/init.d 
     40        $(INSTALL_BIN) ./files/httpd.init $(IDIR_WEBIF)/etc/init.d/S50httpd-webif 
     41        $(INSTALL_BIN) ./files/network.init $(IDIR_WEBIF)/etc/init.d/S40net-webif 
     42        $(INSTALL_BIN) ./files/dnsmasq.init $(IDIR_WEBIF)/etc/init.d/S50dns-webif 
     43        $(INSTALL_DATA) ./files/dnsmasq.conf $(IDIR_WEBIF)/etc/dnsmasq.conf-webif 
     44        $(INSTALL_DATA) ./files/network-nvram.sh $(IDIR_WEBIF)/etc/ 
    3845        find $(IDIR_WEBIF) -name CVS -o -name .svn | xargs rm -rf 
    3946        $(IPKG_BUILD) $(IDIR_WEBIF) $(PACKAGE_DIR) 
  • trunk/freewrt/package/webif/files/ifdown

    r227 r673  
    11#!/bin/sh 
    22[ $# = 0 ] && { echo "  $0 <group>"; exit; } 
    3 . /etc/functions.sh 
     3. /etc/network-nvram.sh 
    44 
    55type=$1 
  • trunk/freewrt/package/webif/files/ifup

    r187 r673  
    11#!/bin/ash 
    22[ $# = 0 ] && { echo "  $0 <group>"; exit; } 
    3 . /etc/functions.sh 
     3. /etc/network-nvram.sh 
    44type=$1 
    55debug "### ifup $type ###" 
  • trunk/freewrt/package/webif/files/network.init

    r367 r673  
    55        ifup_interfaces=${ifup_interfaces:-"lan wan wifi"} 
    66        for iface in $ifup_interfaces; do 
    7                 ifup $iface 
     7                ifup.nvram $iface 
    88                [ "$iface" = wifi ] && wifi up 
    99        done 
  • trunk/freewrt/package/webif/files/usr/lib/webif/apply.sh

    r295 r673  
    2020        echo '@TR<<Reloading>> @TR<<networking settings>> ...' 
    2121        egrep '^w?wan_' config-network >&- 2>&- && { 
    22                 ifdown wan 
    23                 ifup wan 
     22                ifdown.nvram wan 
     23                ifup.nvram wan 
    2424                killall -HUP dnsmasq 
    2525        } 
    2626         
    2727        grep '^lan_' config-network >&- 2>&- && { 
    28                 ifdown lan 
    29                 ifup lan 
     28                ifdown.nvram lan 
     29                ifup.nvram lan 
    3030                killall dnsmasq 
    31                 /etc/init.d/S??dnsmasq 
     31                /etc/init.d/S??dnsmasq-webif 
    3232        } 
    3333} 
     
    3838        ( 
    3939                /sbin/wifi 
    40                 [ -f /etc/init.d/S41wpa ] && /etc/init.d/S41wpa 
     40                [ -f /etc/init.d/S49nas ] && /etc/init.d/S49nas 
    4141        ) >&- 2>&- <&- 
    4242} 
  • trunk/freewrt/package/webif/files/usr/lib/webif/webif.sh

    r463 r673  
    6565        _uptime="${_uptime%%,*}" 
    6666        _hostname=$(cat /proc/sys/kernel/hostname) 
    67         _version=$( grep "(" /etc/banner ) 
    68         _version="${_version%% ---*}" 
     67        _version=$(cat /etc/version) 
    6968        _head="${3:+<div class=\"settings-block-title\"><h2>$3$_saved_title</h2></div>}" 
    7069        _form="${5:+<form enctype=\"multipart/form-data\" action=\"$5\" method=\"post\"><input type=\"hidden\" name=\"submit\" value=\"1\" />}" 
  • trunk/freewrt/target/Config.in

    r627 r673  
    2020          Build firmware images with a writable jffs2 root filesystem. 
    2121 
     22config FWRT_TARGET_ROOTFS_SQUASHFS_SYMLINKS 
     23        bool "Firmware image with read-only root filesystem and symlinks" 
     24        select FWRT_PACKAGE_JFFS2ROOT 
     25        help 
     26          Build firmware images with a read-only and highly compressed  
     27          (squashfs with lzma compression) root filesystem. 
     28          Startup scripts will create symlinks to the writable jffs2 portion. 
     29          If you want to change anything, first remove the symlink then edit  
     30          the file. 
     31 
    2232config FWRT_TARGET_ROOTFS_SQUASHFS_OVERLAY 
    2333        bool "Firmware image with read-only root filesystem and overlay fs"