slitaz-tools diff tinyutils/hwsetup @ rev 457
tazhw can now setup devices
author | Rohit Joshi <jozee@slitaz.org> |
---|---|
date | Mon Mar 22 09:11:17 2010 +0000 (2010-03-22) |
parents | |
children | ae755fbd0ee8 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tinyutils/hwsetup Mon Mar 22 09:11:17 2010 +0000 1.3 @@ -0,0 +1,855 @@ 1.4 +#!/bin/sh 1.5 +# usage: hwsetup [device] 1.6 +# e.g., hwsetup printer 1.7 +# # 1.8 +# (c) - SliTaz GNU/Linux 2009 - GNU GPL v3 1.9 +# Authors : Rohit Joshi <jozee@slitaz.org> 1.10 +# 1.11 + 1.12 +DEVICE=$1 1.13 +DEPENDS="usbutils hal-info" 1.14 +AUTO_INSTALL_SUGGESTED="no" 1.15 +CONFIRM_SUGGESTED="no" 1.16 +NON_FREE="no" 1.17 +DETECTED="no" 1.18 + 1.19 +usage() 1.20 +{ 1.21 + echo -e "\nSliTaz Setup configuration\n 1.22 +\033[1mUsage: \033[0m `basename $0` [command] [--option] 1.23 + 1.24 +\033[1mCommands: \033[0m 1.25 + usage Print this short usage. 1.26 + printer Paraller and USB Printer setup. 1.27 + scanner USB Scanner setup. 1.28 + webcam Integrated and USB webcam setup. 1.29 + camera Digital Camera setup. 1.30 + bluetooth Bluetooth setup. 1.31 + 3g-modem 3g-modem setup. 1.32 + firewall start/stop firewall. 1.33 + nvidia Nvidia (non-free/free) setup. 1.34 + ati ATI (non-free/free) setup. 1.35 + 1.36 +\033[1mOptions: \033[0m 1.37 + --non-free install non-free packages (nvidia, ati). 1.38 + --suggested auto-install optional dependencies. 1.39 + --confirm confirm before installing optional dependencies\n" 1.40 +} 1.41 + 1.42 + 1.43 +run_daemon_startup() 1.44 +{ 1.45 + # Add server to rcS.conf and avoid duplication. 1.46 + . /etc/rcS.conf 1.47 + if ! echo "$RUN_DAEMONS" | grep -q "$1"; then 1.48 + sed -i "s/^RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"\1 $1\"/" /etc/rcS.conf 1.49 + fi 1.50 +} 1.51 + 1.52 +device() 1.53 +{ 1.54 + case "$DEVICE" in 1.55 + printer) 1.56 + DEPENDS="$DEPENDS cups cups-pdf" 1.57 + SUGGESTED="hplip gutenprint foomatic-filters foomatic-db hal-cups-utils foomatic-db-nonfree ufr2 splix" 1.58 + CONFIRM_SUGGESTED="yes" 1.59 + GROUP="lp" 1.60 + ;; 1.61 + scanner) 1.62 + DEPENDS="$DEPENDS xsane" 1.63 + SUGGESTED="hplip" 1.64 + GROUP="scanner lp" 1.65 + ;; 1.66 + webcam) 1.67 + DEPENDS="$DEPENDS v4l-dvb " 1.68 + SUGGESTED="xorg-xf86-video-v4l linux-video libv4l " 1.69 + GROUP="video audio lp" 1.70 + ;; 1.71 + camera) 1.72 + DEPENDS="$DEPENDS gphoto2" 1.73 + SUGGESTED="" 1.74 + GROUP="camera lp" 1.75 + ;; 1.76 + bluetooth) 1.77 + DEPENDS="$DEPENDS bluez" 1.78 + SUGGESTED="" 1.79 + GROUP="lp" 1.80 + ;; 1.81 + 3g-modem) 1.82 + DEPENDS="$DEPENDS linux-dialup wvdial pcmciautils" 1.83 + SUGGESTED="" 1.84 + GROUP="dialout lp" 1.85 + ;; 1.86 + firewall) 1.87 + DEPENDS="iptables slitaz-tools" 1.88 + SUGGESTED="nmap" 1.89 + GROUP="" 1.90 + ;; 1.91 + nvidia) 1.92 + DEPENDS="mesa mesa-demos linux-agp xorg-xf86-video-nv" 1.93 + NON_FREE_DEPENDS="mesa mesa-demos linux-agp nvidia" 1.94 + SUGGESTED="" 1.95 + GROUP="video" 1.96 + ;; 1.97 + ati) 1.98 + DEPENDS=" xorg-xf86-video-ati mesa-dri-ati " 1.99 + NON_FREE_DEPENDS="mesa mesa-demos mesa-dri linux-agp catalyst" 1.100 + SUGGESTED="" 1.101 + GROUP="video" 1.102 + ;; 1.103 + esac 1.104 +} 1.105 + 1.106 +# Check if user is root 1.107 +check_root() 1.108 +{ 1.109 + if test $(id -u) != 0 ; then 1.110 + echo -e "\nYou must be root to run `basename $0` with this option." 1.111 + echo -e "Please use 'su' and root password to become super-user.\n" 1.112 + exit 0 1.113 + fi 1.114 +} 1.115 + 1.116 +untested() 1.117 +{ 1.118 + echo "==========================================================" 1.119 + echo "Due to a lack of compatible hardware for troubleshooting," 1.120 + echo "this $DEVICE device has not been properly tested. Please " 1.121 + echo "report any success, failure, bug to SliTaz Labs or Forums." 1.122 + echo "==========================================================" 1.123 + sleep 1 1.124 +} 1.125 + 1.126 +failed() 1.127 +{ 1.128 + echo "" 1.129 + echo "======================================" 1.130 + echo " Failed to setup $DEVICE" 1.131 + echo "======================================" 1.132 + sleep 1 1.133 +} 1.134 +# Install DEPENDS and/or SUGGESTED 1.135 +install() 1.136 +{ 1.137 + #echo "pkgs to install: $1" 1.138 + for pkg in $1 ; do 1.139 + # Avoid reinstall 1.140 + if [ ! -d /var/lib/tazpkg/installed/"$pkg" ]; then 1.141 + echo "installing pkg: $pkg" 1.142 + tazpkg get-install "$pkg" --forced 1.143 + if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then 1.144 + UDEV_RULES="yes" 1.145 + fi 1.146 + fi 1.147 + done 1.148 + 1.149 +} 1.150 +# Install DEPENDS and/or SUGGESTED 1.151 +confirm_install() 1.152 +{ 1.153 + #echo "Suggested pkgs to install: $1" 1.154 + for pkg in $1 ; do 1.155 + # Avoid reinstall 1.156 + if [ ! -d /var/lib/tazpkg/installed/"$pkg" ]; then 1.157 + echo -n " Would you like to install pkg: $pkg (y/N) ? "; read anser 1.158 + if [ "$anser" == "y" ]; then 1.159 + tazpkg get-install "$pkg" --forced 1.160 + if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then 1.161 + UDEV_RULES="yes" 1.162 + fi 1.163 + fi 1.164 + fi 1.165 + done 1.166 +} 1.167 + 1.168 +add_all_user_to_group() 1.169 +{ 1.170 + USERS=`grep /home /etc/passwd | cut -d: -f1` 1.171 + #echo "checking $USERS in $GROUP" 1.172 + for grp in $GROUP ; do 1.173 + for user in $USERS ; do 1.174 + if ! grep -q "$grp.*$user.*" /etc/group ; then 1.175 + echo "adding $user to $grp" 1.176 + addgroup "$user" "$grp" 1.177 + fi 1.178 + done 1.179 + done 1.180 +} 1.181 + 1.182 +find_usb_device() 1.183 +{ 1.184 + case "$DEVICE" in 1.185 + printer) PATTERN="Cls=00" ;; 1.186 + scanner) PATTERN="Cls=00" ;; 1.187 + camera) PATTERN="Cls=00" ;; 1.188 + bluetooth) PATTERN="Cls=e0" ;; 1.189 + esac 1.190 + 1.191 + if [ -f /proc/bus/usb/devices ]; then 1.192 + # no vendor entry in dmesg ?? 1.193 + #dmesglogs=`dmesg | tail -20` 1.194 + DETECTED="no" 1.195 + count=1 1.196 + 1.197 + # assume device to be in last 3 entries; use tac 1.198 + DEVICES_LIST=`cat /proc/bus/usb/devices | grep ^[TDP] | grep -B1 -A1 "$PATTERN" | grep -i vendor | \ 1.199 + awk ' { print $2,$3 } ' | sed 's/ / /'|sed 's/Vendor=//' | sed 's/ProdID=//' | tail -3` 1.200 + echo "Detected USB Device : Vendor : Product" 1.201 + echo "========================================" 1.202 + echo "$DEVICES_LIST" | while read line 1.203 + do 1.204 + vendorid=`echo "$line" | awk '{ print $1 }'` 1.205 + productid=`echo "$line" | awk '{ print $2 }'` 1.206 + vendor=`zcat /usr/share/misc/usb.ids.gz | grep $vendorid | head -1` 1.207 + 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' ` 1.208 + echo " $count) Vendor : $vendor " 1.209 + echo " Product : $product" 1.210 + echo "========================================" 1.211 + count=`expr $count + 1` 1.212 + done 1.213 + # confirm (use dmesg or some other way to automate this) 1.214 + confirm_device 1.215 + fi 1.216 +} 1.217 + 1.218 +confirm_device() 1.219 +{ 1.220 + echo -n " Which no. is your $DEVICE shown in the above lines (1,2,3,none); ? "; read choice 1.221 + 1.222 + case "$choice" in 1.223 + [nN*]) DETECTED="no" ;; 1.224 + 1.225 + *) dev=`echo "$DEVICES_LIST" | head -$choice | tail -1` 1.226 + vendorid=`echo "$dev" | awk '{ print $1 }'` 1.227 + productid=`echo "$dev" | awk '{ print $2 }'` 1.228 + bus=`grep -B2 ".*$vendorid.*$productid" /proc/bus/usb/devices| grep Bus` 1.229 + busno=` echo $bus| awk '{ print $2 }' |cut -d "=" -f 2` 1.230 + deviceno=`echo $bus| awk '{ print $8 }' ` 1.231 + HP=`echo $vendor | grep -q -i "Hewlett"` 1.232 + DETECTED="yes" 1.233 + ;; 1.234 + esac 1.235 + 1.236 + 1.237 +} 1.238 + 1.239 +hputil() 1.240 +{ 1.241 + if [ "$HP" == "1" ]; then 1.242 + install "hplip" 1.243 + echo "" 1.244 + echo -n " Do you want to use hp-setup utility (y/N) ? "; read choice 1.245 + if [ "$choice" == "y" ]; then 1.246 + hp-setup 1.247 + fi 1.248 + fi 1.249 +} 1.250 + 1.251 +# udev now should do this correctly 1.252 +fix_usb_permissions() 1.253 +{ 1.254 + grp=$1 1.255 + if [ "$DETECTED" == "yes" ]; then 1.256 + if ls /dev/bus/usb/*$busno/*$deviceno ; then 1.257 + chmod 666 /dev/bus/usb/*$busno/*$deviceno 1.258 + chgrp $grp /dev/bus/usb/*$busno/*$deviceno 1.259 + echo "========================================" 1.260 + echo -e "\033[1m Verify $DEVICE Permissions \033[0m " 1.261 + echo " Your $DEVICE must be in $grp group with 666 permissions" 1.262 + ls -l /dev/bus/usb/*$busno/*$deviceno 1.263 + echo "========================================" 1.264 + fi 1.265 + fi 1.266 + 1.267 +} 1.268 + 1.269 +fix_parallel_permissions() 1.270 +{ 1.271 + if [ -f /usr/lib/cups/backend/parallel ] ; then 1.272 + chmod 0755 /usr/lib/cups/backend/parallel 1.273 + fi 1.274 +} 1.275 + 1.276 +load_modules() 1.277 +{ 1.278 + tazhw detect-pci 1.279 + tazhw detect-usb 1.280 + sleep 1 1.281 +} 1.282 + 1.283 +udev() 1.284 +{ 1.285 + 1.286 + if [ "$UDEV_RULES" == "yes" ]; then 1.287 + echo "new udev rules are added by a package" 1.288 + udevadm trigger 1.289 + sleep 2 1.290 + fi 1.291 + 1.292 +} 1.293 + 1.294 +xorg() 1.295 +{ 1.296 + 1.297 + [ -x /usr/bin/Xorg ] || install "xorg" 1.298 + echo "Auto configuring Xorg.." 1.299 + # Xorg auto configuration. 1.300 + if [ ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then 1.301 + echo "Configuring Xorg..." 1.302 + # generate xorg.conf if no xorg.conf (shifting from xvesa to xorg) 1.303 + Xorg -configure 1.304 + mv -f /root/xorg.conf.new /etc/X11/xorg.conf 1.305 + sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf 1.306 + sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf 1.307 + tazx config-xorg 1.308 + fi 1.309 + 1.310 +} 1.311 + 1.312 +wvdialbox() 1.313 +{ 1.314 + # setup your modem 1.315 + #wvdialconf 1.316 + echo "====================================" 1.317 + #set username, password, pin 1.318 + #echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin" 1.319 + if [ ! -f /etc/wvdial.conf ]; then 1.320 + APN="apn.yournet.net" 1.321 + PHONE="*99#" 1.322 + USERNAME="user" 1.323 + PASSWORD="passwd" 1.324 + PIN="9999" 1.325 + echo "[Dialer slitaz]" > /etc/wvdial.conf 1.326 + echo "Phone = $PHONE" >> /etc/wvdial.conf 1.327 + echo "Username = $USERNAME" >> /etc/wvdial.conf 1.328 + echo "Password = $PASSWORD" >> /etc/wvdial.conf 1.329 + echo "Stupid Mode = 1" >> /etc/wvdial.conf 1.330 + echo "Dial Command = ATDT" >> /etc/wvdial.conf 1.331 + [ -n "$MODEM" ] || MODEM="/dev/ttyUSB0" 1.332 + echo "Modem = $MODEM" >> /etc/wvdial.conf 1.333 + echo "Baud = 460800" >> /etc/wvdial.conf 1.334 + echo "Init1 = ATZ " >> /etc/wvdial.conf 1.335 + echo "Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" >> /etc/wvdial.conf 1.336 + echo "Init3 = AT+CGDCONT=1,\"IP\", \"$APN\"" >> /etc/wvdial.conf 1.337 + echo "ISDN = 0" >> /etc/wvdial.conf 1.338 + echo "Modem Type = Analog Modem" >> /etc/wvdial.conf 1.339 + echo "" >> /etc/wvdial.conf 1.340 + echo "" >> /etc/wvdial.conf 1.341 + echo "[Dialer pin]" >> /etc/wvdial.conf 1.342 + echo "Modem = $MODEM" >> /etc/wvdial.conf 1.343 + echo "Init4 = AT+CPIN=$PIN" >> /etc/wvdial.conf 1.344 + fi 1.345 + #<action>sed -i "s/^\[Dialer.*/[Dialer slitaz]/" /etc/wvdial.conf</action> 1.346 + #DIALER=`grep Dialer /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3` 1.347 + #DIALER=`grep -B1 AT+CPIN /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3` 1.348 + 1.349 +MAIN_DIALOG=" 1.350 +<window title=\"Wvdial Box\" icon-name=\"applications-internet\"> 1.351 +<vbox> 1.352 + 1.353 +" 1.354 + MAIN_DIALOG=${MAIN_DIALOG}' 1.355 + 1.356 + <hbox> 1.357 + <text use-markup="true"> 1.358 + <label>"<b>Phone Number: </b>"</label> 1.359 + </text> 1.360 + <entry> 1.361 + <input>cat /etc/wvdial.conf | grep ^Phone | cut -d "=" -f2 | tr -d "[\" ]"</input> 1.362 + <variable>PHONE</variable> 1.363 + </entry> 1.364 + </hbox> 1.365 + <hbox> 1.366 + <text use-markup="true"> 1.367 + <label>"<b>Username: </b>"</label> 1.368 + </text> 1.369 + <entry> 1.370 + <input>cat /etc/wvdial.conf | grep ^Username | cut -d "=" -f2 | tr -d "[\" ]"</input> 1.371 + <variable>USERNAME</variable> 1.372 + </entry> 1.373 + </hbox> 1.374 + <hbox> 1.375 + <text use-markup="true"> 1.376 + <label>"<b>Password: </b>"</label> 1.377 + </text> 1.378 + <entry visibility="false"> 1.379 + <input>cat /etc/wvdial.conf | grep ^Password | cut -d "=" -f2 | tr -d "[\" ]"</input> 1.380 + <variable>PASSWORD</variable> 1.381 + </entry> 1.382 + </hbox> 1.383 + <hbox> 1.384 + <text use-markup="true"> 1.385 + <label>"<b>Pin (if required):</b>"</label> 1.386 + </text> 1.387 + <entry visibility="false"> 1.388 + <input>cat /etc/wvdial.conf | grep AT+CPIN= | cut -d "=" -f3 | tr -d "[\" ]"</input> 1.389 + <variable>PIN</variable> 1.390 + </entry> 1.391 + </hbox> 1.392 + <hbox> 1.393 + <text use-markup="true"> 1.394 + <label>"<b>Modem: </b>"</label> 1.395 + </text> 1.396 + <entry> 1.397 + <input>cat /etc/wvdial.conf | grep ^Modem.*/dev.* | cut -d "=" -f2 | tr -d "[\" ]"|uniq</input> 1.398 + <variable>MODEM</variable> 1.399 + </entry> 1.400 + </hbox> 1.401 + <hbox> 1.402 + <text use-markup="true"> 1.403 + <label>"<b>Access Point Name (APN):</b>"</label> 1.404 + </text> 1.405 + <entry> 1.406 + <input>cat /etc/wvdial.conf | grep AT+CGDCONT | cut -d "," -f3 | tr -d "[\" ]"</input> 1.407 + <variable>APN</variable> 1.408 + </entry> 1.409 + </hbox> 1.410 + 1.411 + 1.412 + <hbox> 1.413 + <text use-markup="true"> 1.414 + <label>" 1.415 +<b>You must save your account info before dialing </b>"</label> 1.416 + </text> 1.417 + </hbox> 1.418 + <hbox> 1.419 + <button> 1.420 + <label>/etc/wvdial.conf</label> 1.421 + <input file icon="accessories-text-editor"></input> 1.422 + <action>leafpad /etc/wvdial.conf</action> 1.423 + <action>refresh:PHONE</action> 1.424 + <action>refresh:USERNAME</action> 1.425 + <action>refresh:PASSWORD</action> 1.426 + <action>refresh:PIN</action> 1.427 + <action>refresh:APN</action> 1.428 + <action>refresh:MODEM</action> 1.429 + </button> 1.430 + <button> 1.431 + <label>Save Configuration</label> 1.432 + <input file icon="document-save"></input> 1.433 + <action>sed -i "s/^Phone.*/Phone = $PHONE/ " /etc/wvdial.conf</action> 1.434 + <action>sed -i "s/^Username.*/Username = $USERNAME/ " /etc/wvdial.conf</action> 1.435 + <action>sed -i "s/^Password.*/Password = $PASSWORD/ " /etc/wvdial.conf</action> 1.436 + <action>sed -i "s/.*AT+CPIN=.*/Init4 = AT+CPIN=$PIN/ " /etc/wvdial.conf</action> 1.437 + <action>sed -i "s/.*AT+CGDCONT=.*/Init3 = AT+CGDCONT=1,\"IP\", \"$APN\" /" /etc/wvdial.conf </action> 1.438 + <action>sed -i "s:^Modem.*/dev.*:Modem = $MODEM: " /etc/wvdial.conf</action> 1.439 + </button> 1.440 + 1.441 + </hbox> 1.442 + <hbox> 1.443 + <button> 1.444 + <label>Dial Pin Once </label> 1.445 + <input file icon="forward"></input> 1.446 + <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial pin; sleep 5"</action> 1.447 + </button> 1.448 + <button> 1.449 + <label>Start Dialing </label> 1.450 + <input file icon="forward"></input> 1.451 + <action>xterm -geometry 80x16 -title "Wvdial" -e "echo \"Bringing eth0 down...\"; ifconfig eth0 down; ifconfig eth1 down; echo \"Dialing...\"; wvdial slitaz; sleep 5"</action> 1.452 + </button> 1.453 + </hbox> ' 1.454 + 1.455 + 1.456 +export MAIN_DIALOG=${MAIN_DIALOG}" 1.457 +</vbox> 1.458 +</window>" 1.459 + gtkdialog --center --program=MAIN_DIALOG 1.460 +} 1.461 + 1.462 + 1.463 + 1.464 + 1.465 +setup() 1.466 +{ 1.467 + case "$DEVICE" in 1.468 + printer) 1.469 + load_modules 1.470 + udev 1.471 + # check parallel or usb printer 1.472 + if [ -f /proc/sys/dev/parport/parport*/autoprobe* ] ; then 1.473 + fix_parallel_permissions 1.474 + DETECTED="yes" 1.475 + else 1.476 + find_usb_device 1.477 + fix_usb_permissions "lp" 1.478 + fi 1.479 + #lpinfo -v 1.480 + if [ "$DETECTED" == "yes" ]; then 1.481 + echo "" 1.482 + echo -n " Do you want to start cups (y/N) ? "; read anser 1.483 + echo "" 1.484 + if [ "$anser" == "y" ]; then 1.485 + /etc/init.d/cupsd start 1.486 + sleep 2 1.487 + browser http://localhost:631/ 1.488 + else 1.489 + echo "" 1.490 + echo "====================================" 1.491 + echo -e "Start \033[1m cups \033[0m using :" 1.492 + echo "/etc/init.d/cupsd start" 1.493 + echo "browser http://localhost:631/" 1.494 + echo "====================================" 1.495 + fi 1.496 + else 1.497 + failed 1.498 + fi 1.499 + ;; 1.500 + scanner) 1.501 + load_modules 1.502 + udev 1.503 + find_usb_device 1.504 + fix_usb_permissions "scanner" 1.505 + 1.506 + if [ "$DETECTED" == "yes" ]; then 1.507 + #hputil 1.508 + echo "" 1.509 + echo -n " Do you want to start scanner (y/N) ? "; read anser 1.510 + echo "" 1.511 + if [ "$anser" == "y" ]; then 1.512 + sane-find-scanner # to verify scanner has been found 1.513 + scanimage -L # List scanners 1.514 + xsane #scanner application 1.515 + else 1.516 + echo "" 1.517 + echo "====================================" 1.518 + echo -e "Following \033[1m Scanner commands \033[0m may be of help" 1.519 + echo "sane-find-scanner # to verify scanner has been found" 1.520 + echo "xsane #scanner application" 1.521 + echo "====================================" 1.522 + fi 1.523 + else 1.524 + failed 1.525 + fi 1.526 + ;; 1.527 + webcam) 1.528 + load_modules 1.529 + udev 1.530 + 1.531 + if [ -n "`ls /dev/video0`" ] ; then 1.532 + # fix permissions 1.533 + chmod 666 /dev/video0 1.534 + # ls -l /dev/video0 1.535 + 1.536 + if [ -d /var/lib/tazpkg/installed/mplayer-svn ]; then 1.537 + echo "" 1.538 + echo -n " Would you like to test webcam (y/N) ? "; read anser 1.539 + echo "" 1.540 + if [ "$anser" == "y" ]; then 1.541 + mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 & 1.542 + fi 1.543 + else 1.544 + echo "" 1.545 + echo -n " Would you like to test webcam by installing mplayer-svn (y/N) ? "; read anser 1.546 + echo "" 1.547 + if [ "$anser" == "y" ]; then 1.548 + install mplayer-svn 1.549 + mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 & 1.550 + else 1.551 + echo "" 1.552 + echo "============================" 1.553 + echo "webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view" 1.554 + echo "============================" 1.555 + fi 1.556 + fi 1.557 + else 1.558 + failed 1.559 + fi 1.560 + ;; 1.561 + camera) 1.562 + udev 1.563 + find_usb_device 1.564 + fix_usb_permissions "camera" 1.565 + 1.566 + if [ "$DETECTED" == "yes" ]; then 1.567 + echo "" 1.568 + echo -n " Do you want to check if gphoto2 can talk to your camera (y/N) ? "; read anser 1.569 + echo "" 1.570 + if [ "$anser" == "y" ]; then 1.571 + # Show if the camera is detected 1.572 + gphoto2 --auto-detect 1.573 + echo -e " Do you want to test importing photos (y/N) ? "; read choice 1.574 + if [ "$choice" == "y" ]; then 1.575 + mkdir -p ~/Images/Photos 1.576 + cd ~/Images/Photos 1.577 + gphoto2 --get-all-files 1.578 + pcmanfm ~/Images/Photos 1.579 + fi 1.580 + echo "" 1.581 + else 1.582 + echo "" 1.583 + echo "====================================" 1.584 + echo "camera is set up; please use gphoto2 to import photos" 1.585 + echo "Quick start guide: http://www.gphoto.org/doc/manual/using-gphoto2.html" 1.586 + echo "====================================" 1.587 + fi 1.588 + else 1.589 + failed 1.590 + fi 1.591 + ;; 1.592 + bluetooth) 1.593 + untested 1.594 + load_modules 1.595 + udev 1.596 + 1.597 + echo -n " Do you want to see if the bluetooth is working (y/N) ? "; read anser 1.598 + echo "" 1.599 + if [ "$anser" == "y" ]; then 1.600 + # sanity check: btusb is not loaded automagically for unknown reasons 1.601 + if ! lsmod | grep -q btusb ; then 1.602 + modprobe btusb 1.603 + fi 1.604 + echo "========================================" 1.605 + echo -e "\033[1m Bluetooth \033[0m interfaces" 1.606 + echo "" 1.607 + lsusb | grep Bluetooth 1.608 + # udev should run bluetoothd automatically 1.609 + #/usr/sbin/bluetoothd 1.610 + hciconfig -a 1.611 + hcitool dev 1.612 + hcitool scan 1.613 + echo "========================================" 1.614 + echo -e "Following \033[1m Bluetooth commands \033[0m may be of help " 1.615 + echo "" 1.616 + echo " modprobe btusb" 1.617 + echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon" 1.618 + echo " hciconfig -a" 1.619 + echo " \"hcitool dev\" : checking local bluetooth devices..." 1.620 + echo " \"hcitool scan\" : scanning remote bluetooth devices..." 1.621 + echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be" 1.622 + echo "========================================" 1.623 + else 1.624 + echo "" 1.625 + echo "========================================" 1.626 + echo -e "Following \033[1m Bluetooth commands \033[0m may be of help" 1.627 + echo "" 1.628 + echo " modprobe btusb" 1.629 + echo " lsusb | grep Bluetooth" 1.630 + echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon" 1.631 + echo " hciconfig -a" 1.632 + # Show if the bluetooth is detected 1.633 + echo " hcitool dev # for checking local devices" 1.634 + echo " hcitool scan # for scanning remote devices" 1.635 + echo "" 1.636 + echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be" 1.637 + echo "" 1.638 + echo "========================================" 1.639 + fi 1.640 + ;; 1.641 + 3g-modem) 1.642 + untested 1.643 + load_modules 1.644 + udev 1.645 + echo "" 1.646 + echo "====================================" 1.647 + echo "list detected devices" 1.648 + # ls /dev/ttyUSB* /dev/ttyACM* /dev/modem 1.649 + 1.650 + if [ -n "`ls /dev/ttyUSB*`" -o -n "`ls /dev/ttyACM*`" ] ; then 1.651 + echo "Detected Modem at:" 1.652 + echo "`ls /dev/ttyUSB*`" 1.653 + echo -n " Do you want to configure wvdial (y/N) ? "; read anser 1.654 + echo "" 1.655 + if [ "$anser" == "y" ]; then 1.656 + wvdialbox 1.657 + else 1.658 + echo "====================================" 1.659 + echo "wvdialconf" 1.660 + echo -e "Edit \033[1m /etc/wvdial.conf \033[0m for phone number, login name, password and pin" 1.661 + echo "wvdial dialername" 1.662 + #nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf 1.663 + echo -e " Add DNS adress of your provider in : \033[1m /etc/resolv.conf \033[0m " 1.664 + echo "====================================" 1.665 + fi 1.666 + else 1.667 + failed 1.668 + fi 1.669 + ;; 1.670 + firewall) echo "Setting IPTABLES_RULES to yes in /etc/firewall.conf" 1.671 + sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/firewall.conf 1.672 + # default is "start" 1.673 + if [ "$STOP" == "yes" ] ; then 1.674 + /etc/init.d/firewall stop 1.675 + else 1.676 + /etc/init.d/firewall start 1.677 + if [ -d /var/lib/tazpkg/installed/nmap ]; then 1.678 + echo "====================================" 1.679 + echo "Probing for open ports..." 1.680 + nmap localhost 1.681 + echo "====================================" 1.682 + fi 1.683 + echo "adding firewall daemon to start automatically at boot" 1.684 + run_daemon_startup "firewall" 1.685 + echo "====================================" 1.686 + fi 1.687 + 1.688 + ;; 1.689 + nvidia) if [ "$NON_FREE" == "yes" ] ; then 1.690 + if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-nv ]; then 1.691 + mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf 1.692 + tazpkg remove xorg-xf86-video-nv 1.693 + fi 1.694 + load_modules 1.695 + #xorg 1.696 + echo -n " Do you want to configure X using non-free nvidia driver (y/N) ? "; read anser 1.697 + echo "" 1.698 + if [ "$anser" == "y" ]; then 1.699 + echo "your config is backed up at /etc/X11/xorg.conf.backup" 1.700 + echo "if nvidia fails; please use your backed up xorg.conf" 1.701 + nvidia-xconfig 1.702 + 1.703 + if ! grep -q "NoLogo" /etc/X11/xorg.conf ; then 1.704 + echo "adding to xorg.conf: Option \"NoLogo\" \"True\"" 1.705 + sed -i 's/BoardName\(.*\)/Boardname \1 \n Option "NoLogo" "True" /' /etc/X11/xorg.conf 1.706 + fi 1.707 + 1.708 + # mesa-demos to check if acceleration is working 1.709 + echo "Checking if nvidia is working ..." 1.710 + glxinfo |grep rendering 1.711 + 1.712 + echo "================================" 1.713 + echo -e "\033[1m Configure nvidia settings :\033[0m " 1.714 + nvidia-settings 1.715 + echo "================================" 1.716 + else 1.717 + echo "" 1.718 + echo "================================" 1.719 + echo "nvidia-xconfig" 1.720 + echo "glxinfo |grep rendering # test nvidia" 1.721 + echo "Use: nvidia-settings utility to configure your settings if necessary" 1.722 + echo "Option \"NoLogo\" \"True\"" 1.723 + echo "================================" 1.724 + fi 1.725 + else 1.726 + if [ -d /var/lib/tazpkg/installed/nvidia ]; then 1.727 + mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf 1.728 + tazpkg remove nvidia 1.729 + fi 1.730 + load_modules 1.731 + #xorg 1.732 + echo -n " Do you want to configure X using free nvidia driver (y/N) ? "; read anser 1.733 + echo "" 1.734 + if [ "$anser" == "y" ]; then 1.735 + echo "" 1.736 + echo "================================" 1.737 + #backup your current config 1.738 + cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup 1.739 + echo "your config is backed up at /etc/X11/xorg.conf.backup" 1.740 + echo "if nvidia fails; please use your backed up xorg.conf" 1.741 + echo "" 1.742 + echo "Replace vesa driver with nv in /etc/X11/xorg.conf" 1.743 + # free nvidia driver is called nv 1.744 + sed -i 's/vesa/nv/' /etc/X11/xorg.conf 1.745 + # mesa-demos to check if acceleration is working 1.746 + echo "Checking if nvidia is working ..." 1.747 + glxinfo |grep rendering 1.748 + echo "================================" 1.749 + fi 1.750 + fi 1.751 + ;; 1.752 + ati) untested 1.753 + if [ "$NON_FREE" == "yes" ] ; then 1.754 + if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-ati ]; then 1.755 + mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf 1.756 + tazpkg remove xorg-xf86-video-ati 1.757 + fi 1.758 + load_modules 1.759 + #xorg 1.760 + echo -n " Do you want to configure X using non-free catalyst ati(radeon) driver (y/N) ? "; read anser 1.761 + echo "" 1.762 + if [ "$anser" == "y" ]; then 1.763 + #backup your current config 1.764 + cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup 1.765 + echo "your config is backed up at /etc/X11/xorg.conf.backup" 1.766 + echo "if ati fails; please use your backed up xorg.conf" 1.767 + # add fglrx driver to xorg.conf 1.768 + aticonfig --initial --input=/etc/X11/xorg.conf 1.769 + # mesa-demos to check if acceleration is working 1.770 + echo "Checking if ati catalyst is working ..." 1.771 + glxinfo |grep rendering 1.772 + else 1.773 + echo "" 1.774 + echo "================================" 1.775 + echo -e "\033[1m Configuration :\033[0m " 1.776 + echo "Use: aticonfig utility to configure xorg.conf settings if necessary" 1.777 + echo "aticonfig --initial --input=/etc/X11/xorg.conf" 1.778 + echo "restart xorg" 1.779 + echo "glxinfo |grep rendering" 1.780 + echo "================================" 1.781 + fi 1.782 + else 1.783 + if [ -d /var/lib/tazpkg/installed/catalyst ]; then 1.784 + mv /etc/X11/xorg.conf.backup /etc/X11/xorg.conf 1.785 + tazpkg remove catalyst 1.786 + fi 1.787 + load_modules 1.788 + #xorg 1.789 + echo -n " Do you want to configure X using free ati (radeon) driver (y/N) ? "; read anser 1.790 + echo "" 1.791 + if [ "$anser" == "y" ]; then 1.792 + echo "" 1.793 + echo "================================" 1.794 + #backup your current config 1.795 + cp -a /etc/X11/xorg.conf /etc/X11/xorg.conf.backup 1.796 + echo "your config is backed up at /etc/X11/xorg.conf.backup" 1.797 + echo "if ati fails; please use your backed up xorg.conf" 1.798 + echo "" 1.799 + echo "Replace vesa driver with nv in /etc/X11/xorg.conf" 1.800 + # free ati driver is called radeon 1.801 + sed -i 's/vesa/radeon/' /etc/X11/xorg.conf 1.802 + # mesa-demos to check if acceleration is working 1.803 + echo "Checking if ati radeon is working ..." 1.804 + glxinfo |grep rendering 1.805 + echo "================================" 1.806 + fi 1.807 + fi 1.808 + ;; 1.809 + 1.810 + esac 1.811 +} 1.812 + 1.813 +# What to do. 1.814 +case "$1" in 1.815 + help|usage ) usage ;; 1.816 + wvdial) wvdialbox ;; 1.817 + xorg) xorg;; 1.818 + 1.819 + *) check_root 1.820 + echo "COMMAND OPTIONS: $@" 1.821 + for i in "$@"; do 1.822 + if [ "$i" == "--non-free" ] ; then NON_FREE="yes"; fi 1.823 + if [ "$i" == "--suggested" ] ; then AUTO_INSTALL_SUGGESTED="yes"; fi 1.824 + if [ "$i" == "--confirm" ] ; then CONFIRM_SUGGESTED="yes"; fi 1.825 + if [ "$i" == "stop" ] ; then STOP="yes"; fi 1.826 + done 1.827 + 1.828 + device 1.829 + #untested 1.830 + 1.831 + if [ "$NON_FREE" == "yes" ]; then 1.832 + DEPENDS="$NON_FREE_DEPENDS" 1.833 + fi 1.834 + 1.835 + if [ "$AUTO_INSTALL_SUGGESTED" == "yes" ]; then 1.836 + anser="all" 1.837 + elif [ "$CONFIRM_SUGGESTED" == "yes" ]; then 1.838 + echo "" 1.839 + echo "====================================" 1.840 + echo "Following optional packages can be installed:" 1.841 + echo "" 1.842 + echo "$SUGGESTED" 1.843 + echo "====================================" 1.844 + echo -n " Do you want to install all/few/no optional dependencies (all|few|N) ? "; read anser 1.845 + fi 1.846 + 1.847 + install "$DEPENDS" 1.848 + case $anser in 1.849 + [aA]*|[yY]|1) install "$SUGGESTED" ;; 1.850 + [fF]*|2) confirm_install "$SUGGESTED" ;; 1.851 + *) ;; 1.852 + esac 1.853 + 1.854 + add_all_user_to_group 1.855 + setup ;; 1.856 +esac 1.857 + 1.858 +