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

plop: update url
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Aug 20 08:30:01 2020 +0000 (2020-08-20)
parents 3de5e6325aab
children 1e55ea7da8de
line source
1 # SliTaz package receipt.
3 PACKAGE="lan-config"
4 VERSION="1.0"
5 CATEGORY="network"
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 DEPENDS="busybox-net"
11 WANTED="base-tiny"
12 CONFIG_FILES="/etc/network.conf"
14 # Rules to configure and make the package.
15 compile_rules()
16 {
17 mkdir -p $stuff/etc/init.d 2> /dev/null
18 cp $wanted_stuff/etc/init.d/network.sh $stuff/etc/init.d/
19 cp $wanted_stuff/etc/network.conf $stuff/etc/
20 sed -i -e 's#^dhcp(.*#&\
21 if [ "$LAN_DHCP" = "yes" ] ; then\
22 echo "Starting udhcpc client on: $LAN_INTERFACE..."\
23 udhcpc -b -T 1 -A 12 -i $LAN_INTERFACE -p /var/run/udhcpc.$LAN_INTERFACE.pid\
24 fi#' -e 's#^static_ip(.*#&\
25 if [ "$LAN_STATIC" = "yes" ] ; then\
26 echo "Configuring static IP on $LAN_INTERFACE: $LAN_IP..."\
27 ifconfig $LAN_INTERFACE $LAN_IP netmask $LAN_NETMASK up\
28 fi#' $stuff/etc/init.d/network.sh
29 cat >> $stuff/etc/network.conf <<EOT
31 # Set lan interface.
32 LAN_INTERFACE="eth1"
34 # Dynamic IP address.
35 # Enable/disable DHCP lan client at boot time.
36 LAN_DHCP="no"
38 # Static IP address.
39 # Enable/disable static lan IP at boot time.
40 LAN_STATIC="yes"
42 # Set lan IP address and netmask for a static IP.
43 LAN_IP="192.168.1.1"
44 LAN_NETMASK="255.255.255.0"
46 EOT
47 }
49 # Rules to gen a SliTaz package suitable for Tazpkg.
50 genpkg_rules()
51 {
52 cp -a $stuff/. $fs/
53 }
55 config_form()
56 {
57 if [ -z "$MODE" ]; then
58 INTERFACE=eth1
59 IP=192.168.0.6
60 NETMASK=255.255.255.0
61 fi
62 cat <<EOT
63 <table>
64 <tr>
65 <td>LAN Interface</td>
66 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
67 </tr>
68 <tr>
69 <td>LAN Network configuration</td>
70 <td><select name="MODE">
71 <option value="STATIC">STATIC</option>
72 <option value="DHCP"$([ "$MODE" = "DHCP" ] && echo ' selected="selected"')>DHCP</option>
73 </select></td>
74 </tr>
75 <tr>
76 <td>LAN Internet address</td>
77 <td><input type="text" name="IP" value="$IP" /></td>
78 </tr>
79 <tr>
80 <td>LAN Netmask</td>
81 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
82 </tr>
83 </table>
84 <input type="checkbox" name="ROUTING" ${ROUTING:+value="ON" checked="checked" }/>
85 Enable LAN routing<br>
86 EOT
87 }
89 post_install()
90 {
91 DHCP="no"
92 STATIC="yes"
93 case "$MODE" in
94 "") return 1;;
95 DHCP) DHCP="yes"
96 STATIC="no"
97 esac
98 sed -i -e "s/^LAN_INTERFACE=.*/LAN_INTERFACE=\"$INTERFACE\"/" \
99 -e "s/^LAN_NETMASK=.*/LAN_NETMASK=\"$NETMASK\"/" \
100 -e "s/^LAN_STATIC=.*/LAN_STATIC=\"$STATIC\"/" \
101 -e "s/^LAN_DHCP=.*/LAN_DHCP=\"$DHCP\"/" \
102 -e "s/^LAN_IP=.*/LAN_IP=\"$IP\"/" $1/etc/network.conf
103 [ "$ROUTING" = "ON" ] && cat >> $1/etc/init.d/local.sh <<EOT
104 # Enable IP routing between interfaces
105 echo 1 > /proc/sys/net/ipv4/ip_forward
107 EOT
108 }