slitaz-tools view tinyutils/hwsetup @ rev 708
Add: name[pt_BR] to desktop files
author | Claudinei Pereira <claudinei@slitaz.org> |
---|---|
date | Wed Mar 14 03:55:38 2012 -0300 (2012-03-14) |
parents | 5299601a32b9 |
children | 29fe613b2eb6 |
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 Parallel 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 [ -n "$vendorid" ] || continue
203 productid=`echo "$line" | awk '{ print $2 }'`
204 vendor=`zcat /usr/share/misc/usb.ids.gz | grep $vendorid | head -1`
205 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' `
206 echo " $count) Vendor : $vendor "
207 echo " Product : $product"
208 echo "========================================"
209 count=`expr $count + 1`
210 done
211 # confirm (use dmesg or some other way to automate this)
212 confirm_device
213 fi
214 }
216 confirm_device()
217 {
218 echo -n "Which no. is your $DEVICE shown in the above lines (1,2,3,none); ? "; read choice
220 case "$choice" in
221 [nN*]) DETECTED="no" ;;
223 *) dev=`echo "$DEVICES_LIST" | head -$choice | tail -1`
224 vendorid=`echo "$dev" | awk '{ print $1 }'`
225 productid=`echo "$dev" | awk '{ print $2 }'`
226 bus=`grep -B2 ".*$vendorid.*$productid" /proc/bus/usb/devices| grep Bus`
227 busno=` echo $bus| awk '{ print $2 }' |cut -d "=" -f 2`
228 deviceno=`echo $bus| awk '{ print $8 }' `
229 HP=`echo $vendor | grep -q -i "Hewlett"`
230 DETECTED="yes"
231 ;;
232 esac
235 }
237 hputil()
238 {
239 if [ "$HP" == "1" ]; then
240 install "hplip"
241 echo ""
242 echo -n "Do you want to use hp-setup utility (y/N) ? "; read choice
243 if [ "$choice" == "y" ]; then
244 hp-setup
245 fi
246 fi
247 }
249 # udev now should do this correctly
250 fix_usb_permissions()
251 {
252 grp=$1
253 if [ "$DETECTED" == "yes" ]; then
254 if ls /dev/bus/usb/*$busno/*$deviceno ; then
255 chmod 666 /dev/bus/usb/*$busno/*$deviceno
256 chgrp $grp /dev/bus/usb/*$busno/*$deviceno
257 echo "========================================"
258 echo -e "\033[1m Verify $DEVICE Permissions \033[0m "
259 echo "Your $DEVICE must be in $grp group with 666 permissions"
260 ls -l /dev/bus/usb/*$busno/*$deviceno
261 echo "========================================"
262 fi
263 fi
265 }
267 fix_parallel_permissions()
268 {
269 if [ -f /usr/lib/cups/backend/parallel ] ; then
270 chmod 0755 /usr/lib/cups/backend/parallel
271 fi
272 }
274 load_modules()
275 {
276 tazhw detect-pci
277 tazhw detect-usb
278 sleep 1
279 }
281 udev()
282 {
284 if [ "$UDEV_RULES" == "yes" ]; then
285 echo "New udev rules are added by a package"
286 udevadm trigger
287 sleep 2
288 fi
290 }
292 xorg()
293 {
295 [ -x /usr/bin/Xorg ] || install "xorg"
296 echo "Auto configuring Xorg.."
297 # Xorg auto configuration.
298 if [ ! -d /etc/X11/xorg.conf.d -a -x /usr/bin/Xorg ]; then
299 echo "Configuring Xorg..."
300 # Populate /etc/X11/xorg.conf.d if it doesn't exist.
301 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
302 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
303 tazx config-xorg
304 fi
306 }
308 wvdialbox()
309 {
310 # setup your modem
311 #wvdialconf
312 echo "===================================="
313 #set username, password, pin
314 #echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin"
315 if [ ! -f /etc/wvdial.conf ]; then
316 APN="apn.yournet.net"
317 PHONE="*99#"
318 USERNAME="user"
319 PASSWORD="passwd"
320 PIN="9999"
321 echo "[Dialer slitaz]" > /etc/wvdial.conf
322 echo "Phone = $PHONE" >> /etc/wvdial.conf
323 echo "Username = $USERNAME" >> /etc/wvdial.conf
324 echo "Password = $PASSWORD" >> /etc/wvdial.conf
325 echo "Stupid Mode = 1" >> /etc/wvdial.conf
326 echo "Dial Command = ATDT" >> /etc/wvdial.conf
327 [ -n "$MODEM" ] || MODEM="/dev/ttyUSB0"
328 echo "Modem = $MODEM" >> /etc/wvdial.conf
329 echo "Baud = 460800" >> /etc/wvdial.conf
330 echo "Init1 = ATZ " >> /etc/wvdial.conf
331 echo "Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" >> /etc/wvdial.conf
332 echo "Init3 = AT+CGDCONT=1,\"IP\", \"$APN\"" >> /etc/wvdial.conf
333 echo "ISDN = 0" >> /etc/wvdial.conf
334 echo "Modem Type = Analog Modem" >> /etc/wvdial.conf
335 echo "" >> /etc/wvdial.conf
336 echo "" >> /etc/wvdial.conf
337 echo "[Dialer pin]" >> /etc/wvdial.conf
338 echo "Modem = $MODEM" >> /etc/wvdial.conf
339 echo "Init4 = AT+CPIN=$PIN" >> /etc/wvdial.conf
340 fi
341 #<action>sed -i "s/^\[Dialer.*/[Dialer slitaz]/" /etc/wvdial.conf</action>
342 #DIALER=`grep Dialer /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
343 #DIALER=`grep -B1 AT+CPIN /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
345 MAIN_DIALOG="
346 <window title=\"Wvdial Box\" icon-name=\"applications-internet\">
347 <vbox>
349 "
350 MAIN_DIALOG=${MAIN_DIALOG}'
352 <hbox>
353 <text use-markup="true">
354 <label>"<b>Phone Number: </b>"</label>
355 </text>
356 <entry>
357 <input>cat /etc/wvdial.conf | grep ^Phone | cut -d "=" -f2 | tr -d "[\" ]"</input>
358 <variable>PHONE</variable>
359 </entry>
360 </hbox>
361 <hbox>
362 <text use-markup="true">
363 <label>"<b>Username: </b>"</label>
364 </text>
365 <entry>
366 <input>cat /etc/wvdial.conf | grep ^Username | cut -d "=" -f2 | tr -d "[\" ]"</input>
367 <variable>USERNAME</variable>
368 </entry>
369 </hbox>
370 <hbox>
371 <text use-markup="true">
372 <label>"<b>Password: </b>"</label>
373 </text>
374 <entry visibility="false">
375 <input>cat /etc/wvdial.conf | grep ^Password | cut -d "=" -f2 | tr -d "[\" ]"</input>
376 <variable>PASSWORD</variable>
377 </entry>
378 </hbox>
379 <hbox>
380 <text use-markup="true">
381 <label>"<b>Pin (if required):</b>"</label>
382 </text>
383 <entry visibility="false">
384 <input>cat /etc/wvdial.conf | grep AT+CPIN= | cut -d "=" -f3 | tr -d "[\" ]"</input>
385 <variable>PIN</variable>
386 </entry>
387 </hbox>
388 <hbox>
389 <text use-markup="true">
390 <label>"<b>Modem: </b>"</label>
391 </text>
392 <entry>
393 <input>cat /etc/wvdial.conf | grep ^Modem.*/dev.* | cut -d "=" -f2 | tr -d "[\" ]"|uniq</input>
394 <variable>MODEM</variable>
395 </entry>
396 </hbox>
397 <hbox>
398 <text use-markup="true">
399 <label>"<b>Access Point Name (APN):</b>"</label>
400 </text>
401 <entry>
402 <input>cat /etc/wvdial.conf | grep AT+CGDCONT | cut -d "," -f3 | tr -d "[\" ]"</input>
403 <variable>APN</variable>
404 </entry>
405 </hbox>
408 <hbox>
409 <text use-markup="true">
410 <label>"
411 <b>You must save your account info before dialing </b>"</label>
412 </text>
413 </hbox>
414 <hbox>
415 <button>
416 <label>/etc/wvdial.conf</label>
417 <input file icon="accessories-text-editor"></input>
418 <action>leafpad /etc/wvdial.conf</action>
419 <action>refresh:PHONE</action>
420 <action>refresh:USERNAME</action>
421 <action>refresh:PASSWORD</action>
422 <action>refresh:PIN</action>
423 <action>refresh:APN</action>
424 <action>refresh:MODEM</action>
425 </button>
426 <button>
427 <label>Save Configuration</label>
428 <input file icon="document-save"></input>
429 <action>sed -i "s/^Phone.*/Phone = $PHONE/ " /etc/wvdial.conf</action>
430 <action>sed -i "s/^Username.*/Username = $USERNAME/ " /etc/wvdial.conf</action>
431 <action>sed -i "s/^Password.*/Password = $PASSWORD/ " /etc/wvdial.conf</action>
432 <action>sed -i "s/.*AT+CPIN=.*/Init4 = AT+CPIN=$PIN/ " /etc/wvdial.conf</action>
433 <action>sed -i "s/.*AT+CGDCONT=.*/Init3 = AT+CGDCONT=1,\"IP\", \"$APN\" /" /etc/wvdial.conf </action>
434 <action>sed -i "s:^Modem.*/dev.*:Modem = $MODEM: " /etc/wvdial.conf</action>
435 </button>
437 </hbox>
438 <hbox>
439 <button>
440 <label>Dial Pin Once </label>
441 <input file icon="forward"></input>
442 <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial pin; sleep 5"</action>
443 </button>
444 <button>
445 <label>Start Dialing </label>
446 <input file icon="forward"></input>
447 <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial slitaz; sleep 5"</action>
448 </button>
449 </hbox> '
452 export MAIN_DIALOG=${MAIN_DIALOG}"
453 </vbox>
454 </window>"
455 gtkdialog --center --program=MAIN_DIALOG
456 }
461 setup()
462 {
463 case "$DEVICE" in
464 printer)
465 load_modules
466 udev
467 # check parallel or usb printer
468 if [ -f /proc/sys/dev/parport/parport*/autoprobe* ] ; then
469 fix_parallel_permissions
470 DETECTED="yes"
471 else
472 find_usb_device
473 fix_usb_permissions "lp"
474 fi
475 #lpinfo -v
476 if [ "$DETECTED" == "yes" ]; then
477 echo ""
478 echo -n "Do you want to start cups (y/N) ? "; read anser
479 echo ""
480 if [ "$anser" == "y" ]; then
481 /etc/init.d/cupsd start
482 sleep 2
483 browser http://localhost:631/
484 else
485 echo ""
486 echo "===================================="
487 echo -e "Starting \033[1m cups \033[0m using :"
488 echo "/etc/init.d/cupsd start"
489 echo "browser http://localhost:631/"
490 echo "===================================="
491 fi
492 else
493 failed
494 fi
495 ;;
496 scanner)
497 load_modules
498 udev
499 find_usb_device
500 fix_usb_permissions "scanner"
502 if [ "$DETECTED" == "yes" ]; then
503 #hputil
504 echo ""
505 echo -n "Do you want to start scanner (y/N) ? "; read anser
506 echo ""
507 if [ "$anser" == "y" ]; then
508 sane-find-scanner # to verify scanner has been found
509 scanimage -L # List scanners
510 xsane #scanner application
511 else
512 echo ""
513 echo "===================================="
514 echo -e "Following \033[1m Scanner commands \033[0m may be of help"
515 echo "sane-find-scanner # to verify scanner has been found"
516 echo "xsane #scanner application"
517 echo "===================================="
518 fi
519 else
520 failed
521 fi
522 ;;
523 webcam)
524 load_modules
525 udev
527 if [ -n "`ls /dev/video0`" ] ; then
528 # fix permissions
529 chmod 666 /dev/video0
530 # ls -l /dev/video0
532 if [ -d /var/lib/tazpkg/installed/mplayer-svn ]; then
533 echo ""
534 echo -n "Would you like to test webcam (y/N) ? "; read anser
535 echo ""
536 if [ "$anser" == "y" ]; then
537 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
538 fi
539 else
540 echo ""
541 echo -n "Would you like to test webcam by installing mplayer-svn (y/N) ? "; read anser
542 echo ""
543 if [ "$anser" == "y" ]; then
544 install mplayer-svn
545 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
546 else
547 echo ""
548 echo "============================"
549 echo "Webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view"
550 echo "============================"
551 fi
552 fi
553 else
554 failed
555 fi
556 ;;
557 camera)
558 udev
559 find_usb_device
560 fix_usb_permissions "camera"
562 if [ "$DETECTED" == "yes" ]; then
563 echo ""
564 echo -n "Do you want to check if gphoto2 can talk to your camera (y/N) ? "; read anser
565 echo ""
566 if [ "$anser" == "y" ]; then
567 # Show if the camera is detected
568 gphoto2 --auto-detect
569 echo -e "Do you want to test importing photos (y/N) ? "; read choice
570 if [ "$choice" == "y" ]; then
571 mkdir -p ~/Images/Photos
572 cd ~/Images/Photos
573 gphoto2 --get-all-files
574 pcmanfm ~/Images/Photos
575 fi
576 echo ""
577 else
578 echo ""
579 echo "===================================="
580 echo "Camera is set up; please use gphoto2 to import photos"
581 echo "Quick start guide: http://www.gphoto.org/doc/manual/using-gphoto2.html"
582 echo "===================================="
583 fi
584 else
585 failed
586 fi
587 ;;
588 bluetooth)
589 load_modules
590 udev
592 echo -n "Do you want to see if the bluetooth is working (y/N) ? "; read anser
593 echo ""
594 if [ "$anser" == "y" ]; then
595 # sanity check: btusb is not loaded automagically for unknown reasons
596 if ! lsmod | grep -q btusb ; then
597 modprobe btusb
598 fi
599 echo "========================================"
600 echo -e "\033[1m Bluetooth \033[0m interfaces"
601 echo ""
602 lsusb | grep Bluetooth
603 # udev should run bluetoothd automatically
604 bluetoothd
605 sleep 1
606 if hcitool dev | grep -q hci ; then
607 echo "========================================"
608 echo -e "Following \033[1m Bluetooth commands \033[0m may be of help "
609 echo ""
610 #echo " modprobe btusb"
611 #echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon"
612 echo " hciconfig -a"
613 echo " \"hcitool dev\" : checking local bluetooth devices..."
614 echo " \"hcitool scan\" : scanning remote bluetooth devices..."
615 echo " \"bluez-simple-agent\" : pairing with remote bluetooth devices..."
616 echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
617 echo "========================================"
618 fi
619 else
620 echo ""
621 echo "========================================"
622 echo -e "Following \033[1m Bluetooth commands \033[0m may be of help"
623 echo ""
624 echo " modprobe btusb"
625 echo " lsusb | grep Bluetooth"
626 echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon"
627 echo " hciconfig -a"
628 # Show if the bluetooth is detected
629 echo " hcitool dev # for checking local devices"
630 echo " hcitool scan # for scanning remote devices"
631 echo " bluez-simple-agent # pairing with remote bluetooth devices"
632 echo ""
633 echo -e "You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
634 echo ""
635 echo "========================================"
636 fi
637 ;;
638 3g-modem)
639 untested
640 load_modules
641 udev
642 echo ""
643 echo "===================================="
644 echo "List detected devices"
645 # ls /dev/ttyUSB* /dev/ttyACM* /dev/modem
647 if [ -n "`ls /dev/ttyUSB*`" -o -n "`ls /dev/ttyACM*`" ] ; then
648 echo "Detected Modem at:"
649 echo "`ls /dev/ttyUSB*`"
650 echo -n "Do you want to configure wvdial (y/N) ? "; read anser
651 echo ""
652 if [ "$anser" == "y" ]; then
653 wvdialbox
654 else
655 echo "===================================="
656 echo "wvdialconf"
657 echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin"
658 echo "wvdial dialername"
659 #nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf
660 echo -e "Add DNS adress of your provider in : \033[1m /etc/resolv.conf \033[0m "
661 echo "===================================="
662 fi
663 else
664 failed
665 fi
666 ;;
667 firewall) echo "Setting IPTABLES_RULES to yes in /etc/firewall.conf"
668 sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/firewall.conf
669 # default is "start"
670 if [ "$STOP" == "yes" ] ; then
671 /etc/init.d/firewall stop
672 else
673 /etc/init.d/firewall start
674 if [ -d /var/lib/tazpkg/installed/nmap ]; then
675 echo "===================================="
676 echo "Probing for open ports..."
677 nmap localhost
678 echo "===================================="
679 fi
680 echo "Adding firewall daemon to start automatically at boot"
681 run_daemon_startup "firewall"
682 echo "===================================="
683 fi
685 ;;
686 nvidia)
687 if [ "$NON_FREE" == "yes" ] ; then
688 if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-nv ]; then
689 rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
690 tazpkg remove xorg-xf86-video-nv
691 fi
692 load_modules
693 #xorg
694 echo -n "Do you want to configure X using non-free nvidia driver (y/N) ? "; read anser
695 echo ""
696 if [ "$anser" == "y" ]; then
697 echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
698 echo "If nvidia fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
699 Xorg -configure :1 > /dev/null
700 nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia
701 sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.nvidia > /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
702 rm /tmp/xorg.conf.nvidia /root/xorg.conf.new
704 if ! grep -q "NoLogo" /etc/X11/xorg.conf.d/55-DeviceTweaks.conf ; then
705 echo "Adding to xorg.conf: Option \"NoLogo\" \"True\""
706 sed -i 's/BoardName\(.*\)/Boardname \1 \n Option "NoLogo" "True" /' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
707 fi
709 # mesa-demos to check if acceleration is working
710 echo "Checking if nvidia is working ..."
711 glxinfo |grep rendering
713 echo "================================"
714 echo -e "\033[1m Configure nvidia settings :\033[0m "
715 nvidia-settings
716 echo "================================"
717 else
718 echo ""
719 echo "================================"
720 echo "Use 'Xorg -configure :1 && nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia' to generate a template configuration file."
721 echo "glxinfo |grep rendering # test nvidia"
722 echo "Use: nvidia-settings utility to configure your settings if necessary"
723 echo "Option \"NoLogo\" \"True\""
724 echo "================================"
725 fi
726 else
727 if [ -d /var/lib/tazpkg/installed/nvidia ]; then
728 rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
729 tazpkg remove nvidia
730 fi
731 load_modules
732 #xorg
733 echo -n "Do you want to configure X using free nvidia driver (y/N) ? "; read anser
734 echo ""
735 if [ "$anser" == "y" ]; then
736 echo ""
737 echo "================================"
738 echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
739 echo "If nvidia fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
740 echo ""
741 echo "Create 55-DeviceTweaks.conf configured with nv driver."
743 # free nvidia driver is called nv
744 cp -a /etc/X11/xorg.conf.d/60-Device.conf /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
745 sed -i 's/vesa/nv/' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
747 # mesa-demos to check if acceleration is working
748 echo "Checking if nvidia is working ..."
749 glxinfo |grep rendering
750 echo "================================"
751 fi
752 fi
753 ;;
754 ati) untested
755 if [ "$NON_FREE" == "yes" ] ; then
756 if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-ati ]; then
757 rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
758 tazpkg remove xorg-xf86-video-ati
759 fi
760 load_modules
761 #xorg
762 echo -n "Do you want to configure X using non-free catalyst ati(radeon) driver (y/N) ? "; read anser
763 echo ""
764 if [ "$anser" == "y" ]; then
765 echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
766 echo "If ati fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
768 # add fglrx driver to xorg.conf
769 Xorg -configure :1 > /dev/null
770 aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati
771 sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.ati > /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
772 rm /tmp/xorg.conf.ati /root/xorg.conf.new
774 # mesa-demos to check if acceleration is working
775 echo "Checking if ati catalyst is working ..."
776 glxinfo |grep rendering
777 else
778 echo ""
779 echo "================================"
780 echo -e "\033[1m Configuration :\033[0m "
781 echo "Use: aticonfig utility to generate a template configuration file if necessary"
782 echo "Xorg -configure :1 && aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati"
783 echo "restart xorg"
784 echo "glxinfo |grep rendering"
785 echo "================================"
786 fi
787 else
788 if [ -d /var/lib/tazpkg/installed/catalyst ]; then
789 rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
790 tazpkg remove catalyst
791 fi
792 load_modules
793 #xorg
794 echo -n "Do you want to configure X using free ati (radeon) driver (y/N) ? "; read anser
795 echo ""
796 if [ "$anser" == "y" ]; then
797 echo ""
798 echo "================================"
799 echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
800 echo "If ati fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
801 echo ""
802 echo "Create 55-DeviceTweaks.conf configured with radeon driver."
804 # free ati driver is called radeon
805 cp -a /etc/X11/xorg.conf.d/60-Device.conf /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
806 sed -i 's/vesa/nv/' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
807 # mesa-demos to check if acceleration is working
808 echo "Checking if ati radeon is working ..."
809 glxinfo |grep rendering
810 echo "================================"
811 fi
812 fi
813 ;;
814 esac
815 }
817 # What to do.
818 case "$1" in
819 help|usage ) usage ;;
820 wvdial) wvdialbox ;;
821 xorg) xorg;;
823 *) check_root
824 echo "COMMAND OPTIONS: $@"
825 for i in "$@"; do
826 if [ "$i" == "--non-free" ] ; then NON_FREE="yes"; fi
827 if [ "$i" == "--suggested" ] ; then AUTO_INSTALL_SUGGESTED="yes"; fi
828 if [ "$i" == "--confirm" ] ; then CONFIRM_SUGGESTED="yes"; fi
829 if [ "$i" == "stop" ] ; then STOP="yes"; fi
830 done
832 device
833 #untested
834 if [ ! "$NON_FREE_DEPENDS" == "" -a "$NON_FREE" == "yes" ]; then
835 DEPENDS="$NON_FREE_DEPENDS"
836 fi
838 if [ "$AUTO_INSTALL_SUGGESTED" == "yes" ]; then
839 anser="all"
840 elif [ "$CONFIRM_SUGGESTED" == "yes" ]; then
841 echo ""
842 echo "===================================="
843 echo "The following optional packages can be installed:"
844 echo ""
845 echo "$SUGGESTED"
846 echo "===================================="
847 echo -n "Do you want to install all/few/no optional dependencies (all|few|N) ? "; read anser
848 fi
850 install "$DEPENDS"
851 case $anser in
852 [aA]*|[yY]|1) install "$SUGGESTED" ;;
853 [fF]*|2) confirm_install "$SUGGESTED" ;;
854 *) ;;
855 esac
857 add_all_user_to_group
858 setup ;;
859 esac