wok-tiny annotate lan-config/receipt @ 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 | |
children | 943c1a94316d |
rev | line source |
---|---|
pascal@8 | 1 # SliTaz package receipt. |
pascal@8 | 2 |
pascal@8 | 3 PACKAGE="lan-config" |
pascal@8 | 4 VERSION="1.0" |
pascal@8 | 5 CATEGORY="tiny-slitaz" |
pascal@8 | 6 SHORT_DESC="Tiny SliTaz lan ip configuration (2nd ethernet card)" |
pascal@8 | 7 MAINTAINER="pascal.bellard@slitaz.org" |
pascal@8 | 8 WEB_SITE="http://mirror.slitaz.org/pizza/tiny/" |
pascal@8 | 9 CONFIG_FILES="/etc/network.conf" |
pascal@8 | 10 |
pascal@8 | 11 # Rules to configure and make the package. |
pascal@8 | 12 compile_rules() |
pascal@8 | 13 { |
pascal@8 | 14 while read pkg file ; do |
pascal@8 | 15 if [ ! -s $pkg*/fs$file ]; then |
pascal@8 | 16 tazpkg get $pkg |
pascal@8 | 17 tazpkg extract $pkg*.tazpkg |
pascal@8 | 18 fi |
pascal@8 | 19 mkdir -p fs$(dirname $file) |
pascal@8 | 20 mv $pkg*/fs$file fs$(dirname $file) || return 1 |
pascal@8 | 21 done << EOT |
pascal@8 | 22 slitaz-boot-scripts /etc/init.d/network.sh |
pascal@8 | 23 slitaz-boot-scripts /etc/network.conf |
pascal@8 | 24 EOT |
pascal@8 | 25 sed -i -e 's#^dhcp(.*#&\ |
pascal@8 | 26 if [ "$LAN_DHCP" = "yes" ] ; then\ |
pascal@8 | 27 echo "Starting udhcpc client on: $LAN_INTERFACE..."\ |
pascal@8 | 28 /sbin/udhcpc -b -T 1 -A 12 -i $LAN_INTERFACE -p /var/run/udhcpc.$LAN_INTERFACE.pid\ |
pascal@8 | 29 fi#' -e 's#^static_ip(.*#&\ |
pascal@8 | 30 if [ "$LAN_STATIC" = "yes" ] ; then\ |
pascal@8 | 31 echo "Configuring static IP on $LAN_INTERFACE: $LAN_IP..."\ |
pascal@8 | 32 /sbin/ifconfig $LAN_INTERFACE $LAN_IP netmask $LAN_NETMASK up\ |
pascal@8 | 33 fi#' fs/etc/init.d/network.sh |
pascal@8 | 34 } |
pascal@8 | 35 |
pascal@8 | 36 # Rules to gen a SliTaz package suitable for Tazpkg. |
pascal@8 | 37 genpkg_rules() |
pascal@8 | 38 { |
pascal@8 | 39 cp -a fs/. $fs |
pascal@8 | 40 } |
pascal@8 | 41 |
pascal@8 | 42 config_form() |
pascal@8 | 43 { |
pascal@8 | 44 [ -n "$INTERFACE" ] || INTERFACE=eth1 |
pascal@8 | 45 [ -n "$IP" ] || IP=192.168.0.6 |
pascal@8 | 46 [ -n "$NETMASK" ] || NETMASK=255.255.255.0 |
pascal@8 | 47 cat <<EOT |
pascal@8 | 48 <table> |
pascal@8 | 49 <tr> |
pascal@8 | 50 <td>LAN Interface</td> |
pascal@8 | 51 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td> |
pascal@8 | 52 </tr> |
pascal@8 | 53 <tr> |
pascal@8 | 54 <td>LAN Network configuration</td> |
pascal@8 | 55 <td><select name="MODE"> |
pascal@8 | 56 <option value="STATIC">STATIC</option> |
pascal@8 | 57 <option value="DHCP"$([ "$MODE" == "DHCP" ] && echo ' selected="selected"')>DHCP</option> |
pascal@8 | 58 </select></td> |
pascal@8 | 59 </tr> |
pascal@8 | 60 <tr> |
pascal@8 | 61 <td>LAN Internet address</td> |
pascal@8 | 62 <td><input type="text" name="IP" value="$IP" /></td> |
pascal@8 | 63 </tr> |
pascal@8 | 64 <tr> |
pascal@8 | 65 <td>LAN Netmask</td> |
pascal@8 | 66 <td><input type="text" name="NETMASK" value="$NETMASK" /></td> |
pascal@8 | 67 </tr> |
pascal@8 | 68 </table> |
pascal@8 | 69 EOT |
pascal@8 | 70 } |
pascal@8 | 71 |
pascal@8 | 72 post_install() |
pascal@8 | 73 { |
pascal@8 | 74 DHCP="no" |
pascal@8 | 75 STATIC="yes" |
pascal@8 | 76 case "$MODE" in |
pascal@8 | 77 "") return 1;; |
pascal@8 | 78 DHCP) DHCP="yes" |
pascal@8 | 79 STATIC="no" |
pascal@8 | 80 esac |
pascal@8 | 81 sed -i -e "s/^LAN_INTERFACE=.*/LAN_INTERFACE=\"$INTERFACE\"/" \ |
pascal@8 | 82 -e "s/^LAN_NETMASK=.*/LAN_NETMASK=\"$NETMASK\"/" \ |
pascal@8 | 83 -e "s/^LAN_STATIC=.*/LAN_STATIC=\"$STATIC\"/" \ |
pascal@8 | 84 -e "s/^LAN_DHCP=.*/LAN_DHCP=\"$DHCP\"/" \ |
pascal@8 | 85 -e "s/^LAN_IP=.*/LAN_IP=\"$IP\"/" $1/etc/network.conf |
pascal@8 | 86 } |