slitaz-tools view tinyutils/hwsetup @ rev 491

slitaz-installer: add tiny web boot support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 05 16:15:05 2010 +0200 (2010-07-05)
parents 7deb180a03a0
children 0bbb123aed02
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 [ ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
298 echo "Configuring Xorg..."
299 # generate xorg.conf if no xorg.conf (shifting from xvesa to xorg)
300 Xorg -configure
301 mv -f /root/xorg.conf.new /etc/X11/xorg.conf
302 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
303 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
304 tazx config-xorg
305 fi
307 }
309 wvdialbox()
310 {
311 # setup your modem
312 #wvdialconf
313 echo "===================================="
314 #set username, password, pin
315 #echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin"
316 if [ ! -f /etc/wvdial.conf ]; then
317 APN="apn.yournet.net"
318 PHONE="*99#"
319 USERNAME="user"
320 PASSWORD="passwd"
321 PIN="9999"
322 echo "[Dialer slitaz]" > /etc/wvdial.conf
323 echo "Phone = $PHONE" >> /etc/wvdial.conf
324 echo "Username = $USERNAME" >> /etc/wvdial.conf
325 echo "Password = $PASSWORD" >> /etc/wvdial.conf
326 echo "Stupid Mode = 1" >> /etc/wvdial.conf
327 echo "Dial Command = ATDT" >> /etc/wvdial.conf
328 [ -n "$MODEM" ] || MODEM="/dev/ttyUSB0"
329 echo "Modem = $MODEM" >> /etc/wvdial.conf
330 echo "Baud = 460800" >> /etc/wvdial.conf
331 echo "Init1 = ATZ " >> /etc/wvdial.conf
332 echo "Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" >> /etc/wvdial.conf
333 echo "Init3 = AT+CGDCONT=1,\"IP\", \"$APN\"" >> /etc/wvdial.conf
334 echo "ISDN = 0" >> /etc/wvdial.conf
335 echo "Modem Type = Analog Modem" >> /etc/wvdial.conf
336 echo "" >> /etc/wvdial.conf
337 echo "" >> /etc/wvdial.conf
338 echo "[Dialer pin]" >> /etc/wvdial.conf
339 echo "Modem = $MODEM" >> /etc/wvdial.conf
340 echo "Init4 = AT+CPIN=$PIN" >> /etc/wvdial.conf
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 MAIN_DIALOG="
347 <window title=\"Wvdial Box\" icon-name=\"applications-internet\">
348 <vbox>
350 "
351 MAIN_DIALOG=${MAIN_DIALOG}'
353 <hbox>
354 <text use-markup="true">
355 <label>"<b>Phone Number: </b>"</label>
356 </text>
357 <entry>
358 <input>cat /etc/wvdial.conf | grep ^Phone | cut -d "=" -f2 | tr -d "[\" ]"</input>
359 <variable>PHONE</variable>
360 </entry>
361 </hbox>
362 <hbox>
363 <text use-markup="true">
364 <label>"<b>Username: </b>"</label>
365 </text>
366 <entry>
367 <input>cat /etc/wvdial.conf | grep ^Username | cut -d "=" -f2 | tr -d "[\" ]"</input>
368 <variable>USERNAME</variable>
369 </entry>
370 </hbox>
371 <hbox>
372 <text use-markup="true">
373 <label>"<b>Password: </b>"</label>
374 </text>
375 <entry visibility="false">
376 <input>cat /etc/wvdial.conf | grep ^Password | cut -d "=" -f2 | tr -d "[\" ]"</input>
377 <variable>PASSWORD</variable>
378 </entry>
379 </hbox>
380 <hbox>
381 <text use-markup="true">
382 <label>"<b>Pin (if required):</b>"</label>
383 </text>
384 <entry visibility="false">
385 <input>cat /etc/wvdial.conf | grep AT+CPIN= | cut -d "=" -f3 | tr -d "[\" ]"</input>
386 <variable>PIN</variable>
387 </entry>
388 </hbox>
389 <hbox>
390 <text use-markup="true">
391 <label>"<b>Modem: </b>"</label>
392 </text>
393 <entry>
394 <input>cat /etc/wvdial.conf | grep ^Modem.*/dev.* | cut -d "=" -f2 | tr -d "[\" ]"|uniq</input>
395 <variable>MODEM</variable>
396 </entry>
397 </hbox>
398 <hbox>
399 <text use-markup="true">
400 <label>"<b>Access Point Name (APN):</b>"</label>
401 </text>
402 <entry>
403 <input>cat /etc/wvdial.conf | grep AT+CGDCONT | cut -d "," -f3 | tr -d "[\" ]"</input>
404 <variable>APN</variable>
405 </entry>
406 </hbox>
409 <hbox>
410 <text use-markup="true">
411 <label>"
412 <b>You must save your account info before dialing </b>"</label>
413 </text>
414 </hbox>
415 <hbox>
416 <button>
417 <label>/etc/wvdial.conf</label>
418 <input file icon="accessories-text-editor"></input>
419 <action>leafpad /etc/wvdial.conf</action>
420 <action>refresh:PHONE</action>
421 <action>refresh:USERNAME</action>
422 <action>refresh:PASSWORD</action>
423 <action>refresh:PIN</action>
424 <action>refresh:APN</action>
425 <action>refresh:MODEM</action>
426 </button>
427 <button>
428 <label>Save Configuration</label>
429 <input file icon="document-save"></input>
430 <action>sed -i "s/^Phone.*/Phone = $PHONE/ " /etc/wvdial.conf</action>
431 <action>sed -i "s/^Username.*/Username = $USERNAME/ " /etc/wvdial.conf</action>
432 <action>sed -i "s/^Password.*/Password = $PASSWORD/ " /etc/wvdial.conf</action>
433 <action>sed -i "s/.*AT+CPIN=.*/Init4 = AT+CPIN=$PIN/ " /etc/wvdial.conf</action>
434 <action>sed -i "s/.*AT+CGDCONT=.*/Init3 = AT+CGDCONT=1,\"IP\", \"$APN\" /" /etc/wvdial.conf </action>
435 <action>sed -i "s:^Modem.*/dev.*:Modem = $MODEM: " /etc/wvdial.conf</action>
436 </button>
438 </hbox>
439 <hbox>
440 <button>
441 <label>Dial Pin Once </label>
442 <input file icon="forward"></input>
443 <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial pin; sleep 5"</action>
444 </button>
445 <button>
446 <label>Start Dialing </label>
447 <input file icon="forward"></input>
448 <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial slitaz; sleep 5"</action>
449 </button>
450 </hbox> '
453 export MAIN_DIALOG=${MAIN_DIALOG}"
454 </vbox>
455 </window>"
456 gtkdialog --center --program=MAIN_DIALOG
457 }
462 setup()
463 {
464 case "$DEVICE" in
465 printer)
466 load_modules
467 udev
468 # check parallel or usb printer
469 if [ -f /proc/sys/dev/parport/parport*/autoprobe* ] ; then
470 fix_parallel_permissions
471 DETECTED="yes"
472 else
473 find_usb_device
474 fix_usb_permissions "lp"
475 fi
476 #lpinfo -v
477 if [ "$DETECTED" == "yes" ]; then
478 echo ""
479 echo -n " Do you want to start cups (y/N) ? "; read anser
480 echo ""
481 if [ "$anser" == "y" ]; then
482 /etc/init.d/cupsd start
483 sleep 2
484 browser http://localhost:631/
485 else
486 echo ""
487 echo "===================================="
488 echo -e "Start \033[1m cups \033[0m using :"
489 echo "/etc/init.d/cupsd start"
490 echo "browser http://localhost:631/"
491 echo "===================================="
492 fi
493 else
494 failed
495 fi
496 ;;
497 scanner)
498 load_modules
499 udev
500 find_usb_device
501 fix_usb_permissions "scanner"
503 if [ "$DETECTED" == "yes" ]; then
504 #hputil
505 echo ""
506 echo -n " Do you want to start scanner (y/N) ? "; read anser
507 echo ""
508 if [ "$anser" == "y" ]; then
509 sane-find-scanner # to verify scanner has been found
510 scanimage -L # List scanners
511 xsane #scanner application
512 else
513 echo ""
514 echo "===================================="
515 echo -e "Following \033[1m Scanner commands \033[0m may be of help"
516 echo "sane-find-scanner # to verify scanner has been found"
517 echo "xsane #scanner application"
518 echo "===================================="
519 fi
520 else
521 failed
522 fi
523 ;;
524 webcam)
525 load_modules
526 udev
528 if [ -n "`ls /dev/video0`" ] ; then
529 # fix permissions
530 chmod 666 /dev/video0
531 # ls -l /dev/video0
533 if [ -d /var/lib/tazpkg/installed/mplayer-svn ]; then
534 echo ""
535 echo -n " Would you like to test webcam (y/N) ? "; read anser
536 echo ""
537 if [ "$anser" == "y" ]; then
538 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
539 fi
540 else
541 echo ""
542 echo -n " Would you like to test webcam by installing mplayer-svn (y/N) ? "; read anser
543 echo ""
544 if [ "$anser" == "y" ]; then
545 install mplayer-svn
546 mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
547 else
548 echo ""
549 echo "============================"
550 echo "webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view"
551 echo "============================"
552 fi
553 fi
554 else
555 failed
556 fi
557 ;;
558 camera)
559 udev
560 find_usb_device
561 fix_usb_permissions "camera"
563 if [ "$DETECTED" == "yes" ]; then
564 echo ""
565 echo -n " Do you want to check if gphoto2 can talk to your camera (y/N) ? "; read anser
566 echo ""
567 if [ "$anser" == "y" ]; then
568 # Show if the camera is detected
569 gphoto2 --auto-detect
570 echo -e " Do you want to test importing photos (y/N) ? "; read choice
571 if [ "$choice" == "y" ]; then
572 mkdir -p ~/Images/Photos
573 cd ~/Images/Photos
574 gphoto2 --get-all-files
575 pcmanfm ~/Images/Photos
576 fi
577 echo ""
578 else
579 echo ""
580 echo "===================================="
581 echo "camera is set up; please use gphoto2 to import photos"
582 echo "Quick start guide: http://www.gphoto.org/doc/manual/using-gphoto2.html"
583 echo "===================================="
584 fi
585 else
586 failed
587 fi
588 ;;
589 bluetooth)
590 load_modules
591 udev
593 echo -n " Do you want to see if the bluetooth is working (y/N) ? "; read anser
594 echo ""
595 if [ "$anser" == "y" ]; then
596 # sanity check: btusb is not loaded automagically for unknown reasons
597 if ! lsmod | grep -q btusb ; then
598 modprobe btusb
599 fi
600 echo "========================================"
601 echo -e "\033[1m Bluetooth \033[0m interfaces"
602 echo ""
603 lsusb | grep Bluetooth
604 # udev should run bluetoothd automatically
605 bluetoothd
606 sleep 1
607 if hcitool dev | grep -q hci ; then
608 echo "========================================"
609 echo -e "Following \033[1m Bluetooth commands \033[0m may be of help "
610 echo ""
611 #echo " modprobe btusb"
612 #echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon"
613 echo " hciconfig -a"
614 echo " \"hcitool dev\" : checking local bluetooth devices..."
615 echo " \"hcitool scan\" : scanning remote bluetooth devices..."
616 echo " \"bluez-simple-agent\" : pairing with remote bluetooth devices..."
617 echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
618 echo "========================================"
619 fi
620 else
621 echo ""
622 echo "========================================"
623 echo -e "Following \033[1m Bluetooth commands \033[0m may be of help"
624 echo ""
625 echo " modprobe btusb"
626 echo " lsusb | grep Bluetooth"
627 echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon"
628 echo " hciconfig -a"
629 # Show if the bluetooth is detected
630 echo " hcitool dev # for checking local devices"
631 echo " hcitool scan # for scanning remote devices"
632 echo " bluez-simple-agent # pairing with remote bluetooth devices"
633 echo ""
634 echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
635 echo ""
636 echo "========================================"
637 fi
638 ;;
639 3g-modem)
640 untested
641 load_modules
642 udev
643 echo ""
644 echo "===================================="
645 echo "list detected devices"
646 # ls /dev/ttyUSB* /dev/ttyACM* /dev/modem
648 if [ -n "`ls /dev/ttyUSB*`" -o -n "`ls /dev/ttyACM*`" ] ; then
649 echo "Detected Modem at:"
650 echo "`ls /dev/ttyUSB*`"
651 echo -n " Do you want to configure wvdial (y/N) ? "; read anser
652 echo ""
653 if [ "$anser" == "y" ]; then
654 wvdialbox
655 else
656 echo "===================================="
657 echo "wvdialconf"
658 echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin"
659 echo "wvdial dialername"
660 #nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf
661 echo -e " Add DNS adress of your provider in : \033[1m /etc/resolv.conf \033[0m "
662 echo "===================================="
663 fi
664 else
665 failed
666 fi
667 ;;
668 firewall) echo "Setting IPTABLES_RULES to yes in /etc/firewall.conf"
669 sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/firewall.conf
670 # default is "start"
671 if [ "$STOP" == "yes" ] ; then
672 /etc/init.d/firewall stop
673 else
674 /etc/init.d/firewall start
675 if [ -d /var/lib/tazpkg/installed/nmap ]; then
676 echo "===================================="
677 echo "Probing for open ports..."
678 nmap localhost
679 echo "===================================="
680 fi
681 echo "adding firewall daemon to start automatically at boot"
682 run_daemon_startup "firewall"
683 echo "===================================="
684 fi
686 ;;
687 nvidia) if [ "$NON_FREE" == "yes" ] ; then
688 if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-nv ]; then
689 mv /etc/X11/xorg.conf.backup /etc/X11/xorg.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 config is backed up at /etc/X11/xorg.conf.backup"
698 echo "if nvidia fails; please use your backed up xorg.conf"
699 nvidia-xconfig
701 if ! grep -q "NoLogo" /etc/X11/xorg.conf ; then
702 echo "adding to xorg.conf: Option \"NoLogo\" \"True\""
703 sed -i 's/BoardName\(.*\)/Boardname \1 \n Option "NoLogo" "True" /' /etc/X11/xorg.conf
704 fi
706 # mesa-demos to check if acceleration is working
707 echo "Checking if nvidia is working ..."
708 glxinfo |grep rendering
710 echo "================================"
711 echo -e "\033[1m Configure nvidia settings :\033[0m "
712 nvidia-settings
713 echo "================================"
714 else
715 echo ""
716 echo "================================"
717 echo "nvidia-xconfig"
718 echo "glxinfo |grep rendering # test nvidia"
719 echo "Use: nvidia-settings utility to configure your settings if necessary"
720 echo "Option \"NoLogo\" \"True\""
721 echo "================================"
722 fi
723 else
724 if [ -d /var/lib/tazpkg/installed/nvidia ]; then
725 mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf
726 tazpkg remove nvidia
727 fi
728 load_modules
729 #xorg
730 echo -n " Do you want to configure X using free nvidia driver (y/N) ? "; read anser
731 echo ""
732 if [ "$anser" == "y" ]; then
733 echo ""
734 echo "================================"
735 #backup your current config
736 cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
737 echo "your config is backed up at /etc/X11/xorg.conf.backup"
738 echo "if nvidia fails; please use your backed up xorg.conf"
739 echo ""
740 echo "Replace vesa driver with nv in /etc/X11/xorg.conf"
741 # free nvidia driver is called nv
742 sed -i 's/vesa/nv/' /etc/X11/xorg.conf
743 # mesa-demos to check if acceleration is working
744 echo "Checking if nvidia is working ..."
745 glxinfo |grep rendering
746 echo "================================"
747 fi
748 fi
749 ;;
750 ati) untested
751 if [ "$NON_FREE" == "yes" ] ; then
752 if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-ati ]; then
753 mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf
754 tazpkg remove xorg-xf86-video-ati
755 fi
756 load_modules
757 #xorg
758 echo -n " Do you want to configure X using non-free catalyst ati(radeon) driver (y/N) ? "; read anser
759 echo ""
760 if [ "$anser" == "y" ]; then
761 #backup your current config
762 cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
763 echo "your config is backed up at /etc/X11/xorg.conf.backup"
764 echo "if ati fails; please use your backed up xorg.conf"
765 # add fglrx driver to xorg.conf
766 aticonfig --initial --input=/etc/X11/xorg.conf
767 # mesa-demos to check if acceleration is working
768 echo "Checking if ati catalyst is working ..."
769 glxinfo |grep rendering
770 else
771 echo ""
772 echo "================================"
773 echo -e "\033[1m Configuration :\033[0m "
774 echo "Use: aticonfig utility to configure xorg.conf settings if necessary"
775 echo "aticonfig --initial --input=/etc/X11/xorg.conf"
776 echo "restart xorg"
777 echo "glxinfo |grep rendering"
778 echo "================================"
779 fi
780 else
781 if [ -d /var/lib/tazpkg/installed/catalyst ]; then
782 mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf
783 tazpkg remove catalyst
784 fi
785 load_modules
786 #xorg
787 echo -n " Do you want to configure X using free ati (radeon) driver (y/N) ? "; read anser
788 echo ""
789 if [ "$anser" == "y" ]; then
790 echo ""
791 echo "================================"
792 #backup your current config
793 cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
794 echo "your config is backed up at /etc/X11/xorg.conf.backup"
795 echo "if ati fails; please use your backed up xorg.conf"
796 echo ""
797 echo "Replace vesa driver with radeon in /etc/X11/xorg.conf"
798 # free ati driver is called radeon
799 sed -i 's/vesa/radeon/' /etc/X11/xorg.conf
800 # mesa-demos to check if acceleration is working
801 echo "Checking if ati radeon is working ..."
802 glxinfo |grep rendering
803 echo "================================"
804 fi
805 fi
806 ;;
808 esac
809 }
811 # What to do.
812 case "$1" in
813 help|usage ) usage ;;
814 wvdial) wvdialbox ;;
815 xorg) xorg;;
817 *) check_root
818 echo "COMMAND OPTIONS: $@"
819 for i in "$@"; do
820 if [ "$i" == "--non-free" ] ; then NON_FREE="yes"; fi
821 if [ "$i" == "--suggested" ] ; then AUTO_INSTALL_SUGGESTED="yes"; fi
822 if [ "$i" == "--confirm" ] ; then CONFIRM_SUGGESTED="yes"; fi
823 if [ "$i" == "stop" ] ; then STOP="yes"; fi
824 done
826 device
827 #untested
828 if [ ! "$NON_FREE_DEPENDS" == "" -a "$NON_FREE" == "yes" ]; then
829 DEPENDS="$NON_FREE_DEPENDS"
830 fi
832 if [ "$AUTO_INSTALL_SUGGESTED" == "yes" ]; then
833 anser="all"
834 elif [ "$CONFIRM_SUGGESTED" == "yes" ]; then
835 echo ""
836 echo "===================================="
837 echo "Following optional packages can be installed:"
838 echo ""
839 echo "$SUGGESTED"
840 echo "===================================="
841 echo -n " Do you want to install all/few/no optional dependencies (all|few|N) ? "; read anser
842 fi
844 install "$DEPENDS"
845 case $anser in
846 [aA]*|[yY]|1) install "$SUGGESTED" ;;
847 [fF]*|2) confirm_install "$SUGGESTED" ;;
848 *) ;;
849 esac
851 add_all_user_to_group
852 setup ;;
853 esac