slitaz-tools view tinyutils/hwsetup @ rev 813

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