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