wok-tiny view lan-config/receipt @ rev 94

Refresh, remove kernel*, add linux
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 02 21:45:05 2015 +0200 (2015-10-02)
parents a6d2ddc65590
children bb00d1e3b0f7
line source
1 # SliTaz package receipt.
3 PACKAGE="lan-config"
4 VERSION="1.0"
5 CATEGORY="meta"
6 SHORT_DESC="Tiny SliTaz lan ip configuration (2nd ethernet card)"
7 MAINTAINER="pascal.bellard@slitaz.org"
8 LICENSE="BSD"
9 WEB_SITE="http://tiny.slitaz.org/"
10 WANTED="base-tiny"
11 CONFIG_FILES="/etc/network.conf"
13 # Rules to configure and make the package.
14 compile_rules()
15 {
16 mkdir -p $stuff/etc/init.d 2> /dev/null
17 cp $wanted_stuff/etc/init.d/network.sh $stuff/etc/init.d/
18 cp $wanted_stuff/etc/network.conf $stuff/etc/
19 sed -i -e 's#^dhcp(.*#&\
20 if [ "$LAN_DHCP" = "yes" ] ; then\
21 echo "Starting udhcpc client on: $LAN_INTERFACE..."\
22 udhcpc -b -T 1 -A 12 -i $LAN_INTERFACE -p /var/run/udhcpc.$LAN_INTERFACE.pid\
23 fi#' -e 's#^static_ip(.*#&\
24 if [ "$LAN_STATIC" = "yes" ] ; then\
25 echo "Configuring static IP on $LAN_INTERFACE: $LAN_IP..."\
26 ifconfig $LAN_INTERFACE $LAN_IP netmask $LAN_NETMASK up\
27 fi#' $stuff/etc/init.d/network.sh
28 cat >> $stuff/etc/network.conf <<EOT
30 # Set lan interface.
31 LAN_INTERFACE="eth1"
33 # Dynamic IP address.
34 # Enable/disable DHCP lan client at boot time.
35 LAN_DHCP="no"
37 # Static IP address.
38 # Enable/disable static lan IP at boot time.
39 LAN_STATIC="yes"
41 # Set lan IP address and netmask for a static IP.
42 LAN_IP="192.168.1.1"
43 LAN_NETMASK="255.255.255.0"
45 EOT
46 }
48 # Rules to gen a SliTaz package suitable for Tazpkg.
49 genpkg_rules()
50 {
51 cp -a $stuff/. $fs
52 }
54 config_form()
55 {
56 [ -n "$INTERFACE" ] || INTERFACE=eth1
57 [ -n "$IP" ] || IP=192.168.0.6
58 [ -n "$NETMASK" ] || NETMASK=255.255.255.0
59 cat <<EOT
60 <table>
61 <tr>
62 <td>LAN Interface</td>
63 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
64 </tr>
65 <tr>
66 <td>LAN Network configuration</td>
67 <td><select name="MODE">
68 <option value="STATIC">STATIC</option>
69 <option value="DHCP"$([ "$MODE" == "DHCP" ] && echo ' selected="selected"')>DHCP</option>
70 </select></td>
71 </tr>
72 <tr>
73 <td>LAN Internet address</td>
74 <td><input type="text" name="IP" value="$IP" /></td>
75 </tr>
76 <tr>
77 <td>LAN Netmask</td>
78 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
79 </tr>
80 </table>
81 <input type="checkbox" name="ROUTING" value="ON" checked="checked" />
82 Enable LAN routing<br>
83 EOT
84 }
86 post_install()
87 {
88 DHCP="no"
89 STATIC="yes"
90 case "$MODE" in
91 "") return 1;;
92 DHCP) DHCP="yes"
93 STATIC="no"
94 esac
95 sed -i -e "s/^LAN_INTERFACE=.*/LAN_INTERFACE=\"$INTERFACE\"/" \
96 -e "s/^LAN_NETMASK=.*/LAN_NETMASK=\"$NETMASK\"/" \
97 -e "s/^LAN_STATIC=.*/LAN_STATIC=\"$STATIC\"/" \
98 -e "s/^LAN_DHCP=.*/LAN_DHCP=\"$DHCP\"/" \
99 -e "s/^LAN_IP=.*/LAN_IP=\"$IP\"/" $1/etc/network.conf
100 [ "$ROUTING" == "ON" ] && cat >> $1/etc/init.d/local.sh <<EOT
101 # Enable IP routing between interfaces
102 echo 1 > /proc/sys/net/ipv4/ip_forward
104 EOT
105 }