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

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 27 17:43:23 2019 +0100 (2 months ago)
parents 10cf1a5f187d
children
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 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 if [ -z "$MODE" ]; then
57 INTERFACE=eth1
58 IP=192.168.0.6
59 NETMASK=255.255.255.0
60 fi
61 cat <<EOT
62 <table>
63 <tr>
64 <td>LAN Interface</td>
65 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
66 </tr>
67 <tr>
68 <td>LAN Network configuration</td>
69 <td><select name="MODE">
70 <option value="STATIC">STATIC</option>
71 <option value="DHCP"$([ "$MODE" = "DHCP" ] && echo ' selected="selected"')>DHCP</option>
72 </select></td>
73 </tr>
74 <tr>
75 <td>LAN Internet address</td>
76 <td><input type="text" name="IP" value="$IP" /></td>
77 </tr>
78 <tr>
79 <td>LAN Netmask</td>
80 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
81 </tr>
82 </table>
83 <input type="checkbox" name="ROUTING" ${ROUTING:+value="ON" checked="checked" }/>
84 Enable LAN routing<br>
85 EOT
86 }
88 post_install()
89 {
90 DHCP="no"
91 STATIC="yes"
92 case "$MODE" in
93 "") return 1;;
94 DHCP) DHCP="yes"
95 STATIC="no"
96 esac
97 sed -i -e "s/^LAN_INTERFACE=.*/LAN_INTERFACE=\"$INTERFACE\"/" \
98 -e "s/^LAN_NETMASK=.*/LAN_NETMASK=\"$NETMASK\"/" \
99 -e "s/^LAN_STATIC=.*/LAN_STATIC=\"$STATIC\"/" \
100 -e "s/^LAN_DHCP=.*/LAN_DHCP=\"$DHCP\"/" \
101 -e "s/^LAN_IP=.*/LAN_IP=\"$IP\"/" $1/etc/network.conf
102 [ "$ROUTING" = "ON" ] && cat >> $1/etc/init.d/local.sh <<EOT
103 # Enable IP routing between interfaces
104 echo 1 > /proc/sys/net/ipv4/ip_forward
106 EOT
107 }