wok-tiny rev 8
Add lan-config
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Feb 02 00:20:03 2011 +0100 (2011-02-02) |
parents | 73db4e196b5f |
children | 943c1a94316d |
files | lan-config/receipt |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/lan-config/receipt Wed Feb 02 00:20:03 2011 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="lan-config" 1.7 +VERSION="1.0" 1.8 +CATEGORY="tiny-slitaz" 1.9 +SHORT_DESC="Tiny SliTaz lan ip configuration (2nd ethernet card)" 1.10 +MAINTAINER="pascal.bellard@slitaz.org" 1.11 +WEB_SITE="http://mirror.slitaz.org/pizza/tiny/" 1.12 +CONFIG_FILES="/etc/network.conf" 1.13 + 1.14 +# Rules to configure and make the package. 1.15 +compile_rules() 1.16 +{ 1.17 + while read pkg file ; do 1.18 + if [ ! -s $pkg*/fs$file ]; then 1.19 + tazpkg get $pkg 1.20 + tazpkg extract $pkg*.tazpkg 1.21 + fi 1.22 + mkdir -p fs$(dirname $file) 1.23 + mv $pkg*/fs$file fs$(dirname $file) || return 1 1.24 + done << EOT 1.25 +slitaz-boot-scripts /etc/init.d/network.sh 1.26 +slitaz-boot-scripts /etc/network.conf 1.27 +EOT 1.28 + sed -i -e 's#^dhcp(.*#&\ 1.29 + if [ "$LAN_DHCP" = "yes" ] ; then\ 1.30 + echo "Starting udhcpc client on: $LAN_INTERFACE..."\ 1.31 + /sbin/udhcpc -b -T 1 -A 12 -i $LAN_INTERFACE -p /var/run/udhcpc.$LAN_INTERFACE.pid\ 1.32 + fi#' -e 's#^static_ip(.*#&\ 1.33 + if [ "$LAN_STATIC" = "yes" ] ; then\ 1.34 + echo "Configuring static IP on $LAN_INTERFACE: $LAN_IP..."\ 1.35 + /sbin/ifconfig $LAN_INTERFACE $LAN_IP netmask $LAN_NETMASK up\ 1.36 + fi#' fs/etc/init.d/network.sh 1.37 +} 1.38 + 1.39 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.40 +genpkg_rules() 1.41 +{ 1.42 + cp -a fs/. $fs 1.43 +} 1.44 + 1.45 +config_form() 1.46 +{ 1.47 + [ -n "$INTERFACE" ] || INTERFACE=eth1 1.48 + [ -n "$IP" ] || IP=192.168.0.6 1.49 + [ -n "$NETMASK" ] || NETMASK=255.255.255.0 1.50 + cat <<EOT 1.51 +<table> 1.52 +<tr> 1.53 +<td>LAN Interface</td> 1.54 +<td><input type="text" name="INTERFACE" value="$INTERFACE" /></td> 1.55 +</tr> 1.56 +<tr> 1.57 +<td>LAN Network configuration</td> 1.58 +<td><select name="MODE"> 1.59 + <option value="STATIC">STATIC</option> 1.60 + <option value="DHCP"$([ "$MODE" == "DHCP" ] && echo ' selected="selected"')>DHCP</option> 1.61 +</select></td> 1.62 +</tr> 1.63 +<tr> 1.64 +<td>LAN Internet address</td> 1.65 +<td><input type="text" name="IP" value="$IP" /></td> 1.66 +</tr> 1.67 +<tr> 1.68 +<td>LAN Netmask</td> 1.69 +<td><input type="text" name="NETMASK" value="$NETMASK" /></td> 1.70 +</tr> 1.71 +</table> 1.72 +EOT 1.73 +} 1.74 + 1.75 +post_install() 1.76 +{ 1.77 + DHCP="no" 1.78 + STATIC="yes" 1.79 + case "$MODE" in 1.80 + "") return 1;; 1.81 + DHCP) DHCP="yes" 1.82 + STATIC="no" 1.83 + esac 1.84 + sed -i -e "s/^LAN_INTERFACE=.*/LAN_INTERFACE=\"$INTERFACE\"/" \ 1.85 + -e "s/^LAN_NETMASK=.*/LAN_NETMASK=\"$NETMASK\"/" \ 1.86 + -e "s/^LAN_STATIC=.*/LAN_STATIC=\"$STATIC\"/" \ 1.87 + -e "s/^LAN_DHCP=.*/LAN_DHCP=\"$DHCP\"/" \ 1.88 + -e "s/^LAN_IP=.*/LAN_IP=\"$IP\"/" $1/etc/network.conf 1.89 +}