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

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 27 17:43:23 2019 +0100 (6 months ago)
parents 12b4e8340345
children 881167180f57
line source
1 # SliTaz package receipt.
3 PACKAGE="base-tiny"
4 VERSION="1.0"
5 CATEGORY="base-system"
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 if [ -z "$MODE" ]; then
25 [ -n "$PASSWORD" ] || PASSWORD=root
26 [ -n "$HOSTNAME" ] || HOSTNAME=slitaz
27 [ -n "$INTERFACE" ] || INTERFACE=eth0
28 [ -n "$IP" ] || IP=192.168.0.6
29 [ -n "$NETMASK" ] || NETMASK=255.255.255.0
30 [ -n "$GATEWAY" ] || GATEWAY=192.168.0.1
31 [ -n "$DNS_SERVER" ] || DNS_SERVER='192.168.0.1 192.168.0.2'
32 [ -n "$FSTAB" ] || FSTAB='/dev/hda1 /mnt ext3 defaults 0 2'
33 [ -n "$RC_LOCAL" ] || RC_LOCAL='[ -x /mnt/boot/init ] && /mnt/boot/init'
34 fi
35 cat <<EOT
36 <table>
37 <tr>
38 <td>Root password (empty=disable)</td>
39 <td><input type="text" name="PASSWORD" value="$PASSWORD" /></td>
40 </tr>
41 <tr>
42 <td>Host name</td>
43 <td><input type="text" name="HOSTNAME" value="$HOSTNAME" /></td>
44 </tr>
45 <tr>
46 <td>Interface</td>
47 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
48 </tr>
49 <tr>
50 <td>Network configuration</td>
51 <td><select name="MODE">
52 <option value="STATIC">STATIC</option>
53 <option value="DHCP"$([ "$MODE" = "DHCP" ] && echo ' selected="selected"')>DHCP</option>
54 <option value="DISABLE"$([ "$MODE" = "DISABLE" ] && echo ' selected="selected"')>DISABLE</option>
55 </select></td>
56 </tr>
57 <tr>
58 <td>Internet address</td>
59 <td><input type="text" name="IP" value="$IP" /></td>
60 </tr>
61 <tr>
62 <td>Netmask</td>
63 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
64 </tr>
65 <tr>
66 <td>Gateway</td>
67 <td><input type="text" name="GATEWAY" value="$GATEWAY" /></td>
68 </tr>
69 <tr>
70 <td>DNS server(s)</td>
71 <td><input type="text" name="DNS_SERVER" value="$DNS_SERVER" /></td>
72 </tr>
73 <tr>
74 <td>Filesystems</td>
75 <td><textarea name="FSTAB" cols="60" wrap="off">
76 $FSTAB
77 </textarea></td>
78 </tr>
79 <tr>
80 <td>Additional boot commands</td>
81 <td><textarea name="RC_LOCAL" cols="60" wrap="off">
82 $RC_LOCAL
83 </textarea></td>
84 </tr>
85 </table>
86 <input type="checkbox" name="KEEP_MODULES" ${KEEP_MODULES:+checked="checked" }/>
87 Do not remove the modules files after loading modules.
88 EOT
89 }
91 post_install()
92 {
93 DHCP="no"
94 STATIC="yes"
95 case "$MODE" in
96 "") return 1;;
97 DISABLE)
98 STATIC="no" ;;
99 DHCP) DHCP="yes"
100 STATIC="no"
101 esac
102 sed -i "s/^KEEP_MODULES=.*/KEEP_MODULES=\"$KEEP_MODULES\"/" \
103 $1/etc/rcS.conf
104 sed -i -e "s/^DNS_SERVER=.*/DNS_SERVER=\"$DNS_SERVER\"/" \
105 -e "s/^INTERFACE=.*/INTERFACE=\"$INTERFACE\"/" \
106 -e "s/^NETMASK=.*/NETMASK=\"$NETMASK\"/" \
107 -e "s/^GATEWAY=.*/GATEWAY=\"$GATEWAY\"/" \
108 -e "s/^STATIC=.*/STATIC=\"$STATIC\"/" \
109 -e "s/^DHCP=.*/DHCP=\"$DHCP\"/" \
110 -e "s/^IP=.*/IP=\"$IP\"/" $1/etc/network.conf
111 if [ -n "$PASSWORD" ]; then
112 case "$PASSWORD" in
113 \$1\$*)
114 sed -i "s|^root:[^:]*|root:$PASSWORD|" $1/etc/shadow ;;
115 *)
116 mkdir $1/fs
117 ( cd $1/fs ; cpio -idmu ) < dist/rootfs.cpio
118 cp $1/etc/passwd $1/fs/etc/
119 echo "root:$PASSWORD" | chroot $1/fs/ busybox chpasswd -m
120 cp $1/fs/etc/passwd $1/etc/
121 rm -rf $1/fs
122 esac
123 else
124 sed -i 's/^root:[^:]*:/root::/' $1/etc/passwd
125 mkdir $1/root 2> /dev/null
126 cat > $1/root/.profile <<EOT
127 grep -qs ^root:: /etc/passwd /etc/shadow && passwd
128 EOT
129 fi
130 [ -n "$HOSTNAME" ] && echo $HOSTNAME > $1/etc/hostname
131 [ -n "$FSTAB" ] && dos2unix >> $1/etc/fstab <<EOT
132 $FSTAB
133 EOT
134 [ -n "$RC_LOCAL" ] && dos2unix >> $1/etc/init.d/local.sh <<EOT
135 $RC_LOCAL
136 EOT
137 [ -s $1/modules ] && for i in $(cat $1/modules ; rm -f $1/modules); do
138 sed -i "s/LOAD_MODULES=./&$i /" $1/etc/rcS.conf
139 done
140 }