wok-tiny view base-tiny/receipt @ rev 97

Fix libs build, inet.conf updates ...
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 09 10:21:00 2015 +0200 (2015-10-09)
parents 2c3b4f47fbf5
children 0d8ef9102fc0
line source
1 # SliTaz package receipt.
3 PACKAGE="base-tiny"
4 VERSION="1.0"
5 CATEGORY="misc"
6 SHORT_DESC="Tiny SliTaz base configuration files"
7 MAINTAINER="pascal.bellard@slitaz.org"
8 LICENSE="BSD"
9 WEB_SITE="http://tiny.slitaz.org/"
10 AUTO_SELECTION="always"
11 CONFIG_FILES="/etc/network.conf /etc/rcS.conf /etc/passwd /etc/fstab \
12 /etc/inetd.conf /etc/daemons.conf /root/.profile /etc/init.d/local.sh"
14 # Rules to gen a SliTaz package suitable for Tazpkg.
15 genpkg_rules()
16 {
17 for i in $CONFIG_FILES ; do
18 [ -e $stuff$i ] && echo ${i#/}
19 done | ( cd $stuff ; cpio -o -H newc ) | ( cd $fs ; cpio -id )
20 }
22 config_form()
23 {
24 [ -n "$PASSWORD" ] || PASSWORD=root
25 [ -n "$HOSTNAME" ] || HOSTNAME=slitaz
26 [ -n "$INTERFACE" ] || INTERFACE=eth0
27 [ -n "$IP" ] || IP=192.168.0.6
28 [ -n "$NETMASK" ] || NETMASK=255.255.255.0
29 [ -n "$GATEWAY" ] || GATEWAY=192.168.0.1
30 [ -n "$DNS_SERVER" ] || DNS_SERVER='192.168.0.1 192.168.0.2'
31 [ -n "$FSTAB" ] || FSTAB='/dev/hda1 /mnt ext3 defaults 0 2'
32 [ -n "$RC_LOCAL" ] || RC_LOCAL='[ -x /mnt/boot/init ] && /mnt/boot/init'
33 cat <<EOT
34 <table>
35 <tr>
36 <td>Root password (empty=disable)</td>
37 <td><input type="text" name="PASSWORD" value="$PASSWORD" /></td>
38 </tr>
39 <tr>
40 <td>Host name</td>
41 <td><input type="text" name="HOSTNAME" value="$HOSTNAME" /></td>
42 </tr>
43 <tr>
44 <td>Interface</td>
45 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
46 </tr>
47 <tr>
48 <td>Network configuration</td>
49 <td><select name="MODE">
50 <option value="STATIC">STATIC</option>
51 <option value="DHCP"$([ "$MODE" == "DHCP" ] && echo ' selected="selected"')>DHCP</option>
52 <option value="DISABLE">DISABLE</option>
53 </select></td>
54 </tr>
55 <tr>
56 <td>Internet address</td>
57 <td><input type="text" name="IP" value="$IP" /></td>
58 </tr>
59 <tr>
60 <td>Netmask</td>
61 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
62 </tr>
63 <tr>
64 <td>Gateway</td>
65 <td><input type="text" name="GATEWAY" value="$GATEWAY" /></td>
66 </tr>
67 <tr>
68 <td>DNS server(s)</td>
69 <td><input type="text" name="DNS_SERVER" value="$DNS_SERVER" /></td>
70 </tr>
71 <tr>
72 <td>Filesystems</td>
73 <td><textarea name="FSTAB" cols="60" wrap="off">
74 $FSTAB
75 </textarea></td>
76 </tr>
77 <tr>
78 <td>Additional boot commands</td>
79 <td><textarea name="RC_LOCAL" cols="60" wrap="off">
80 $RC_LOCAL
81 </textarea></td>
82 </tr>
83 </table>
84 <input type="checkbox" name="KEEP_MODULES" />
85 Do not remove the modules files after loading modules.
86 EOT
87 }
89 post_install()
90 {
91 DHCP="no"
92 STATIC="yes"
93 case "$MODE" in
94 "") return 1;;
95 DISABLE)
96 STATIC="no" ;;
97 DHCP) DHCP="yes"
98 STATIC="no"
99 esac
100 sed -i "s/^KEEP_MODULES=.*/KEEP_MODULES=\"$KEEP_MODULES\"/" \
101 $1/etc/rcS.conf
102 sed -i -e "s/^DNS_SERVER=.*/DNS_SERVER=\"$DNS_SERVER\"/" \
103 -e "s/^INTERFACE=.*/INTERFACE=\"$INTERFACE\"/" \
104 -e "s/^NETMASK=.*/NETMASK=\"$NETMASK\"/" \
105 -e "s/^GATEWAY=.*/GATEWAY=\"$GATEWAY\"/" \
106 -e "s/^STATIC=.*/STATIC=\"$STATIC\"/" \
107 -e "s/^DHCP=.*/DHCP=\"$DHCP\"/" \
108 -e "s/^IP=.*/IP=\"$IP\"/" $1/etc/network.conf
109 if [ -n "$PASSWORD" ]; then
110 case "$PASSWORD" in
111 \$1\$*)
112 sed -i "s|^root:[^:]*|root:$PASSWORD|" $1/etc/shadow ;;
113 *)
114 mkdir $1/fs
115 ( cd $1/fs ; cpio -idmu ) < dist/rootfs.cpio
116 cp $1/etc/passwd $1/fs/etc/
117 echo "root:$PASSWORD" | chroot $1/fs/ busybox chpasswd -m
118 cp $1/fs/etc/passwd $1/etc/
119 rm -rf $1/fs
120 esac
121 else
122 sed -i 's/^root:[^:]*:/root::/' $1/etc/passwd
123 mkdir $1/root 2> /dev/null
124 cat > $1/root/.profile <<EOT
125 grep -qs ^root:: /etc/passwd /etc/shadow && passwd
126 EOT
127 fi
128 [ -n "$HOSTNAME" ] && echo $HOSTNAME > $1/etc/hostname
129 [ -n "$FSTAB" ] && dos2unix >> $1/etc/fstab <<EOT
130 $FSTAB
131 EOT
132 [ -n "$RC_LOCAL" ] && dos2unix >> $1/etc/init.d/local.sh <<EOT
133 $RC_LOCAL
134 EOT
135 [ -s $1/modules ] && for i in $(cat $1/modules ; rm -f $1/modules); do
136 sed -i "s/LOAD_MODULES=./&$i /" $1/etc/rcS.conf
137 done
138 }