wok-tiny view custom-console/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 34a749493ee3
children
line source
1 # SliTaz package receipt.
3 PACKAGE="custom-console"
4 VERSION="2.0"
5 CATEGORY="meta"
6 GROUP="system"
7 SHORT_DESC="Configure the consoles"
8 MAINTAINER="pascal.bellard@slitaz.org"
9 LICENSE="BSD"
10 WEB_SITE="http://tiny.slitaz.org/"
11 DEPENDS="base-tiny"
12 SUGGESTED="module-usbserial module-serial"
14 # Rules to gen a SliTaz package suitable for Tazpkg.
15 genpkg_rules()
16 {
17 mkdir -p $fs/etc/init.d
18 }
20 post_install()
21 {
22 respawn=respawn
23 [ "$ASKFIRST" ] && respawn=askfirst
24 [ "$KERNEL_TTY" = "none" ] ||
25 echo -n " console=tty0 console=$KERNEL_TTY,${SPEED_KERNEL_TTY}n8" \
26 >> $1/boot/cmdline
27 TTY_LIST=""
28 for i in $(seq 1 63); do
29 eval n=\$TTY$i
30 [ -n "$n" ] || continue
31 TTY_LIST="$TTY_LIST tty$i:38400"
32 done
33 for i in $(seq 0 3 | sed 's/^/TTYS/' ; seq 0 3 | sed 's/^/TTYUSB/'); do
34 eval n=\$$i
35 [ -n "$n" ] || continue
36 eval s=\$SPEED_$i
37 TTY_LIST="$TTY_LIST ${i/TTY/tty}:$s"
38 done
39 [ -s $1/etc/init.d/tty.sh ] || cat > $1/etc/init.d/tty.sh <<EOT
40 #!/bin/sh
42 . /etc/init.d/rc.functions
43 EOT
44 chmod +x $1/etc/init.d/tty.sh
45 cat >> $1/etc/init.d/tty.sh <<EOT
47 sed -i '/^tty/d' /etc/inittab
48 EOT
49 [ -n "$TTY_LIST" ] ||
50 echo 'echo -n "Disable login console"' >> $1/etc/init.d/tty.sh
51 [ -n "$TTY_LIST" ] && cat >> $1/etc/init.d/tty.sh <<EOT
52 echo -n "Enable login console from "
53 for i in$TTY_LIST; do
54 dev=\${i%:*}
55 major=4
56 minor=\$(echo \$dev | sed 's/[^0-9]*//')
57 case "\$dev" in
58 ttyUSB*) major=188 ;;
59 ttyS*) minor=\$((64+\$minor)) ;;
60 esac
61 [ -e /dev/\$dev ] || mknod /dev/\$dev c \$major \$minor
62 stty -F /dev/\$dev > /dev/null 2>&1 || continue
63 echo -n "\$dev "
64 echo "\$dev::$respawn:getty \${i#*:} /dev/\$dev" >> /etc/inittab
65 done
66 kill -1 1
67 status
68 EOT
69 grep tty.sh $1/etc/rcS.conf ||
70 sed -i 's/^RUN_SCRIPTS="/&tty.sh /' $1/etc/rcS.conf
71 }
73 config_form()
74 {
75 cat <<EOT
76 <hr />
77 Virtual consoles
78 <table>
79 EOT
80 for i in $(seq 1 63); do
81 [ $(($i & 7)) -eq 1 ] && echo "<tr>"
82 eval checked="\$TTY$i"
83 cat <<EOT
84 <td>
85 <input type="checkbox" name="TTY$i" ${checked:+checked=checked }/> tty$i
86 </td>
87 EOT
88 [ $(($i & 7)) -eq 0 ] && echo "</tr>"
89 done
90 cat <<EOT
91 <td></td>
92 </tr>
93 </table>
94 <hr />
95 Serial consoles
96 <table>
97 EOT
98 for i in $(seq 0 3 | sed 's/^/TTYS/' ; seq 0 3 | sed 's/^/TTYUSB/'); do
99 eval checked="\$$i"
100 cat <<EOT
101 <tr>
102 <td><input type="checkbox" name="$i" ${checked:+checked=checked }/> ${i/TTY/tty} </td>
103 EOT
104 eval speed="\$SPEED_$i"
105 for j in 115200 57600 38400 19200 9600 4800 2400 1200 600 300; do
106 [ $j -eq 4800 ] && cat <<EOT
107 </tr>
108 <tr>
109 <td></td>
110 EOT
111 checked=
112 case " ${speed:-9600} " in
113 *\ $j\ *) checked="checked=checked "
114 esac
115 cat <<EOT
116 <td><input type="checkbox" name="SPEED_$i[]" value="$j" $checked/> $j</td>
117 EOT
118 done
119 done
120 cat <<EOT
121 </table>
122 </tr>
123 <p>
124 <input type="checkbox" name="ASKFIRST" ${ASKFIRST:+checked=checked }/>
125 Confirm console launch (spare some memory)
126 </p>
127 <p>
128 Kernel serial console
129 <select name="KERNEL_TTY">
130 <option>none</option>
131 EOT
132 for i in $(seq 0 3); do
133 echo -n "<option"
134 [ "$KERNEL_TTY" = "ttyS$i" ] && echo -n ' selected="selected"'
135 echo ">ttyS$i</option>"
136 done
137 cat <<EOT
138 </select>
139 <select name="SPEED_KERNEL_TTY">
140 EOT
141 for i in 115200 57600 38400 19200 9600 4800 2400 1200 600 300; do
142 echo -n "<option"
143 [ "$SPEED_KERNEL_TTY" = "$i" ] && echo -n ' selected="selected"'
144 echo ">$i</option>"
145 done
146 echo -e "</select>\n</p>"
147 }