rev |
line source |
jozee@457
|
1 #!/bin/sh
|
jozee@457
|
2 # usage: hwsetup [device]
|
jozee@457
|
3 # e.g., hwsetup printer
|
gokhlayeh@497
|
4 # #
|
al@939
|
5 # Copyright (C) 2009-2015 SliTaz GNU/Linux - GNU GPL v3
|
jozee@457
|
6 # Authors : Rohit Joshi <jozee@slitaz.org>
|
jozee@457
|
7 #
|
al@939
|
8
|
al@813
|
9 . /lib/libtaz.sh
|
al@813
|
10 . /etc/slitaz/slitaz.conf
|
al@813
|
11 export TEXTDOMAIN='slitaz-tools' #i18n
|
jozee@457
|
12
|
jozee@457
|
13 DEVICE=$1
|
jozee@460
|
14 DEPENDS=""
|
jozee@457
|
15 AUTO_INSTALL_SUGGESTED="no"
|
jozee@457
|
16 CONFIRM_SUGGESTED="no"
|
jozee@457
|
17 NON_FREE="no"
|
jozee@457
|
18 DETECTED="no"
|
al@813
|
19 USB_IDS=/usr/share/misc/usb.ids.gz
|
jozee@457
|
20
|
al@939
|
21
|
al@813
|
22 usage() {
|
al@813
|
23 newline
|
al@813
|
24 _ 'SliTaz Setup configuration'
|
al@813
|
25 newline
|
al@813
|
26 boldify $(_n 'Usage:')
|
al@813
|
27 echo " $(basename $0) [$(_n 'command')] [--$(_n 'option')]"
|
al@813
|
28 newline
|
al@813
|
29 boldify $(_n 'Commands:')
|
al@813
|
30 optlist "\
|
al@813
|
31 usage $(_n 'Print this short usage.')
|
al@813
|
32 printer $(_n 'Parallel and USB Printer setup.')
|
al@813
|
33 scanner $(_n 'USB Scanner setup.')
|
al@813
|
34 webcam $(_n 'Integrated and USB webcam setup.')
|
al@813
|
35 camera $(_n 'Digital Camera setup.')
|
al@813
|
36 bluetooth $(_n 'Bluetooth setup.')
|
al@813
|
37 3g-modem $(_n '3g-modem setup.')
|
al@813
|
38 firewall $(_n 'Start/stop firewall.')
|
al@813
|
39 nvidia $(_n 'Nvidia (non-free/free) setup.')
|
al@813
|
40 ati $(_n 'ATI (non-free/free) setup.')"
|
al@813
|
41 newline
|
al@813
|
42 boldify $(_n 'Options:')
|
al@813
|
43 optlist "\
|
al@813
|
44 --nonfree $(_n 'install non-free packages (nvidia, ati).')
|
al@813
|
45 --suggested $(_n 'auto-install optional dependencies.')
|
al@813
|
46 --confirm $(_n 'confirm before installing optional dependencies')"
|
al@813
|
47 newline
|
jozee@457
|
48 }
|
jozee@457
|
49
|
al@939
|
50
|
al@813
|
51 run_daemon_startup() {
|
jozee@457
|
52 # Add server to rcS.conf and avoid duplication.
|
jozee@457
|
53 . /etc/rcS.conf
|
jozee@457
|
54 if ! echo "$RUN_DAEMONS" | grep -q "$1"; then
|
jozee@457
|
55 sed -i "s/^RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"\1 $1\"/" /etc/rcS.conf
|
gokhlayeh@497
|
56 fi
|
jozee@457
|
57 }
|
jozee@457
|
58
|
al@939
|
59
|
al@813
|
60 device() {
|
al@813
|
61 SUGGESTED=""
|
jozee@457
|
62 case "$DEVICE" in
|
al@813
|
63 printer)
|
jozee@489
|
64 DEPENDS="$DEPENDS cups cups-pdf usbutils hal-info ghostscript aspell aspell-en"
|
jozee@457
|
65 SUGGESTED="hplip gutenprint foomatic-filters foomatic-db hal-cups-utils foomatic-db-nonfree ufr2 splix"
|
jozee@457
|
66 CONFIRM_SUGGESTED="yes"
|
al@813
|
67 GROUP="lp" ;;
|
gokhlayeh@497
|
68 scanner)
|
jozee@460
|
69 DEPENDS="$DEPENDS xsane usbutils hal-info"
|
jozee@457
|
70 SUGGESTED="hplip"
|
al@813
|
71 GROUP="scanner lp" ;;
|
al@813
|
72 webcam)
|
al@813
|
73 DEPENDS="$DEPENDS v4l-dvb usbutils hal-info"
|
jozee@457
|
74 SUGGESTED="xorg-xf86-video-v4l linux-video libv4l "
|
al@813
|
75 GROUP="video audio lp" ;;
|
gokhlayeh@497
|
76 camera)
|
al@813
|
77 DEPENDS="$DEPENDS gphoto2 usbutils hal-info"
|
al@813
|
78 GROUP="camera lp" ;;
|
jozee@457
|
79 bluetooth)
|
jozee@484
|
80 DEPENDS="$DEPENDS bluez usbutils hal-info pygobject dbus-python"
|
al@813
|
81 GROUP="lp" ;;
|
jozee@457
|
82 3g-modem)
|
al@813
|
83 DEPENDS="$DEPENDS linux-dialup wvdial pcmciautils usbutils hal-info"
|
al@813
|
84 GROUP="dialout lp" ;;
|
jozee@457
|
85 firewall)
|
al@813
|
86 DEPENDS="iptables slitaz-tools"
|
jozee@457
|
87 SUGGESTED="nmap"
|
al@813
|
88 GROUP="" ;;
|
jozee@457
|
89 nvidia)
|
al@813
|
90 DEPENDS="mesa mesa-demos linux-agp xorg-xf86-video-nv"
|
al@813
|
91 NON_FREE_DEPENDS="mesa mesa-demos linux-agp nvidia"
|
al@813
|
92 GROUP="video" ;;
|
jozee@457
|
93 ati)
|
al@813
|
94 DEPENDS="xorg-xf86-video-ati mesa-dri-ati mesa-demos"
|
al@813
|
95 NON_FREE_DEPENDS="mesa mesa-demos mesa-dri linux-agp catalyst"
|
al@813
|
96 GROUP="video" ;;
|
jozee@457
|
97 esac
|
jozee@457
|
98 }
|
jozee@457
|
99
|
al@939
|
100
|
al@813
|
101 untested() {
|
al@813
|
102 newline; separator
|
al@813
|
103 longline $(_ "Due to a lack of compatible hardware for troubleshooting, \
|
al@943
|
104 this %s device has not been properly tested. Please report any success, \
|
al@943
|
105 failure, bug to SliTaz Bug tracker or Forum." "$DEVICE")
|
al@813
|
106 separator; newline
|
jozee@457
|
107 sleep 1
|
jozee@457
|
108 }
|
jozee@457
|
109
|
al@939
|
110
|
al@813
|
111 failed() {
|
al@813
|
112 newline; separator
|
al@943
|
113 _ 'Failed to setup %s' "$DEVICE"
|
al@813
|
114 separator; newline
|
jozee@457
|
115 sleep 1
|
jozee@457
|
116 }
|
al@813
|
117
|
al@939
|
118
|
jozee@457
|
119 # Install DEPENDS and/or SUGGESTED
|
al@939
|
120
|
al@813
|
121 install() {
|
jozee@457
|
122 for pkg in $1 ; do
|
al@813
|
123 # Avoid reinstall
|
al@813
|
124 if [ ! -d "$INSTALLED/$pkg" ]; then
|
al@943
|
125 _ 'Installing pkg: %s' "$pkg"
|
al@813
|
126 tazpkg get-install "$pkg"
|
gokhlayeh@497
|
127 if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then
|
al@813
|
128 UDEV_RULES="yes"
|
jozee@457
|
129 fi
|
jozee@457
|
130 fi
|
jozee@457
|
131 done
|
al@813
|
132 }
|
gokhlayeh@497
|
133
|
al@939
|
134
|
jozee@457
|
135 # Install DEPENDS and/or SUGGESTED
|
al@939
|
136
|
al@813
|
137 confirm_install() {
|
jozee@457
|
138 for pkg in $1 ; do
|
al@813
|
139 # Avoid reinstall
|
al@813
|
140 if [ ! -d "$INSTALLED/$pkg" ]; then
|
al@943
|
141 _n 'Would you like to install pkg: %s' "$pkg"; confirm
|
pascal@1029
|
142 if [ $? = 0 ]; then
|
jozee@457
|
143 tazpkg get-install "$pkg" --forced
|
gokhlayeh@497
|
144 if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then
|
al@813
|
145 UDEV_RULES="yes"
|
jozee@457
|
146 fi
|
gokhlayeh@497
|
147 fi
|
jozee@457
|
148 fi
|
gokhlayeh@497
|
149 done
|
jozee@457
|
150 }
|
jozee@457
|
151
|
al@939
|
152
|
al@813
|
153 add_all_user_to_group() {
|
al@813
|
154 USERS=$(grep /home /etc/passwd | cut -d: -f1)
|
jozee@457
|
155 #echo "checking $USERS in $GROUP"
|
jozee@457
|
156 for grp in $GROUP ; do
|
jozee@457
|
157 for user in $USERS ; do
|
jozee@457
|
158 if ! grep -q "$grp.*$user.*" /etc/group ; then
|
al@943
|
159 _ 'adding %s to %s' "$user" "$grp"
|
jozee@457
|
160 addgroup "$user" "$grp"
|
gokhlayeh@497
|
161 fi
|
jozee@457
|
162 done
|
jozee@457
|
163 done
|
jozee@457
|
164 }
|
jozee@457
|
165
|
al@939
|
166
|
al@813
|
167 find_usb_device() {
|
jozee@457
|
168 case "$DEVICE" in
|
al@813
|
169 printer|scanner|camera) PATTERN="Cls=00" ;;
|
al@813
|
170 bluetooth) PATTERN="Cls=e0" ;;
|
al@813
|
171 esac
|
gokhlayeh@497
|
172
|
gokhlayeh@497
|
173 if [ -f /proc/bus/usb/devices ]; then
|
al@813
|
174 # no vendor entry in dmesg ??
|
al@813
|
175 #dmesglogs=`dmesg | tail -20`
|
al@813
|
176 DETECTED="no"
|
al@813
|
177 count=1
|
gokhlayeh@497
|
178
|
al@813
|
179 # assume device to be in last 3 entries; use tac
|
pascal@1031
|
180 DEVICES_LIST=$(grep ^[TDP] /proc/bus/usb/devices | \
|
al@813
|
181 grep -B1 -A1 "$PATTERN" | grep -i vendor | awk ' { print $2,$3 } ' | \
|
al@813
|
182 sed 's/ / /'|sed 's/Vendor=//' | sed 's/ProdID=//' | tail -3)
|
al@813
|
183 _ 'Detected USB Device : Vendor : Product'
|
al@813
|
184 separator
|
al@813
|
185 echo "$DEVICES_LIST" | while read line
|
al@813
|
186 do
|
al@813
|
187 vendorid=$(echo "$line" | awk '{ print $1 }')
|
al@813
|
188 [ -n "$vendorid" ] || continue
|
al@813
|
189 productid=$(echo "$line" | awk '{ print $2 }')
|
al@813
|
190 vendor=$(zcat $USB_IDS | grep $vendorid | head -1)
|
al@813
|
191 product=$(zcat $USB_IDS | grep $productid | head -2 | \
|
al@813
|
192 awk ' { print $1,$2,$3,$4} ' | sed -e :a -e '$!N;s/\n/ ; /;ta')
|
al@943
|
193 _ ' %s) Vendor : %s ' "$count" "$vendor"
|
al@943
|
194 _ ' Product : %s' "$product"
|
al@813
|
195 separator
|
al@813
|
196 count=$(expr $count + 1)
|
al@813
|
197 done
|
al@813
|
198 # confirm (use dmesg or some other way to automate this)
|
al@813
|
199 confirm_device
|
jozee@457
|
200 fi
|
jozee@457
|
201 }
|
jozee@457
|
202
|
al@939
|
203
|
al@813
|
204 confirm_device() {
|
al@943
|
205 _n 'Which no. is your %s shown in the above lines (1,2,3,none)? ' "$DEVICE"
|
al@943
|
206 read choice
|
jozee@457
|
207 case "$choice" in
|
al@813
|
208 1|2|3)
|
al@813
|
209 dev=$(echo "$DEVICES_LIST" | head -$choice | tail -1)
|
al@813
|
210 vendorid=$(echo "$dev" | awk '{ print $1 }')
|
al@813
|
211 productid=$(echo "$dev" | awk '{ print $2 }')
|
al@813
|
212 bus=$(grep -B2 ".*$vendorid.*$productid" /proc/bus/usb/devices | grep Bus)
|
al@813
|
213 busno=$(echo $bus | awk '{ print $2 }' | cut -d"=" -f2)
|
al@813
|
214 deviceno=$(echo $bus | awk '{ print $8 }')
|
al@813
|
215 HP=$(echo $vendor | grep -q -i "Hewlett")
|
gokhlayeh@497
|
216 DETECTED="yes"
|
jozee@457
|
217 ;;
|
al@813
|
218 *)
|
al@813
|
219 DETECTED="no" ;;
|
jozee@457
|
220 esac
|
jozee@457
|
221 }
|
jozee@457
|
222
|
al@939
|
223
|
al@813
|
224 hputil() {
|
pascal@1029
|
225 if [ "$HP" = "1" ]; then
|
al@813
|
226 install "hplip"
|
al@813
|
227 newline
|
al@813
|
228 _n 'Do you want to use hp-setup utility'; confirm
|
pascal@1029
|
229 if [ $? = 0 ]; then
|
al@813
|
230 hp-setup
|
jozee@457
|
231 fi
|
gokhlayeh@497
|
232 fi
|
jozee@457
|
233 }
|
jozee@457
|
234
|
al@939
|
235
|
jozee@457
|
236 # udev now should do this correctly
|
al@939
|
237
|
al@813
|
238 fix_usb_permissions() {
|
jozee@457
|
239 grp=$1
|
pascal@1029
|
240 if [ "$DETECTED" = "yes" ]; then
|
jozee@457
|
241 if ls /dev/bus/usb/*$busno/*$deviceno ; then
|
jozee@457
|
242 chmod 666 /dev/bus/usb/*$busno/*$deviceno
|
jozee@457
|
243 chgrp $grp /dev/bus/usb/*$busno/*$deviceno
|
al@813
|
244 newline; separator
|
al@943
|
245 boldify "$(_ 'Verify %s Permissions' "$DEVICE")"
|
al@943
|
246 _ 'Your %s must be in %s group with rw-rw-rw- permissions' "$DEVICE" "$grp"
|
gokhlayeh@497
|
247 ls -l /dev/bus/usb/*$busno/*$deviceno
|
al@813
|
248 separator; newline
|
jozee@457
|
249 fi
|
gokhlayeh@497
|
250 fi
|
jozee@457
|
251 }
|
jozee@457
|
252
|
al@939
|
253
|
al@813
|
254 fix_parallel_permissions() {
|
al@813
|
255 if [ -f /usr/lib/cups/backend/parallel ] ; then
|
al@813
|
256 chmod 0755 /usr/lib/cups/backend/parallel
|
al@813
|
257 fi
|
jozee@457
|
258 }
|
jozee@457
|
259
|
al@939
|
260
|
al@813
|
261 load_modules() {
|
jozee@457
|
262 tazhw detect-pci
|
gokhlayeh@497
|
263 tazhw detect-usb
|
jozee@457
|
264 sleep 1
|
jozee@457
|
265 }
|
jozee@457
|
266
|
al@939
|
267
|
al@813
|
268 udev() {
|
pascal@1029
|
269 if [ "$UDEV_RULES" = "yes" ]; then
|
al@813
|
270 _ 'New udev rules are added by a package'
|
jozee@457
|
271 udevadm trigger
|
jozee@457
|
272 sleep 2
|
jozee@457
|
273 fi
|
jozee@457
|
274 }
|
jozee@457
|
275
|
al@939
|
276
|
al@813
|
277 xorg() {
|
gokhlayeh@497
|
278 [ -x /usr/bin/Xorg ] || install "xorg"
|
al@813
|
279 _ 'Auto configuring Xorg...'
|
al@939
|
280
|
jozee@457
|
281 # Xorg auto configuration.
|
gokhlayeh@497
|
282 if [ ! -d /etc/X11/xorg.conf.d -a -x /usr/bin/Xorg ]; then
|
al@813
|
283 _ 'Configuring Xorg...'
|
gokhlayeh@497
|
284 # Populate /etc/X11/xorg.conf.d if it doesn't exist.
|
jozee@457
|
285 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
|
al@813
|
286 sed -i 's|^xserver_arguments|\#xserver_arguments|' /etc/slim.conf
|
jozee@457
|
287 tazx config-xorg
|
jozee@457
|
288 fi
|
jozee@457
|
289 }
|
jozee@457
|
290
|
al@939
|
291
|
al@813
|
292 get_wvdial_vars() {
|
al@813
|
293 PHONE=$( grep ^Phone $CONF | cut -d= -f2 | tr -d '[" ]')
|
al@813
|
294 USERNAME=$(grep ^Username $CONF | cut -d= -f2 | tr -d '[" ]')
|
al@813
|
295 PASSWORD=$(grep ^Password $CONF | cut -d= -f2 | tr -d '[" ]')
|
al@813
|
296 PIN=$( grep AT+CPIN= $CONF | cut -d= -f3 | tr -d '[" ]')
|
al@813
|
297 MODEM=$( grep ^Modem.*/dev.* $CONF | cut -d= -f2 | tr -d '[" ]' | uniq)
|
al@813
|
298 APN=$( grep AT+CGDCONT $CONF | cut -d, -f3 | tr -d '[" ]')
|
pascal@1029
|
299 [ "x$USERNAME" = "x''" ] && USERNAME=
|
pascal@1029
|
300 [ "x$PASSWORD" = "x''" ] && PASSWORD=
|
al@813
|
301 }
|
al@813
|
302
|
al@939
|
303
|
al@813
|
304 set_wvdial_vars() {
|
al@813
|
305 # wvdial needs something right the equal sign
|
pascal@1029
|
306 [ x$USERNAME = x ] && USERNAME="''"
|
pascal@1029
|
307 [ x$PASSWORD = x ] && PASSWORD="''"
|
al@813
|
308 sed 's|^Phone.*|Phone = '$PHONE'|; s|^Username.*|Username = '$USERNAME'|; \
|
al@813
|
309 s|^Password.*|Password = '$PASSWORD'|; s|.*AT+CPIN=.*|Init4 = AT+CPIN='$PIN'|; \
|
al@813
|
310 s|.*AT+CGDCONT=.*|Init3 = AT+CGDCONT=1,"IP", "'$APN'"|; \
|
al@813
|
311 s|^Modem.*/dev.*|Modem = '$MODEM'|' -i $CONF
|
al@813
|
312 }
|
al@813
|
313
|
al@939
|
314
|
al@813
|
315 wvdialbox_main() {
|
al@813
|
316 icon=network-transmit-receive
|
al@813
|
317 yad --title="$(_n 'Wvdial Box')" --window-icon=$icon --center \
|
al@813
|
318 --image=$icon \
|
al@813
|
319 --form \
|
al@813
|
320 --field="$(_n 'Phone Number:')" "$PHONE" \
|
al@813
|
321 --field="$(_n 'Username:')" "$USERNAME" \
|
al@813
|
322 --field="$(_n 'Password:'):H" "$PASSWORD" \
|
al@813
|
323 --field="$(_n 'Pin (if required):'):H" "$PIN" \
|
al@813
|
324 --field="$(_n 'Modem:')" "$MODEM" \
|
al@813
|
325 --field="$(_n 'Access Point Name (APN):')" "$APN" \
|
al@813
|
326 --field="<b>$(_n 'You must save your account info before dialing')</b>:LBL" "" \
|
al@813
|
327 --field="$(_n 'Edit config file'):BTN" "leafpad $CONF" \
|
al@813
|
328 --button="$(_n 'Save Configuration'):2" \
|
al@813
|
329 --button="$(_n 'Dial Pin Once'):1" \
|
al@813
|
330 --button="gtk-connect:3"
|
al@813
|
331 # --always-print-result
|
al@813
|
332 }
|
al@813
|
333
|
al@939
|
334
|
al@813
|
335 wvdialbox() {
|
gokhlayeh@497
|
336 # setup your modem
|
gokhlayeh@497
|
337 #wvdialconf
|
jozee@457
|
338 #set username, password, pin
|
jozee@457
|
339 #echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin"
|
al@813
|
340 CONF=/etc/wvdial.conf
|
al@813
|
341 if [ ! -f $CONF ]; then
|
al@813
|
342 APN="apn.yournet.net"
|
al@813
|
343 PHONE="*99#"
|
al@813
|
344 USERNAME="user"
|
al@813
|
345 PASSWORD="passwd"
|
al@813
|
346 PIN="9999"
|
jozee@457
|
347 [ -n "$MODEM" ] || MODEM="/dev/ttyUSB0"
|
al@943
|
348 cat > $CONF <<EOT
|
al@813
|
349 [Dialer slitaz]
|
al@813
|
350 Phone = $PHONE
|
al@813
|
351 Username = $USERNAME
|
al@813
|
352 Password = $PASSWORD
|
al@813
|
353 Stupid Mode = 1
|
al@813
|
354 Dial Command = ATDT
|
al@813
|
355 Modem = $MODEM
|
al@813
|
356 Baud = 460800
|
al@813
|
357 Init1 = ATZ
|
al@813
|
358 Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
|
al@813
|
359 Init3 = AT+CGDCONT=1,"IP", "$APN"
|
al@813
|
360 ISDN = 0
|
al@813
|
361 Modem Type = Analog Modem
|
al@813
|
362
|
al@813
|
363 [Dialer pin]
|
al@813
|
364 Modem = $MODEM
|
al@813
|
365 Init4 = AT+CPIN=$PIN
|
al@813
|
366 EOT
|
jozee@457
|
367 fi
|
jozee@457
|
368 #<action>sed -i "s/^\[Dialer.*/[Dialer slitaz]/" /etc/wvdial.conf</action>
|
jozee@457
|
369 #DIALER=`grep Dialer /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
|
jozee@457
|
370 #DIALER=`grep -B1 AT+CPIN /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
|
gokhlayeh@497
|
371
|
al@813
|
372 get_wvdial_vars
|
gokhlayeh@497
|
373
|
al@813
|
374 CONF_VARS=$(wvdialbox_main); BUTTON="$?"
|
al@813
|
375 PHONE=$( echo $CONF_VARS | cut -d"|" -f1)
|
al@813
|
376 USERNAME=$(echo $CONF_VARS | cut -d"|" -f2)
|
al@813
|
377 PASSWORD=$(echo $CONF_VARS | cut -d"|" -f3)
|
al@813
|
378 PIN=$( echo $CONF_VARS | cut -d"|" -f4)
|
al@813
|
379 MODEM=$( echo $CONF_VARS | cut -d"|" -f5)
|
al@813
|
380 APN=$( echo $CONF_VARS | cut -d"|" -f6)
|
gokhlayeh@497
|
381
|
al@813
|
382 case "$BUTTON" in
|
al@813
|
383 2) set_wvdial_vars; wvdialbox ;;
|
al@813
|
384 1) terminal -geometry 80x16 -title "Wvdial" -e "$0 dial pin" ;;
|
al@813
|
385 3) terminal -geometry 80x16 -title "Wvdial" -e "$0 dial slitaz" ;;
|
al@813
|
386 esac
|
jozee@457
|
387 }
|
jozee@457
|
388
|
jozee@457
|
389
|
al@813
|
390 setup() {
|
al@813
|
391 case "$DEVICE" in
|
gokhlayeh@497
|
392 printer)
|
jozee@457
|
393 load_modules
|
jozee@457
|
394 udev
|
al@939
|
395
|
jozee@457
|
396 # check parallel or usb printer
|
jozee@457
|
397 if [ -f /proc/sys/dev/parport/parport*/autoprobe* ] ; then
|
jozee@457
|
398 fix_parallel_permissions
|
jozee@457
|
399 DETECTED="yes"
|
jozee@457
|
400 else
|
jozee@457
|
401 find_usb_device
|
al@813
|
402 fix_usb_permissions "lp"
|
jozee@457
|
403 fi
|
al@939
|
404
|
jozee@457
|
405 #lpinfo -v
|
pascal@1029
|
406 if [ "$DETECTED" = "yes" ]; then
|
al@813
|
407 newline
|
al@813
|
408 _n 'Do you want to start cups'; confirm
|
pascal@1029
|
409 if [ $? = 0 ]; then
|
al@813
|
410 newline
|
al@813
|
411 /etc/init.d/cupsd start
|
al@813
|
412 sleep 2
|
al@813
|
413 browser http://localhost:631/
|
gokhlayeh@497
|
414 else
|
al@813
|
415 newline; separator
|
al@813
|
416 emsg "$(_ 'Starting <b>cups</b> using:')"
|
al@813
|
417 echo "/etc/init.d/cupsd start"
|
al@813
|
418 echo "browser http://localhost:631/"
|
al@813
|
419 separator; newline
|
jozee@457
|
420 fi
|
jozee@457
|
421 else
|
jozee@457
|
422 failed
|
al@813
|
423 fi
|
jozee@457
|
424 ;;
|
al@813
|
425
|
gokhlayeh@497
|
426 scanner)
|
jozee@457
|
427 load_modules
|
jozee@457
|
428 udev
|
jozee@457
|
429 find_usb_device
|
gokhlayeh@497
|
430 fix_usb_permissions "scanner"
|
gokhlayeh@497
|
431
|
pascal@1029
|
432 if [ "$DETECTED" = "yes" ]; then
|
al@813
|
433 #hputil
|
al@813
|
434 newline
|
al@813
|
435 _n 'Do you want to start scanner'; confirm
|
pascal@1029
|
436 if [ $? = 0 ]; then
|
al@813
|
437 newline
|
al@813
|
438 sane-find-scanner # to verify scanner has been found
|
al@813
|
439 scanimage -L # List scanners
|
al@813
|
440 xsane #scanner application
|
gokhlayeh@497
|
441 else
|
al@813
|
442 newline; separator
|
al@813
|
443 emsg "$(_ 'Following <b>scanner commands</b> may be of help:')"
|
al@813
|
444 echo ' sane-find-scanner # ' $(_n 'to verify scanner has been found')
|
al@813
|
445 echo ' xsane # ' $(_n 'scanner application')
|
al@813
|
446 separator
|
jozee@457
|
447 fi
|
jozee@457
|
448 else
|
jozee@457
|
449 failed
|
jozee@457
|
450 fi
|
jozee@457
|
451 ;;
|
al@813
|
452
|
al@813
|
453 webcam)
|
al@813
|
454 load_modules
|
al@813
|
455 udev
|
al@813
|
456
|
al@813
|
457 if [ -n "$(ls /dev/video0)" ] ; then
|
al@813
|
458 # fix permissions
|
al@813
|
459 chmod 666 /dev/video0
|
al@813
|
460 # ls -l /dev/video0
|
al@813
|
461
|
al@813
|
462 if [ -d $INSTALLED/mplayer-svn ]; then
|
al@813
|
463 newline
|
al@813
|
464 _n 'Would you like to test webcam'; confirm
|
pascal@1029
|
465 if [ $? = 0 ]; then
|
al@813
|
466 newline
|
al@813
|
467 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
|
al@813
|
468 fi
|
al@813
|
469 else
|
al@813
|
470 newline
|
al@813
|
471 _n 'Would you like to test webcam by installing mplayer-svn'; confirm
|
pascal@1029
|
472 if [ $? = 0 ]; then
|
al@813
|
473 newline
|
al@813
|
474 install mplayer-svn
|
al@813
|
475 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
|
al@813
|
476 else
|
al@813
|
477 newline; separator
|
al@813
|
478 _ "Webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view"
|
al@813
|
479 separator
|
al@813
|
480 fi
|
al@813
|
481 fi
|
al@813
|
482 else
|
al@813
|
483 failed
|
al@813
|
484 fi
|
al@813
|
485 ;;
|
al@813
|
486
|
gokhlayeh@497
|
487 camera)
|
jozee@457
|
488 udev
|
jozee@457
|
489 find_usb_device
|
gokhlayeh@497
|
490 fix_usb_permissions "camera"
|
gokhlayeh@497
|
491
|
pascal@1029
|
492 if [ "$DETECTED" = "yes" ]; then
|
al@813
|
493 newline
|
al@813
|
494 _n 'Do you want to check if gphoto2 can talk to your camera'; confirm
|
pascal@1029
|
495 if [ $? = 0 ]; then
|
al@813
|
496 newline
|
jozee@457
|
497 # Show if the camera is detected
|
jozee@457
|
498 gphoto2 --auto-detect
|
al@813
|
499 _n 'Do you want to test importing photos'; confirm
|
pascal@1029
|
500 if [ $? = 0 ]; then
|
jozee@457
|
501 mkdir -p ~/Images/Photos
|
jozee@457
|
502 cd ~/Images/Photos
|
jozee@457
|
503 gphoto2 --get-all-files
|
al@813
|
504 file-manager ~/Images/Photos
|
jozee@457
|
505 fi
|
al@813
|
506 newline
|
gokhlayeh@497
|
507 else
|
al@813
|
508 newline; separator
|
al@813
|
509 _ 'Camera is set up; please use gphoto2 to import photos'
|
al@943
|
510 _ 'Quick start guide: %s' 'http://www.gphoto.org/doc/manual/using-gphoto2.html'
|
al@813
|
511 separator; newline
|
jozee@457
|
512 fi
|
jozee@457
|
513 else
|
jozee@457
|
514 failed
|
al@813
|
515 fi
|
al@813
|
516 ;;
|
al@939
|
517
|
gokhlayeh@497
|
518 bluetooth)
|
jozee@457
|
519 load_modules
|
jozee@457
|
520 udev
|
gokhlayeh@497
|
521
|
al@813
|
522 _n 'Do you want to see if the bluetooth is working'; confirm
|
pascal@1029
|
523 if [ $? = 0 ]; then
|
al@813
|
524 newline
|
al@939
|
525
|
jozee@457
|
526 # sanity check: btusb is not loaded automagically for unknown reasons
|
gokhlayeh@497
|
527 if ! lsmod | grep -q btusb ; then
|
jozee@457
|
528 modprobe btusb
|
jozee@457
|
529 fi
|
al@813
|
530 separator
|
al@813
|
531 emsg "$(_n '<b>Bluetooth</b> interfaces')"
|
al@813
|
532 newline
|
jozee@457
|
533 lsusb | grep Bluetooth
|
al@939
|
534
|
jozee@457
|
535 # udev should run bluetoothd automatically
|
gokhlayeh@497
|
536 bluetoothd
|
jozee@484
|
537 sleep 1
|
jozee@484
|
538 if hcitool dev | grep -q hci ; then
|
al@813
|
539 newline; separator
|
al@813
|
540 emsg "$(_n 'Following <b>Bluetooth commands</b> may be of help')"
|
al@813
|
541 newline
|
al@813
|
542 optlist "\
|
al@813
|
543 modprobe btusb
|
al@813
|
544 hciconfig -a
|
al@813
|
545 hcitool dev $(_n 'checking local bluetooth devices...')
|
al@813
|
546 hcitool scan $(_n 'scanning remote bluetooth devices...')
|
al@813
|
547 bluez-simple-agent $(_n 'pairing with remote bluetooth devices...')"
|
al@813
|
548 newline
|
al@813
|
549 bt=$(emsg '<b>/etc/bluetooth</b>')
|
al@813
|
550 longline $(_ "You can manually edit the configuration \
|
al@943
|
551 files in %s if need be" "$bt")
|
al@813
|
552 separator; newline
|
jozee@484
|
553 fi
|
jozee@457
|
554 else
|
jozee@457
|
555 # Show if the bluetooth is detected
|
al@813
|
556 newline; separator
|
al@813
|
557 emsg "$(_n 'Following <b>Bluetooth commands</b> may be of help')"
|
al@813
|
558 newline
|
al@813
|
559 cat << EOT
|
al@813
|
560 modprobe btusb
|
al@813
|
561 lsusb | grep Bluetooth
|
al@813
|
562 EOT
|
al@813
|
563 optlist "\
|
al@813
|
564 /usr/sbin/bluetoothd -nd $(_n 'for starting bluetooth daemon')
|
al@813
|
565 hciconfig -a
|
al@813
|
566 hcitool dev $(_n 'for checking local devices')
|
al@813
|
567 hcitool scan $(_n 'for scanning remote devices')
|
al@813
|
568 bluez-simple-agent $(_n 'pairing with remote bluetooth devices')"
|
al@813
|
569 newline
|
al@813
|
570 bt=$(emsg '<b>/etc/bluetooth</b>')
|
al@813
|
571 longline $(_ "You can manually edit the configuration files \
|
al@943
|
572 in %s if need be" "$bt")
|
al@813
|
573 newline; separator
|
al@813
|
574 fi
|
al@813
|
575 ;;
|
al@813
|
576
|
gokhlayeh@497
|
577 3g-modem)
|
al@813
|
578 untested
|
al@813
|
579 load_modules
|
al@813
|
580 udev
|
al@813
|
581 newline; separator
|
al@813
|
582 _ 'List detected devices'
|
al@813
|
583 # ls /dev/ttyUSB* /dev/ttyACM* /dev/modem
|
gokhlayeh@497
|
584
|
al@813
|
585 if [ -n "$(ls /dev/ttyUSB*)" -o -n "$(ls /dev/ttyACM*)" ] ; then
|
al@813
|
586 _ 'Detected Modem at:'
|
al@813
|
587 ls /dev/ttyUSB* /dev/ttyACM* 2> /dev/null
|
al@813
|
588 _n 'Do you want to configure wvdial'; confirm
|
pascal@1029
|
589 if [ $? = 0 ]; then
|
al@813
|
590 wvdialbox
|
al@813
|
591 else
|
al@813
|
592 #nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf
|
al@813
|
593 newline; separator
|
al@813
|
594 optlist "\
|
al@943
|
595 wvdialconf $(_ 'Edit %s for phone number, login name, password and pin' "$(boldify '/etc/wvdial.conf')")
|
al@943
|
596 wvdial $(_ 'Add DNS address of your provider in %s' "$(boldify '/etc/resolv.conf')")"
|
al@813
|
597 separator
|
al@813
|
598 fi
|
al@813
|
599 else
|
al@813
|
600 failed
|
al@813
|
601 fi
|
al@813
|
602 ;;
|
gokhlayeh@497
|
603
|
al@813
|
604 firewall)
|
al@813
|
605 _ 'Setting IPTABLES_RULES to yes in /etc/slitaz/firewall.conf'
|
al@813
|
606 sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/slitaz/firewall.conf
|
al@813
|
607 # default is "start"
|
pascal@1029
|
608 if [ "$STOP" = "yes" ] ; then
|
al@813
|
609 /etc/init.d/firewall stop
|
al@813
|
610 else
|
al@813
|
611 /etc/init.d/firewall start
|
al@813
|
612 if [ -d $INSTALLED/nmap ]; then
|
al@813
|
613 separator
|
al@943
|
614 _ 'Probing for open ports...'
|
al@813
|
615 nmap localhost
|
al@813
|
616 separator
|
al@813
|
617 fi
|
al@943
|
618 _ 'Adding firewall daemon to start automatically at boot'
|
al@813
|
619 run_daemon_startup "firewall"
|
al@813
|
620 separator
|
al@813
|
621 fi
|
al@813
|
622 ;;
|
al@813
|
623
|
gokhlayeh@497
|
624 nvidia)
|
al@813
|
625 xorg55=/etc/X11/xorg.conf.d/55-DeviceTweaks.conf
|
al@813
|
626 xorg60=/etc/X11/xorg.conf.d/60-Device.conf
|
al@813
|
627 xorg55short=55-DeviceTweaks.conf
|
pascal@1029
|
628 if [ "$NON_FREE" = "yes" ] ; then
|
al@813
|
629 if [ -d $INSTALLED/xorg-xf86-video-nv ]; then
|
al@813
|
630 rm $xorg55
|
gokhlayeh@497
|
631 tazpkg remove xorg-xf86-video-nv
|
gokhlayeh@497
|
632 fi
|
gokhlayeh@497
|
633 load_modules
|
gokhlayeh@497
|
634 #xorg
|
al@813
|
635 _n 'Do you want to configure X using non-free nvidia driver'; confirm
|
pascal@1029
|
636 if [ $? = 0 ]; then
|
al@813
|
637 newline
|
al@943
|
638 _ 'Your previous config is in %s' "$xorg60"
|
al@943
|
639 _ 'If nvidia fails, you can remove %s to restore previous config.' "$xorg55"
|
gokhlayeh@497
|
640 Xorg -configure :1 > /dev/null
|
gokhlayeh@497
|
641 nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia
|
al@813
|
642 sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.nvidia > $xorg55
|
gokhlayeh@497
|
643 rm /tmp/xorg.conf.nvidia /root/xorg.conf.new
|
gokhlayeh@497
|
644
|
al@813
|
645 if ! grep -q "NoLogo" $xorg55 ; then
|
al@813
|
646 _n 'Adding to xorg.conf:'; echo ' Option "NoLogo" "True"'
|
al@813
|
647 sed -i 's/BoardName\(.*\)/Boardname \1 \n Option "NoLogo" "True" /' $xorg55
|
jozee@457
|
648 fi
|
gokhlayeh@497
|
649
|
gokhlayeh@497
|
650 # mesa-demos to check if acceleration is working
|
al@813
|
651 _ 'Checking if nvidia is working...'
|
al@813
|
652 glxinfo | grep rendering
|
gokhlayeh@497
|
653
|
al@813
|
654 newline; separator
|
al@813
|
655 boldify "$(_n 'Configure nvidia settings:')"
|
gokhlayeh@497
|
656 nvidia-settings
|
al@813
|
657 separator; newline
|
gokhlayeh@497
|
658 else
|
al@813
|
659 newline; separator
|
al@813
|
660 xcmd='Xorg -configure :1 && nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia'
|
al@943
|
661 _ "Use '%s' to generate a template configuration file." "$xcmd"
|
al@813
|
662 echo 'glxinfo | grep rendering #' $(_n 'test nvidia')
|
al@813
|
663 _ 'Use: nvidia-settings utility to configure your settings if necessary'
|
al@813
|
664 echo 'Option "NoLogo" "True"'
|
al@813
|
665 separator; newline
|
gokhlayeh@497
|
666 fi
|
gokhlayeh@497
|
667 else
|
al@813
|
668 if [ -d $INSTALLED/nvidia ]; then
|
al@813
|
669 rm $xorg55
|
gokhlayeh@497
|
670 tazpkg remove nvidia
|
gokhlayeh@497
|
671 fi
|
gokhlayeh@497
|
672 load_modules
|
gokhlayeh@497
|
673 #xorg
|
al@813
|
674 _n 'Do you want to configure X using free nvidia driver'; confirm
|
pascal@1029
|
675 if [ $? = 0 ]; then
|
al@813
|
676 newline; separator
|
al@943
|
677 _ 'Your previous config is in %s' "$xorg60"
|
al@943
|
678 _ 'If nvidia fails, you can remove %s to restore previous config.' "$xorg55"
|
al@813
|
679 newline
|
al@943
|
680 _ 'Create %s configured with nv driver.' "$xorg55short"
|
gokhlayeh@497
|
681
|
gokhlayeh@497
|
682 # free nvidia driver is called nv
|
al@813
|
683 cp -a $xorg60 $xorg55
|
al@813
|
684 sed -i 's/vesa/nv/' $xorg55
|
gokhlayeh@497
|
685
|
gokhlayeh@497
|
686 # mesa-demos to check if acceleration is working
|
al@813
|
687 _ 'Checking if nvidia is working...'
|
al@813
|
688 glxinfo | grep rendering
|
al@813
|
689 separator
|
gokhlayeh@497
|
690 fi
|
gokhlayeh@497
|
691 fi
|
gokhlayeh@497
|
692 ;;
|
al@813
|
693
|
al@813
|
694 ati)
|
al@813
|
695 xorg55=/etc/X11/xorg.conf.d/55-DeviceTweaks.conf
|
al@813
|
696 xorg60=/etc/X11/xorg.conf.d/60-Device.conf
|
al@813
|
697 xorg55short=55-DeviceTweaks.conf
|
al@813
|
698 untested
|
pascal@1029
|
699 if [ "$NON_FREE" = "yes" ] ; then
|
al@813
|
700 if [ -d $INSTALLED/xorg-xf86-video-ati ]; then
|
al@813
|
701 rm $xorg55
|
gokhlayeh@497
|
702 tazpkg remove xorg-xf86-video-ati
|
gokhlayeh@497
|
703 fi
|
gokhlayeh@497
|
704 load_modules
|
gokhlayeh@497
|
705 #xorg
|
al@813
|
706 _n 'Do you want to configure X using non-free catalyst ATI (radeon) driver'; confirm
|
pascal@1029
|
707 if [ $? = 0 ]; then
|
al@813
|
708 newline
|
al@943
|
709 _ 'Your previous config is in %s' "$xorg60"
|
al@943
|
710 _ 'If ati fails, you can remove %s to restore previous config.' "$xorg55"
|
gokhlayeh@497
|
711
|
gokhlayeh@497
|
712 # add fglrx driver to xorg.conf
|
gokhlayeh@497
|
713 Xorg -configure :1 > /dev/null
|
gokhlayeh@497
|
714 aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati
|
al@813
|
715 sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.ati > $xorg55
|
gokhlayeh@497
|
716 rm /tmp/xorg.conf.ati /root/xorg.conf.new
|
gokhlayeh@497
|
717
|
gokhlayeh@497
|
718 # mesa-demos to check if acceleration is working
|
al@813
|
719 _ 'Checking if ati catalyst is working...'
|
al@813
|
720 glxinfo | grep rendering
|
gokhlayeh@497
|
721 else
|
al@813
|
722 newline; separator
|
al@813
|
723 boldify "$(_n 'Configuration:')"
|
al@813
|
724 _ 'Use: aticonfig utility to generate a template configuration file if necessary'
|
al@813
|
725 cat << EOT
|
al@813
|
726 Xorg -configure :1 && aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati
|
al@813
|
727 restart xorg
|
al@813
|
728 glxinfo | grep rendering
|
al@813
|
729 EOT
|
al@813
|
730 separator; newline
|
gokhlayeh@497
|
731 fi
|
gokhlayeh@497
|
732 else
|
al@813
|
733 if [ -d $INSTALLED/catalyst ]; then
|
al@813
|
734 rm $xorg55
|
gokhlayeh@497
|
735 tazpkg remove catalyst
|
gokhlayeh@497
|
736 fi
|
gokhlayeh@497
|
737 load_modules
|
gokhlayeh@497
|
738 #xorg
|
al@813
|
739 _n 'Do you want to configure X using free ATI (radeon) driver'; confirm
|
pascal@1029
|
740 if [ $? = 0 ]; then
|
al@813
|
741 newline; separator
|
al@943
|
742 _ 'Your previous config is in %s' "$xorg60"
|
al@943
|
743 _ 'If ATI fails, you can remove %s to restore previous config.' "$xorg55"
|
al@813
|
744 newline
|
al@943
|
745 _ 'Create %s configured with radeon driver.' "$xorg55short"
|
gokhlayeh@497
|
746
|
gokhlayeh@497
|
747 # free ati driver is called radeon
|
gokhlayeh@497
|
748 cp -a /etc/X11/xorg.conf.d/60-Device.conf /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
|
gokhlayeh@497
|
749 sed -i 's/vesa/nv/' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
|
gokhlayeh@497
|
750 # mesa-demos to check if acceleration is working
|
al@813
|
751 _ 'Checking if ATI radeon is working...'
|
gokhlayeh@497
|
752 glxinfo |grep rendering
|
al@813
|
753 separator
|
gokhlayeh@497
|
754 fi
|
gokhlayeh@497
|
755 fi
|
gokhlayeh@497
|
756 ;;
|
jozee@457
|
757 esac
|
jozee@457
|
758 }
|
jozee@457
|
759
|
al@939
|
760
|
jozee@457
|
761 # What to do.
|
al@939
|
762
|
jozee@457
|
763 case "$1" in
|
al@813
|
764 -h|--help|help|usage) usage ;;
|
al@813
|
765 wvdial) wvdialbox ;;
|
al@813
|
766 xorg) xorg ;;
|
gokhlayeh@497
|
767
|
al@813
|
768 dial)
|
al@813
|
769 _ 'Bringing eth0 down...'; ifconfig eth0 down; ifconfig eth1 down
|
al@813
|
770 _ 'Dialing...'; wvdial $2
|
al@813
|
771 sleep 5 ;;
|
gokhlayeh@497
|
772
|
al@813
|
773 *)
|
al@813
|
774 check_root $@
|
al@813
|
775 echo "COMMAND OPTIONS: $@"
|
al@813
|
776 NON_FREE="$nonfree"
|
al@813
|
777 AUTO_INSTALL_SUGGESTED="$suggested"
|
al@813
|
778 CONFIRM_SUGGESTED="$confirm"
|
al@813
|
779 for i in "$@"; do
|
pascal@1029
|
780 # if [ "$i" = "--non-free" ] ; then NON_FREE="yes"; fi
|
pascal@1029
|
781 # if [ "$i" = "--suggested" ] ; then AUTO_INSTALL_SUGGESTED="yes"; fi
|
pascal@1029
|
782 # if [ "$i" = "--confirm" ] ; then CONFIRM_SUGGESTED="yes"; fi
|
pascal@1029
|
783 if [ "$i" = "stop" ] ; then STOP="yes"; fi
|
al@813
|
784 done
|
jozee@457
|
785
|
al@813
|
786 device
|
al@813
|
787 #untested
|
pascal@1029
|
788 if [ -n "$NON_FREE_DEPENDS" -a "$NON_FREE" = "yes" ]; then
|
al@813
|
789 DEPENDS="$NON_FREE_DEPENDS"
|
al@813
|
790 fi
|
gokhlayeh@497
|
791
|
pascal@1029
|
792 if [ "$AUTO_INSTALL_SUGGESTED" = "yes" ]; then
|
al@813
|
793 anser="all"
|
pascal@1029
|
794 elif [ "$CONFIRM_SUGGESTED" = "yes" ]; then
|
al@813
|
795 newline; separator
|
al@813
|
796 _ 'The following optional packages can be installed:'
|
al@813
|
797 newline
|
al@813
|
798 echo $SUGGESTED
|
al@813
|
799 separator; newline
|
al@813
|
800 _n 'Do you want to install all/few/no optional dependencies (all|few|N)? '; read anser
|
al@813
|
801 fi
|
jozee@457
|
802
|
al@813
|
803 install "$DEPENDS"
|
al@813
|
804 case $anser in
|
al@813
|
805 [aA]*|[yY]|1) install "$SUGGESTED" ;;
|
al@813
|
806 [fF]*|2) confirm_install "$SUGGESTED" ;;
|
al@813
|
807 *) ;;
|
al@813
|
808 esac
|
al@813
|
809
|
al@813
|
810 add_all_user_to_group
|
al@813
|
811 setup ;;
|
jozee@457
|
812 esac
|