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

base: use host chpasswd
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 08 16:23:14 2012 +0100 (2012-03-08)
parents d3c5f3688ec0
children 998910ee725e
line source
1 # SliTaz package receipt.
3 PACKAGE="base-tiny"
4 VERSION="1.0"
5 CATEGORY="configuration"
6 SHORT_DESC="Tiny SliTaz base configuration files"
7 MAINTAINER="pascal.bellard@slitaz.org"
8 WEB_SITE="http://tiny.slitaz.org/"
9 AUTO_SELECTION="always"
10 CONFIG_FILES="/etc/network.conf /etc/passwd /etc/shadow \
11 /root/.profile /etc/fstab /etc/init.d/local.sh"
13 # Rules to configure and make the package.
14 compile_rules()
15 {
16 mkdir -p fs/var/lib fs/etc
17 echo "none" > fs/var/lib/detected-modules
18 echo "LANG=C" > fs/etc/locale.conf
19 while read pkg file ; do
20 if [ ! -s $pkg*/fs$file ]; then
21 tazpkg get $pkg
22 tazpkg extract $pkg*.tazpkg
23 fi
24 mkdir -p fs$(dirname $file)
25 mv $pkg*/fs$file fs$(dirname $file) || return 1
26 done << EOT
27 busybox /etc/udhcpd.conf
28 busybox /etc/inetd.conf
29 slitaz-base-files /etc/fstab
30 slitaz-base-files /etc/group
31 slitaz-base-files /etc/passwd
32 slitaz-base-files /etc/shadow
33 slitaz-boot-scripts /etc/inittab
34 slitaz-boot-scripts /etc/network.conf
35 slitaz-boot-scripts /etc/init.d/local.sh
36 slitaz-boot-scripts /etc/rcS.conf
37 EOT
38 sed -i 's/:x:/:!:/' fs/etc/passwd
39 sed -i 's/UDEV=.*/UDEV="no"/;s/hwconf.sh l/l/' fs/etc/rcS.conf
40 }
42 # Rules to gen a SliTaz package suitable for Tazpkg.
43 genpkg_rules()
44 {
45 cp -a fs/. $fs
46 }
48 config_form()
49 {
50 [ -n "$PASSWORD" ] || PASSWORD=root
51 [ -n "$INTERFACE" ] || INTERFACE=eth0
52 [ -n "$IP" ] || IP=192.168.0.6
53 [ -n "$NETMASK" ] || NETMASK=255.255.255.0
54 [ -n "$GATEWAY" ] || GATEWAY=192.168.0.1
55 [ -n "$DNS_SERVER" ] || DNS_SERVER='192.168.0.1 192.168.0.2'
56 [ -n "$FSTAB" ] || FSTAB='/dev/hda1 /mnt ext3 defaults 0 2'
57 [ -n "$RC_LOCAL" ] || RC_LOCAL='[ -x /mnt/boot/init ] && /mnt/boot/init'
58 cat <<EOT
59 <table>
60 <tr>
61 <td>Root password</td>
62 <td><input type="text" name="PASSWORD" value="$PASSWORD" /></td>
63 </tr>
64 <tr>
65 <td>Interface</td>
66 <td><input type="text" name="INTERFACE" value="$INTERFACE" /></td>
67 </tr>
68 <tr>
69 <td>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 <option value="DISABLE">DISABLE</option>
74 </select></td>
75 </tr>
76 <tr>
77 <td>Internet address</td>
78 <td><input type="text" name="IP" value="$IP" /></td>
79 </tr>
80 <tr>
81 <td>Netmask</td>
82 <td><input type="text" name="NETMASK" value="$NETMASK" /></td>
83 </tr>
84 <tr>
85 <td>Gateway</td>
86 <td><input type="text" name="GATEWAY" value="$GATEWAY" /></td>
87 </tr>
88 <tr>
89 <td>DNS server(s)</td>
90 <td><input type="text" name="DNS_SERVER" value="$DNS_SERVER" /></td>
91 </tr>
92 <tr>
93 <td>Filesystems</td>
94 <td><textarea name="FSTAB" cols="60" wrap="off">
95 $FSTAB
96 </textarea></td>
97 </tr>
98 <tr>
99 <td>Additional boot commands</td>
100 <td><textarea name="RC_LOCAL" cols="60" wrap="off">
101 $RC_LOCAL
102 </textarea></td>
103 </tr>
104 </table>
105 EOT
106 }
108 post_install()
109 {
110 DHCP="no"
111 STATIC="yes"
112 case "$MODE" in
113 "") return 1;;
114 DISABLE)
115 STATIC="no" ;;
116 DHCP) DHCP="yes"
117 STATIC="no"
118 esac
119 sed -i -e "s/^DNS_SERVER=.*/DNS_SERVER=\"$DNS_SERVER\"/" \
120 -e "s/^INTERFACE=.*/INTERFACE=\"$INTERFACE\"/" \
121 -e "s/^NETMASK=.*/NETMASK=\"$NETMASK\"/" \
122 -e "s/^GATEWAY=.*/GATEWAY=\"$GATEWAY\"/" \
123 -e "s/^STATIC=.*/STATIC=\"$STATIC\"/" \
124 -e "s/^DHCP=.*/DHCP=\"$DHCP\"/" \
125 -e "s/^IP=.*/IP=\"$IP\"/" $1/etc/network.conf
126 if [ -n "$PASSWORD" ]; then
127 mkdir $1/lib
128 cp -a /lib/lib[cm][.-]* /lib/ld* $1/lib
129 cp -a /bin/busybox $1/lib/chpasswd
130 echo "root:$PASSWORD" | chroot $1/ /lib/chpasswd -m
131 rm -rf $1/lib
132 else
133 sed -i 's/^root:[^:]*:/root::/' $1/etc/passwd
134 mkdir $1/root 2> /dev/null
135 cat > $1/root/.profile <<EOT
136 grep -qs ^root:: /etc/passwd /etc/shadow && passwd
137 EOT
138 fi
139 [ -n "$FSTAB" ] && dos2unix >> $1/etc/fstab <<EOT
140 $FSTAB
141 EOT
142 [ -n "$RC_LOCAL" ] && dos2unix >> $1/etc/init.d/local.sh <<EOT
143 $RC_LOCAL
144 EOT
145 }