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

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