slitaz-tools view tinyutils/hwsetup @ rev 498

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