slitaz-tools diff tinyutils/hwsetup @ rev 813

Current state, features stabilized and open for bugfixes and translations.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Sep 09 03:27:04 2013 +0300 (2013-09-09)
parents fc41098293ec
children c79e656b37a5
line diff
     1.1 --- a/tinyutils/hwsetup	Fri Apr 26 12:51:26 2013 +0000
     1.2 +++ b/tinyutils/hwsetup	Mon Sep 09 03:27:04 2013 +0300
     1.3 @@ -2,9 +2,12 @@
     1.4  # usage: hwsetup [device]
     1.5  # e.g.,  hwsetup printer
     1.6  # #
     1.7 -# (c) - SliTaz GNU/Linux 2009 - GNU GPL v3
     1.8 +# Copyright (C) 2009-2013 SliTaz GNU/Linux - GNU GPL v3
     1.9  # Authors : Rohit Joshi <jozee@slitaz.org>
    1.10  #
    1.11 +. /lib/libtaz.sh
    1.12 +. /etc/slitaz/slitaz.conf
    1.13 +export TEXTDOMAIN='slitaz-tools' #i18n
    1.14  
    1.15  DEVICE=$1
    1.16  DEPENDS=""
    1.17 @@ -12,33 +15,37 @@
    1.18  CONFIRM_SUGGESTED="no"
    1.19  NON_FREE="no"
    1.20  DETECTED="no"
    1.21 +USB_IDS=/usr/share/misc/usb.ids.gz
    1.22  
    1.23 -usage()
    1.24 -{
    1.25 -	echo -e "\nSliTaz Setup configuration\n
    1.26 -\033[1mUsage: \033[0m `basename $0` [command] [--option]
    1.27 -
    1.28 -\033[1mCommands: \033[0m
    1.29 -  usage		Print this short usage.
    1.30 -  printer	Parallel and USB Printer setup.
    1.31 -  scanner	USB Scanner setup.
    1.32 -  webcam	Integrated and USB webcam setup.
    1.33 -  camera	Digital Camera setup.
    1.34 -  bluetooth	Bluetooth setup.
    1.35 -  3g-modem	3g-modem setup.
    1.36 -  firewall	Start/stop firewall.
    1.37 -  nvidia	Nvidia (non-free/free) setup.
    1.38 -  ati		ATI (non-free/free) setup.
    1.39 -
    1.40 -\033[1mOptions: \033[0m
    1.41 -  --non-free	install non-free packages (nvidia, ati).
    1.42 -  --suggested	auto-install optional dependencies.
    1.43 -  --confirm	confirm before installing optional dependencies\n"
    1.44 +usage() {
    1.45 +	newline
    1.46 +	_ 'SliTaz Setup configuration'
    1.47 +	newline
    1.48 +	boldify $(_n 'Usage:')
    1.49 +	echo "  $(basename $0) [$(_n 'command')] [--$(_n 'option')]"
    1.50 +	newline
    1.51 +	boldify $(_n 'Commands:')
    1.52 +	optlist "\
    1.53 +usage		$(_n 'Print this short usage.')
    1.54 +printer		$(_n 'Parallel and USB Printer setup.')
    1.55 +scanner		$(_n 'USB Scanner setup.')
    1.56 +webcam		$(_n 'Integrated and USB webcam setup.')
    1.57 +camera		$(_n 'Digital Camera setup.')
    1.58 +bluetooth	$(_n 'Bluetooth setup.')
    1.59 +3g-modem	$(_n '3g-modem setup.')
    1.60 +firewall	$(_n 'Start/stop firewall.')
    1.61 +nvidia		$(_n 'Nvidia (non-free/free) setup.')
    1.62 +ati			$(_n 'ATI (non-free/free) setup.')"
    1.63 +	newline
    1.64 +	boldify $(_n 'Options:')
    1.65 +	optlist "\
    1.66 +--nonfree	$(_n 'install non-free packages (nvidia, ati).')
    1.67 +--suggested	$(_n 'auto-install optional dependencies.')
    1.68 +--confirm	$(_n 'confirm before installing optional dependencies')"
    1.69 +	newline
    1.70  }
    1.71  
    1.72 -
    1.73 -run_daemon_startup()
    1.74 -{
    1.75 +run_daemon_startup() {
    1.76  	# Add server to rcS.conf and avoid duplication.
    1.77  	. /etc/rcS.conf
    1.78  	if ! echo "$RUN_DAEMONS" | grep -q "$1"; then
    1.79 @@ -46,421 +53,316 @@
    1.80  	fi
    1.81  }
    1.82  
    1.83 -device()
    1.84 -{
    1.85 +device() {
    1.86 +	SUGGESTED=""
    1.87  	case "$DEVICE" in
    1.88 -  		printer)
    1.89 +		printer)
    1.90  			DEPENDS="$DEPENDS cups cups-pdf usbutils hal-info ghostscript aspell aspell-en"
    1.91  			SUGGESTED="hplip gutenprint foomatic-filters foomatic-db hal-cups-utils foomatic-db-nonfree ufr2 splix"
    1.92  			CONFIRM_SUGGESTED="yes"
    1.93 -			GROUP="lp"
    1.94 -			;;
    1.95 +			GROUP="lp" ;;
    1.96  		scanner)
    1.97  			DEPENDS="$DEPENDS xsane usbutils hal-info"
    1.98  			SUGGESTED="hplip"
    1.99 -			GROUP="scanner lp"
   1.100 -			;;
   1.101 -    	webcam)
   1.102 -    		DEPENDS="$DEPENDS v4l-dvb usbutils hal-info"
   1.103 +			GROUP="scanner lp" ;;
   1.104 +		webcam)
   1.105 +			DEPENDS="$DEPENDS v4l-dvb usbutils hal-info"
   1.106  			SUGGESTED="xorg-xf86-video-v4l linux-video libv4l "
   1.107 -			GROUP="video audio lp"
   1.108 -			;;
   1.109 +			GROUP="video audio lp" ;;
   1.110  		camera)
   1.111 -    	    DEPENDS="$DEPENDS gphoto2 usbutils hal-info"
   1.112 -			SUGGESTED=""
   1.113 -			GROUP="camera lp"
   1.114 -			;;
   1.115 +			DEPENDS="$DEPENDS gphoto2 usbutils hal-info"
   1.116 +			GROUP="camera lp" ;;
   1.117  		bluetooth)
   1.118  			DEPENDS="$DEPENDS bluez usbutils hal-info pygobject dbus-python"
   1.119 -			SUGGESTED=""
   1.120 -			GROUP="lp"
   1.121 -			;;
   1.122 +			GROUP="lp" ;;
   1.123  		3g-modem)
   1.124 -    		DEPENDS="$DEPENDS linux-dialup wvdial pcmciautils usbutils hal-info"
   1.125 -			SUGGESTED=""
   1.126 -			GROUP="dialout lp"
   1.127 -			;;
   1.128 +			DEPENDS="$DEPENDS linux-dialup wvdial pcmciautils usbutils hal-info"
   1.129 +			GROUP="dialout lp" ;;
   1.130  		firewall)
   1.131 -    		DEPENDS="iptables slitaz-tools"
   1.132 +			DEPENDS="iptables slitaz-tools"
   1.133  			SUGGESTED="nmap"
   1.134 -			GROUP=""
   1.135 -			;;
   1.136 +			GROUP="" ;;
   1.137  		nvidia)
   1.138 -    		DEPENDS="mesa mesa-demos linux-agp xorg-xf86-video-nv"
   1.139 -    		NON_FREE_DEPENDS="mesa mesa-demos linux-agp nvidia"
   1.140 -    		SUGGESTED=""
   1.141 -			GROUP="video"
   1.142 -			;;
   1.143 +			DEPENDS="mesa mesa-demos linux-agp xorg-xf86-video-nv"
   1.144 +			NON_FREE_DEPENDS="mesa mesa-demos linux-agp nvidia"
   1.145 +			GROUP="video" ;;
   1.146  		ati)
   1.147 -    		DEPENDS=" xorg-xf86-video-ati mesa-dri-ati mesa-demos"
   1.148 -    		NON_FREE_DEPENDS="mesa mesa-demos mesa-dri linux-agp catalyst"
   1.149 -    		SUGGESTED=""
   1.150 -			GROUP="video"
   1.151 -			;;
   1.152 +			DEPENDS="xorg-xf86-video-ati mesa-dri-ati mesa-demos"
   1.153 +			NON_FREE_DEPENDS="mesa mesa-demos mesa-dri linux-agp catalyst"
   1.154 +			GROUP="video" ;;
   1.155  	esac
   1.156  }
   1.157  
   1.158 -# Check if user is root
   1.159 -check_root()
   1.160 -{
   1.161 -	if test $(id -u) != 0 ; then
   1.162 -		echo -e "\nYou must be root to run `basename $0` with this option."
   1.163 -		echo -e "Please use 'su' and root password to become super-user.\n"
   1.164 -		exit 0
   1.165 -	fi
   1.166 -}
   1.167 -
   1.168 -untested()
   1.169 -{
   1.170 -	echo "=========================================================="
   1.171 -	echo "Due to a lack of compatible hardware for troubleshooting,"
   1.172 -	echo "this $DEVICE device has not been properly tested. Please "
   1.173 -	echo "report any success, failure, bug to SliTaz Labs or Forums."
   1.174 -	echo "=========================================================="
   1.175 +untested() {
   1.176 +	newline; separator
   1.177 +	longline $(_ "Due to a lack of compatible hardware for troubleshooting, \
   1.178 +this \$DEVICE device has not been properly tested. Please report any success, \
   1.179 +failure, bug to SliTaz Bug tracker or Forum.")
   1.180 +	separator; newline
   1.181  	sleep 1
   1.182  }
   1.183  
   1.184 -failed()
   1.185 -{
   1.186 -	echo ""
   1.187 -	echo "======================================"
   1.188 -	echo " Failed to setup $DEVICE"
   1.189 -	echo "======================================"
   1.190 +failed() {
   1.191 +	newline; separator
   1.192 +	_ 'Failed to setup $DEVICE'
   1.193 +	separator; newline
   1.194  	sleep 1
   1.195  }
   1.196 +
   1.197  # Install DEPENDS and/or SUGGESTED
   1.198 -install()
   1.199 -{
   1.200 -	#echo "pkgs to install: $1"
   1.201 +install() {
   1.202  	for pkg in $1 ; do
   1.203 -	   # Avoid reinstall
   1.204 -		if [ ! -d /var/lib/tazpkg/installed/"$pkg" ]; then
   1.205 -			echo "Installing pkg: $pkg"
   1.206 -			tazpkg get-install "$pkg" --forced
   1.207 +		# Avoid reinstall
   1.208 +		if [ ! -d "$INSTALLED/$pkg" ]; then
   1.209 +			_ 'Installing pkg: $pkg'
   1.210 +			tazpkg get-install "$pkg"
   1.211  			if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then
   1.212 -			   UDEV_RULES="yes"
   1.213 +				UDEV_RULES="yes"
   1.214  			fi
   1.215  		fi
   1.216  	done
   1.217 +}
   1.218  
   1.219 -}
   1.220  # Install DEPENDS and/or SUGGESTED
   1.221 -confirm_install()
   1.222 -{
   1.223 -	#echo "Suggested pkgs to install: $1"
   1.224 +confirm_install() {
   1.225  	for pkg in $1 ; do
   1.226 -	   # Avoid reinstall
   1.227 -		if [ ! -d /var/lib/tazpkg/installed/"$pkg" ]; then
   1.228 -			echo -n "Would you like to install pkg: $pkg (y/N) ? "; read anser
   1.229 -			if [ "$anser" == "y" ]; then
   1.230 +		# Avoid reinstall
   1.231 +		if [ ! -d "$INSTALLED/$pkg" ]; then
   1.232 +			_n 'Would you like to install pkg: $pkg'; confirm
   1.233 +			if [ $? == 0 ]; then
   1.234  				tazpkg get-install "$pkg" --forced
   1.235  				if tazpkg list-files "$pkg" | grep -q "/etc/udev" ; then
   1.236 -			   		UDEV_RULES="yes"
   1.237 +					UDEV_RULES="yes"
   1.238  				fi
   1.239  			fi
   1.240  		fi
   1.241  	done
   1.242  }
   1.243  
   1.244 -add_all_user_to_group()
   1.245 -{
   1.246 -	USERS=`grep /home /etc/passwd | cut -d: -f1`
   1.247 +add_all_user_to_group() {
   1.248 +	USERS=$(grep /home /etc/passwd | cut -d: -f1)
   1.249  	#echo "checking $USERS in $GROUP"
   1.250  	for grp in $GROUP ; do
   1.251  		for user in $USERS ; do
   1.252  			if ! grep -q "$grp.*$user.*" /etc/group ; then
   1.253 -				echo "adding $user to $grp"
   1.254 +				_ 'adding $user to $grp'
   1.255  				addgroup "$user" "$grp"
   1.256  			fi
   1.257  		done
   1.258  	done
   1.259  }
   1.260  
   1.261 -find_usb_device()
   1.262 -{
   1.263 +find_usb_device() {
   1.264  	case "$DEVICE" in
   1.265 -  		printer) PATTERN="Cls=00" ;;
   1.266 -  		scanner) PATTERN="Cls=00" ;;
   1.267 -  		camera)  PATTERN="Cls=00" ;;
   1.268 -  		bluetooth) PATTERN="Cls=e0" ;;
   1.269 -  	esac
   1.270 +		printer|scanner|camera) PATTERN="Cls=00" ;;
   1.271 +		bluetooth) PATTERN="Cls=e0" ;;
   1.272 +	esac
   1.273  
   1.274  	if [ -f /proc/bus/usb/devices ]; then
   1.275 -	   # no vendor entry in dmesg ??
   1.276 -	   #dmesglogs=`dmesg | tail -20`
   1.277 -	   DETECTED="no"
   1.278 -	   count=1
   1.279 +		# no vendor entry in dmesg ??
   1.280 +		#dmesglogs=`dmesg | tail -20`
   1.281 +		DETECTED="no"
   1.282 +		count=1
   1.283  
   1.284 -	   # assume device to be in last 3 entries; use tac
   1.285 -	   DEVICES_LIST=`cat /proc/bus/usb/devices | grep ^[TDP] | grep -B1 -A1 "$PATTERN" | grep -i vendor | \
   1.286 -	   awk ' { print $2,$3 } ' | sed 's/ /   /'|sed 's/Vendor=//' | sed 's/ProdID=//' | tail -3`
   1.287 -	   echo "Detected USB Device : Vendor : Product"
   1.288 -	   echo "========================================"
   1.289 -	   echo "$DEVICES_LIST" | while read line
   1.290 -	   do
   1.291 -	      vendorid=`echo "$line" | awk '{ print $1 }'`
   1.292 -	      [ -n "$vendorid" ] || continue
   1.293 -	      productid=`echo "$line" | awk '{ print $2 }'`
   1.294 -	      vendor=`zcat /usr/share/misc/usb.ids.gz | grep $vendorid | head -1`
   1.295 -	   	  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.296 -	   	  echo " $count) Vendor  : $vendor "
   1.297 -	   	  echo "    Product : $product"
   1.298 -	   	  echo "========================================"
   1.299 -	   	  count=`expr $count + 1`
   1.300 -	   done
   1.301 -	    # confirm (use dmesg or some other way to automate this)
   1.302 -	   	  confirm_device
   1.303 +		# assume device to be in last 3 entries; use tac
   1.304 +		DEVICES_LIST=$(cat /proc/bus/usb/devices | grep ^[TDP] | \
   1.305 +			grep -B1 -A1 "$PATTERN" | grep -i vendor | awk ' { print $2,$3 } ' | \
   1.306 +			sed 's/ /   /'|sed 's/Vendor=//' | sed 's/ProdID=//' | tail -3)
   1.307 +		_ 'Detected USB Device : Vendor : Product'
   1.308 +		separator
   1.309 +		echo "$DEVICES_LIST" | while read line
   1.310 +		do
   1.311 +			vendorid=$(echo "$line" | awk '{ print $1 }')
   1.312 +			[ -n "$vendorid" ] || continue
   1.313 +			productid=$(echo "$line" | awk '{ print $2 }')
   1.314 +			vendor=$(zcat $USB_IDS | grep $vendorid | head -1)
   1.315 +			product=$(zcat $USB_IDS | grep $productid | head -2 | \
   1.316 +				awk ' { print $1,$2,$3,$4} ' | sed -e :a -e '$!N;s/\n/ ; /;ta')
   1.317 +			_ " $count) Vendor  : $vendor "
   1.318 +			_ "    Product : $product"
   1.319 +			separator
   1.320 +			count=$(expr $count + 1)
   1.321 +		done
   1.322 +		# confirm (use dmesg or some other way to automate this)
   1.323 +		confirm_device
   1.324  	fi
   1.325  }
   1.326  
   1.327 -confirm_device()
   1.328 -{
   1.329 -	echo -n "Which no. is your $DEVICE shown in the above lines (1,2,3,none);  ? "; read choice
   1.330 -
   1.331 +confirm_device() {
   1.332 +	_ "Which no. is your $DEVICE shown in the above lines (1,2,3,none)? "; read choice
   1.333  	case "$choice" in
   1.334 -	 [nN*]) DETECTED="no" ;;
   1.335 -
   1.336 -	 *) 	dev=`echo "$DEVICES_LIST" | head -$choice | tail -1`
   1.337 -			vendorid=`echo "$dev" | awk '{ print $1 }'`
   1.338 -			productid=`echo "$dev" | awk '{ print $2 }'`
   1.339 -			bus=`grep -B2 ".*$vendorid.*$productid" /proc/bus/usb/devices| grep Bus`
   1.340 -			busno=` echo $bus|  awk '{ print $2 }' |cut -d "=" -f 2`
   1.341 -			deviceno=`echo $bus| awk '{ print $8 }' `
   1.342 -			HP=`echo $vendor | grep -q -i "Hewlett"`
   1.343 +		1|2|3)
   1.344 +			dev=$(echo "$DEVICES_LIST" | head -$choice | tail -1)
   1.345 +			vendorid=$(echo "$dev" | awk '{ print $1 }')
   1.346 +			productid=$(echo "$dev" | awk '{ print $2 }')
   1.347 +			bus=$(grep -B2 ".*$vendorid.*$productid" /proc/bus/usb/devices | grep Bus)
   1.348 +			busno=$(echo $bus | awk '{ print $2 }' | cut -d"=" -f2)
   1.349 +			deviceno=$(echo $bus | awk '{ print $8 }')
   1.350 +			HP=$(echo $vendor | grep -q -i "Hewlett")
   1.351  			DETECTED="yes"
   1.352  			;;
   1.353 +		*)
   1.354 +			DETECTED="no" ;;
   1.355  	esac
   1.356 -
   1.357 -
   1.358  }
   1.359  
   1.360 -hputil()
   1.361 -{
   1.362 +hputil() {
   1.363  	if [ "$HP" == "1" ]; then
   1.364 -	 	install "hplip"
   1.365 -		echo ""
   1.366 -		echo -n "Do you want to use hp-setup utility (y/N) ? "; read choice
   1.367 -		if [ "$choice" == "y" ]; then
   1.368 -		  hp-setup
   1.369 +		install "hplip"
   1.370 +		newline
   1.371 +		_n 'Do you want to use hp-setup utility'; confirm
   1.372 +		if [ $? == 0 ]; then
   1.373 +			hp-setup
   1.374  		fi
   1.375  	fi
   1.376  }
   1.377  
   1.378  # udev now should do this correctly
   1.379 -fix_usb_permissions()
   1.380 -{
   1.381 +fix_usb_permissions() {
   1.382  	grp=$1
   1.383  	if [ "$DETECTED" == "yes" ]; then
   1.384  		if ls /dev/bus/usb/*$busno/*$deviceno ; then
   1.385  			chmod 666 /dev/bus/usb/*$busno/*$deviceno
   1.386  			chgrp $grp /dev/bus/usb/*$busno/*$deviceno
   1.387 -			echo "========================================"
   1.388 -			echo -e "\033[1m Verify $DEVICE Permissions \033[0m "
   1.389 -			echo "Your $DEVICE must be in $grp group with 666 permissions"
   1.390 +			newline; separator
   1.391 +			boldify "$(_ 'Verify $DEVICE Permissions')"
   1.392 +			_ 'Your $DEVICE must be in $grp group with rw-rw-rw- permissions'
   1.393  			ls -l /dev/bus/usb/*$busno/*$deviceno
   1.394 -			echo "========================================"
   1.395 +			separator; newline
   1.396  		fi
   1.397  	fi
   1.398 -
   1.399  }
   1.400  
   1.401 -fix_parallel_permissions()
   1.402 -{
   1.403 - 	if [ -f /usr/lib/cups/backend/parallel ] ; then
   1.404 - 		chmod 0755 /usr/lib/cups/backend/parallel
   1.405 - 	fi
   1.406 +fix_parallel_permissions() {
   1.407 +	if [ -f /usr/lib/cups/backend/parallel ] ; then
   1.408 +		chmod 0755 /usr/lib/cups/backend/parallel
   1.409 +	fi
   1.410  }
   1.411  
   1.412 -load_modules()
   1.413 -{
   1.414 +load_modules() {
   1.415  	tazhw detect-pci
   1.416  	tazhw detect-usb
   1.417  	sleep 1
   1.418  }
   1.419  
   1.420 -udev()
   1.421 -{
   1.422 -
   1.423 +udev() {
   1.424  	if [ "$UDEV_RULES" == "yes" ]; then
   1.425 -		echo "New udev rules are added by a package"
   1.426 +		_ 'New udev rules are added by a package'
   1.427  		udevadm trigger
   1.428  		sleep 2
   1.429  	fi
   1.430 -
   1.431  }
   1.432  
   1.433 -xorg()
   1.434 -{
   1.435 -
   1.436 +xorg() {
   1.437  	[ -x /usr/bin/Xorg ] || install "xorg"
   1.438 -	echo "Auto configuring Xorg.."
   1.439 +	_ 'Auto configuring Xorg...'
   1.440  	# Xorg auto configuration.
   1.441  	if [ ! -d /etc/X11/xorg.conf.d -a -x /usr/bin/Xorg ]; then
   1.442 -		echo "Configuring Xorg..."
   1.443 +		_ 'Configuring Xorg...'
   1.444  		# Populate /etc/X11/xorg.conf.d if it doesn't exist.
   1.445  		sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
   1.446 -		sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
   1.447 +		sed -i 's|^xserver_arguments|\#xserver_arguments|' /etc/slim.conf
   1.448  		tazx config-xorg
   1.449  	fi
   1.450 -
   1.451  }
   1.452  
   1.453 -wvdialbox()
   1.454 -{
   1.455 +get_wvdial_vars() {
   1.456 +	PHONE=$(   grep ^Phone         $CONF | cut -d= -f2 | tr -d '[" ]')
   1.457 +	USERNAME=$(grep ^Username      $CONF | cut -d= -f2 | tr -d '[" ]')
   1.458 +	PASSWORD=$(grep ^Password      $CONF | cut -d= -f2 | tr -d '[" ]')
   1.459 +	PIN=$(     grep AT+CPIN=       $CONF | cut -d= -f3 | tr -d '[" ]')
   1.460 +	MODEM=$(   grep ^Modem.*/dev.* $CONF | cut -d= -f2 | tr -d '[" ]' | uniq)
   1.461 +	APN=$(     grep AT+CGDCONT     $CONF | cut -d, -f3 | tr -d '[" ]')
   1.462 +	[ "x$USERNAME" == "x''" ] && USERNAME=
   1.463 +	[ "x$PASSWORD" == "x''" ] && PASSWORD=
   1.464 +}
   1.465 +
   1.466 +set_wvdial_vars() {
   1.467 +	# wvdial needs something right the equal sign
   1.468 +	[ x$USERNAME == x ] && USERNAME="''"
   1.469 +	[ x$PASSWORD == x ] && PASSWORD="''"
   1.470 +	sed 's|^Phone.*|Phone = '$PHONE'|; s|^Username.*|Username = '$USERNAME'|; \
   1.471 +	s|^Password.*|Password = '$PASSWORD'|; s|.*AT+CPIN=.*|Init4 = AT+CPIN='$PIN'|; \
   1.472 +	s|.*AT+CGDCONT=.*|Init3 = AT+CGDCONT=1,"IP", "'$APN'"|; \
   1.473 +	s|^Modem.*/dev.*|Modem = '$MODEM'|' -i $CONF
   1.474 +}
   1.475 +
   1.476 +wvdialbox_main() {
   1.477 +	icon=network-transmit-receive
   1.478 +	yad --title="$(_n 'Wvdial Box')" --window-icon=$icon --center \
   1.479 +		--image=$icon \
   1.480 +		--form \
   1.481 +		--field="$(_n 'Phone Number:')" "$PHONE" \
   1.482 +		--field="$(_n 'Username:')" "$USERNAME" \
   1.483 +		--field="$(_n 'Password:'):H" "$PASSWORD" \
   1.484 +		--field="$(_n 'Pin (if required):'):H" "$PIN" \
   1.485 +		--field="$(_n 'Modem:')" "$MODEM" \
   1.486 +		--field="$(_n 'Access Point Name (APN):')" "$APN" \
   1.487 +		--field="<b>$(_n 'You must save your account info before dialing')</b>:LBL" "" \
   1.488 +		--field="$(_n 'Edit config file'):BTN" "leafpad $CONF" \
   1.489 +		--button="$(_n 'Save Configuration'):2" \
   1.490 +		--button="$(_n 'Dial Pin Once'):1" \
   1.491 +		--button="gtk-connect:3"
   1.492 +		# --always-print-result
   1.493 +}
   1.494 +
   1.495 +wvdialbox() {
   1.496  	# setup your modem
   1.497  	#wvdialconf
   1.498 -	echo "===================================="
   1.499  	#set username, password, pin
   1.500  	#echo -e "Edit \033[1m /etc/wvdial.conf \033[0m  for phone number, login name, password and pin"
   1.501 -	if [ ! -f /etc/wvdial.conf ]; then
   1.502 -	    APN="apn.yournet.net"
   1.503 -	    PHONE="*99#"
   1.504 -	    USERNAME="user"
   1.505 -	    PASSWORD="passwd"
   1.506 -	    PIN="9999"
   1.507 -		echo "[Dialer slitaz]" > /etc/wvdial.conf
   1.508 -		echo "Phone = $PHONE" >> /etc/wvdial.conf
   1.509 -		echo "Username = $USERNAME" >> /etc/wvdial.conf
   1.510 -		echo "Password = $PASSWORD" >> /etc/wvdial.conf
   1.511 -		echo "Stupid Mode = 1" >> /etc/wvdial.conf
   1.512 -		echo "Dial Command = ATDT" >> /etc/wvdial.conf
   1.513 +	CONF=/etc/wvdial.conf
   1.514 +	if [ ! -f $CONF ]; then
   1.515 +		APN="apn.yournet.net"
   1.516 +		PHONE="*99#"
   1.517 +		USERNAME="user"
   1.518 +		PASSWORD="passwd"
   1.519 +		PIN="9999"
   1.520  		[ -n "$MODEM" ] || MODEM="/dev/ttyUSB0"
   1.521 -		echo "Modem = $MODEM" >> /etc/wvdial.conf
   1.522 -		echo "Baud = 460800" >> /etc/wvdial.conf
   1.523 -		echo "Init1 = ATZ " >> /etc/wvdial.conf
   1.524 -		echo "Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" >> /etc/wvdial.conf
   1.525 -		echo "Init3 = AT+CGDCONT=1,\"IP\", \"$APN\"" >> /etc/wvdial.conf
   1.526 -		echo "ISDN = 0" >> /etc/wvdial.conf
   1.527 -		echo "Modem Type = Analog Modem" >> /etc/wvdial.conf
   1.528 -		echo "" >> /etc/wvdial.conf
   1.529 -		echo "" >> /etc/wvdial.conf
   1.530 -		echo "[Dialer pin]" >> /etc/wvdial.conf
   1.531 -		echo "Modem = $MODEM" >> /etc/wvdial.conf
   1.532 -		echo "Init4 = AT+CPIN=$PIN" >> /etc/wvdial.conf
   1.533 +		cat > $CONF << EOT
   1.534 +[Dialer slitaz]
   1.535 +Phone = $PHONE
   1.536 +Username = $USERNAME
   1.537 +Password = $PASSWORD
   1.538 +Stupid Mode = 1
   1.539 +Dial Command = ATDT
   1.540 +Modem = $MODEM
   1.541 +Baud = 460800
   1.542 +Init1 = ATZ
   1.543 +Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
   1.544 +Init3 = AT+CGDCONT=1,"IP", "$APN"
   1.545 +ISDN = 0
   1.546 +Modem Type = Analog Modem
   1.547 +
   1.548 +[Dialer pin]
   1.549 +Modem = $MODEM
   1.550 +Init4 = AT+CPIN=$PIN
   1.551 +EOT
   1.552  	fi
   1.553  	#<action>sed -i "s/^\[Dialer.*/[Dialer slitaz]/" /etc/wvdial.conf</action>
   1.554  	#DIALER=`grep Dialer /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
   1.555  	#DIALER=`grep -B1 AT+CPIN /etc/wvdial.conf | sed \'2d\'|tr \"[]\" \" \"|cut -d \" \" -f 3`
   1.556  
   1.557 -MAIN_DIALOG="
   1.558 -<window title=\"Wvdial Box\" icon-name=\"applications-internet\">
   1.559 -<vbox>
   1.560 +	get_wvdial_vars
   1.561  
   1.562 -"
   1.563 -	MAIN_DIALOG=${MAIN_DIALOG}'
   1.564 +	CONF_VARS=$(wvdialbox_main); BUTTON="$?"
   1.565 +	PHONE=$(   echo $CONF_VARS | cut -d"|" -f1)
   1.566 +	USERNAME=$(echo $CONF_VARS | cut -d"|" -f2)
   1.567 +	PASSWORD=$(echo $CONF_VARS | cut -d"|" -f3)
   1.568 +	PIN=$(     echo $CONF_VARS | cut -d"|" -f4)
   1.569 +	MODEM=$(   echo $CONF_VARS | cut -d"|" -f5)
   1.570 +	APN=$(     echo $CONF_VARS | cut -d"|" -f6)
   1.571  
   1.572 -       <hbox>
   1.573 -			<text use-markup="true">
   1.574 -				<label>"<b>Phone Number:   </b>"</label>
   1.575 -			</text>
   1.576 -			<entry>
   1.577 -				<input>cat /etc/wvdial.conf | grep ^Phone | cut -d "=" -f2 | tr -d "[\" ]"</input>
   1.578 -				<variable>PHONE</variable>
   1.579 -			</entry>
   1.580 -		</hbox>
   1.581 -		<hbox>
   1.582 -			<text use-markup="true">
   1.583 -				<label>"<b>Username:           </b>"</label>
   1.584 -			</text>
   1.585 -			<entry>
   1.586 -				<input>cat /etc/wvdial.conf | grep ^Username | cut -d "=" -f2 | tr -d "[\" ]"</input>
   1.587 -				<variable>USERNAME</variable>
   1.588 -			</entry>
   1.589 -		</hbox>
   1.590 -		<hbox>
   1.591 -			<text use-markup="true">
   1.592 -				<label>"<b>Password:           </b>"</label>
   1.593 -			</text>
   1.594 -			<entry visibility="false">
   1.595 -				<input>cat /etc/wvdial.conf | grep ^Password | cut -d "=" -f2 | tr -d "[\" ]"</input>
   1.596 -				<variable>PASSWORD</variable>
   1.597 -			</entry>
   1.598 -		</hbox>
   1.599 -		 <hbox>
   1.600 -			<text use-markup="true">
   1.601 -				<label>"<b>Pin (if required):</b>"</label>
   1.602 -			</text>
   1.603 -			<entry visibility="false">
   1.604 -				<input>cat /etc/wvdial.conf | grep AT+CPIN= | cut -d "=" -f3 | tr -d "[\" ]"</input>
   1.605 -				<variable>PIN</variable>
   1.606 -			</entry>
   1.607 -		</hbox>
   1.608 -		<hbox>
   1.609 -			<text use-markup="true">
   1.610 -				<label>"<b>Modem:                </b>"</label>
   1.611 -			</text>
   1.612 -			<entry>
   1.613 -				<input>cat /etc/wvdial.conf | grep ^Modem.*/dev.*  | cut -d "=" -f2 | tr -d "[\" ]"|uniq</input>
   1.614 -				<variable>MODEM</variable>
   1.615 -			</entry>
   1.616 -		</hbox>
   1.617 -		<hbox>
   1.618 -			<text use-markup="true">
   1.619 -				<label>"<b>Access Point Name (APN):</b>"</label>
   1.620 -			</text>
   1.621 -			<entry>
   1.622 -				<input>cat /etc/wvdial.conf | grep AT+CGDCONT | cut -d "," -f3 | tr -d "[\" ]"</input>
   1.623 -				<variable>APN</variable>
   1.624 -			</entry>
   1.625 -		</hbox>
   1.626 -
   1.627 -
   1.628 -		<hbox>
   1.629 -			<text use-markup="true">
   1.630 -				<label>"
   1.631 -<b>You must save your account info before dialing    </b>"</label>
   1.632 -			</text>
   1.633 -			</hbox>
   1.634 -			<hbox>
   1.635 -			<button>
   1.636 -					<label>/etc/wvdial.conf</label>
   1.637 -					<input file icon="accessories-text-editor"></input>
   1.638 -					<action>leafpad /etc/wvdial.conf</action>
   1.639 -					<action>refresh:PHONE</action>
   1.640 -					<action>refresh:USERNAME</action>
   1.641 -					<action>refresh:PASSWORD</action>
   1.642 -					<action>refresh:PIN</action>
   1.643 -					<action>refresh:APN</action>
   1.644 -					<action>refresh:MODEM</action>
   1.645 -			</button>
   1.646 -			<button>
   1.647 -				<label>Save Configuration</label>
   1.648 -				<input file icon="document-save"></input>
   1.649 -				<action>sed -i "s/^Phone.*/Phone = $PHONE/ " /etc/wvdial.conf</action>
   1.650 -				<action>sed -i "s/^Username.*/Username = $USERNAME/ " /etc/wvdial.conf</action>
   1.651 -				<action>sed -i "s/^Password.*/Password = $PASSWORD/ " /etc/wvdial.conf</action>
   1.652 -				<action>sed -i "s/.*AT+CPIN=.*/Init4 = AT+CPIN=$PIN/ " /etc/wvdial.conf</action>
   1.653 -				<action>sed -i "s/.*AT+CGDCONT=.*/Init3 = AT+CGDCONT=1,\"IP\", \"$APN\" /" /etc/wvdial.conf </action>
   1.654 -				<action>sed -i "s:^Modem.*/dev.*:Modem = $MODEM: " /etc/wvdial.conf</action>
   1.655 -			</button>
   1.656 -
   1.657 -		</hbox>
   1.658 -		<hbox>
   1.659 -			<button>
   1.660 -					<label>Dial Pin Once        </label>
   1.661 -					<input file icon="forward"></input>
   1.662 -					<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.663 -			</button>
   1.664 -			<button>
   1.665 -					<label>Start Dialing       </label>
   1.666 -					<input file icon="forward"></input>
   1.667 -					<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.668 -			</button>
   1.669 -		</hbox>	'
   1.670 -
   1.671 -
   1.672 -export MAIN_DIALOG=${MAIN_DIALOG}"
   1.673 -</vbox>
   1.674 -</window>"
   1.675 -	gtkdialog --center --program=MAIN_DIALOG
   1.676 +	case "$BUTTON" in
   1.677 +		2) set_wvdial_vars; wvdialbox ;;
   1.678 +		1) terminal -geometry 80x16 -title "Wvdial" -e "$0 dial pin" ;;
   1.679 +		3) terminal -geometry 80x16 -title "Wvdial" -e "$0 dial slitaz" ;;
   1.680 +	esac
   1.681  }
   1.682  
   1.683  
   1.684 -
   1.685 -
   1.686 -setup()
   1.687 -{
   1.688 - 	case "$DEVICE" in
   1.689 +setup() {
   1.690 +	case "$DEVICE" in
   1.691  		printer)
   1.692  			load_modules
   1.693  			udev
   1.694 @@ -470,344 +372,357 @@
   1.695  				DETECTED="yes"
   1.696  			else
   1.697  				find_usb_device
   1.698 -			   	fix_usb_permissions "lp"
   1.699 +				fix_usb_permissions "lp"
   1.700  			fi
   1.701  			#lpinfo -v
   1.702  			if [ "$DETECTED" == "yes" ]; then
   1.703 -			    echo ""
   1.704 -				echo -n "Do you want to start cups (y/N) ? "; read anser
   1.705 -				echo ""
   1.706 -				if [ "$anser" == "y" ]; then
   1.707 -						/etc/init.d/cupsd start
   1.708 -						sleep 2
   1.709 -						browser http://localhost:631/
   1.710 +				newline
   1.711 +				_n 'Do you want to start cups'; confirm
   1.712 +				if [ $? == 0 ]; then
   1.713 +					newline
   1.714 +					/etc/init.d/cupsd start
   1.715 +					sleep 2
   1.716 +					browser http://localhost:631/
   1.717  				else
   1.718 -					echo ""
   1.719 -					echo "===================================="
   1.720 -						echo -e "Starting \033[1m cups \033[0m using :"
   1.721 -						echo "/etc/init.d/cupsd start"
   1.722 -						echo "browser http://localhost:631/"
   1.723 -					echo "===================================="
   1.724 +					newline; separator
   1.725 +					emsg "$(_ 'Starting <b>cups</b> using:')"
   1.726 +					echo "/etc/init.d/cupsd start"
   1.727 +					echo "browser http://localhost:631/"
   1.728 +					separator; newline
   1.729  				fi
   1.730  			else
   1.731  				failed
   1.732 -		    fi
   1.733 +			fi
   1.734  			;;
   1.735 +
   1.736  		scanner)
   1.737  			load_modules
   1.738  			udev
   1.739  			find_usb_device
   1.740  			fix_usb_permissions "scanner"
   1.741  
   1.742 -		  	if [ "$DETECTED" == "yes" ]; then
   1.743 -		  	    #hputil
   1.744 -				echo ""
   1.745 -				echo -n "Do you want to start scanner (y/N) ? "; read anser
   1.746 -				echo ""
   1.747 -				if [ "$anser" == "y" ]; then
   1.748 -						sane-find-scanner # to verify scanner has been found
   1.749 -						scanimage -L # List scanners
   1.750 -						xsane #scanner application
   1.751 +			if [ "$DETECTED" == "yes" ]; then
   1.752 +				#hputil
   1.753 +				newline
   1.754 +				_n 'Do you want to start scanner'; confirm
   1.755 +				if [ $? == 0 ]; then
   1.756 +					newline
   1.757 +					sane-find-scanner # to verify scanner has been found
   1.758 +					scanimage -L # List scanners
   1.759 +					xsane #scanner application
   1.760  				else
   1.761 -					echo ""
   1.762 -					echo "===================================="
   1.763 -						echo -e "Following \033[1m Scanner commands \033[0m  may be of help"
   1.764 -						echo "sane-find-scanner # to verify scanner has been found"
   1.765 -						echo "xsane # scanner application"
   1.766 -					echo "===================================="
   1.767 -				fi
   1.768 -			else
   1.769 -				failed
   1.770 -		    fi
   1.771 -			;;
   1.772 -		webcam)
   1.773 -			load_modules
   1.774 -			udev
   1.775 -
   1.776 -		   	if [ -n "`ls /dev/video0`" ] ; then
   1.777 -				# fix permissions
   1.778 -				 chmod 666 /dev/video0
   1.779 -				# ls -l /dev/video0
   1.780 -
   1.781 -				if [ -d /var/lib/tazpkg/installed/mplayer-svn ]; then
   1.782 -					echo ""
   1.783 -					echo -n "Would you like to test webcam (y/N) ? "; read anser
   1.784 -					echo ""
   1.785 -					if [ "$anser" == "y" ]; then
   1.786 -						mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
   1.787 -					fi
   1.788 -				else
   1.789 -				    echo ""
   1.790 -					echo -n "Would you like to test webcam by installing mplayer-svn (y/N) ? "; read anser
   1.791 -					echo ""
   1.792 -					if [ "$anser" == "y" ]; then
   1.793 -						install mplayer-svn
   1.794 -						mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
   1.795 -					else
   1.796 -						echo ""
   1.797 -		       			echo "============================"
   1.798 -						echo "Webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view"
   1.799 -						echo "============================"
   1.800 -		       		fi
   1.801 +					newline; separator
   1.802 +					emsg "$(_ 'Following <b>scanner commands</b> may be of help:')"
   1.803 +					echo '  sane-find-scanner # ' $(_n 'to verify scanner has been found')
   1.804 +					echo '  xsane # ' $(_n 'scanner application')
   1.805 +					separator
   1.806  				fi
   1.807  			else
   1.808  				failed
   1.809  			fi
   1.810  			;;
   1.811 +
   1.812 +		webcam)
   1.813 +			load_modules
   1.814 +			udev
   1.815 +
   1.816 +			if [ -n "$(ls /dev/video0)" ] ; then
   1.817 +				# fix permissions
   1.818 +				chmod 666 /dev/video0
   1.819 +				# ls -l /dev/video0
   1.820 +
   1.821 +				if [ -d $INSTALLED/mplayer-svn ]; then
   1.822 +					newline
   1.823 +					_n 'Would you like to test webcam'; confirm
   1.824 +					if [ $? == 0 ]; then
   1.825 +						newline
   1.826 +						mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
   1.827 +					fi
   1.828 +				else
   1.829 +					newline
   1.830 +					_n 'Would you like to test webcam by installing mplayer-svn'; confirm
   1.831 +					if [ $? == 0 ]; then
   1.832 +						newline
   1.833 +						install mplayer-svn
   1.834 +						mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo x11 &
   1.835 +					else
   1.836 +						newline; separator
   1.837 +						_ "Webcam is set up; please use mplayer-svn/fswebcam/amsn/skype to view"
   1.838 +						separator
   1.839 +					fi
   1.840 +				fi
   1.841 +			else
   1.842 +				failed
   1.843 +			fi
   1.844 +			;;
   1.845 +
   1.846  		camera)
   1.847  			udev
   1.848  			find_usb_device
   1.849  			fix_usb_permissions "camera"
   1.850  
   1.851  			if [ "$DETECTED" == "yes" ]; then
   1.852 -				echo ""
   1.853 -				echo -n "Do you want to check if gphoto2 can talk to your camera (y/N) ? "; read anser
   1.854 -				echo ""
   1.855 -				if [ "$anser" == "y" ]; then
   1.856 +				newline
   1.857 +				_n 'Do you want to check if gphoto2 can talk to your camera'; confirm
   1.858 +				if [ $? == 0 ]; then
   1.859 +					newline
   1.860  					# Show if the camera is detected
   1.861  					gphoto2 --auto-detect
   1.862 -					echo -e "Do you want to test importing photos (y/N) ? "; read choice
   1.863 -					if [ "$choice" == "y" ]; then
   1.864 +					_n 'Do you want to test importing photos'; confirm
   1.865 +					if [ $? == 0 ]; then
   1.866  						mkdir -p ~/Images/Photos
   1.867  						cd ~/Images/Photos
   1.868  						gphoto2 --get-all-files
   1.869 -						pcmanfm ~/Images/Photos
   1.870 +						file-manager ~/Images/Photos
   1.871  					fi
   1.872 -				echo ""
   1.873 +				newline
   1.874  				else
   1.875 -					echo ""
   1.876 -					echo "===================================="
   1.877 -					echo "Camera is set up; please use gphoto2 to import photos"
   1.878 -					echo "Quick start guide: http://www.gphoto.org/doc/manual/using-gphoto2.html"
   1.879 -					echo "===================================="
   1.880 +					newline; separator
   1.881 +					_ 'Camera is set up; please use gphoto2 to import photos'
   1.882 +					guide_url='http://www.gphoto.org/doc/manual/using-gphoto2.html'
   1.883 +					_ 'Quick start guide: $guide_url'
   1.884 +					separator; newline
   1.885  				fi
   1.886  			else
   1.887  				failed
   1.888 -		    fi
   1.889 -		    ;;
   1.890 +			fi
   1.891 +			;;
   1.892  		bluetooth)
   1.893  			load_modules
   1.894  			udev
   1.895  
   1.896 -			echo -n "Do you want to see if the bluetooth is working (y/N) ? "; read anser
   1.897 -			echo ""
   1.898 -			if [ "$anser" == "y" ]; then
   1.899 +			_n 'Do you want to see if the bluetooth is working'; confirm
   1.900 +			if [ $? == 0 ]; then
   1.901 +				newline
   1.902  				# sanity check: btusb is not loaded automagically for unknown reasons
   1.903  				if ! lsmod | grep -q btusb ; then
   1.904  					modprobe btusb
   1.905  				fi
   1.906 -				echo "========================================"
   1.907 -				echo -e "\033[1m Bluetooth \033[0m  interfaces"
   1.908 -				echo ""
   1.909 +				separator
   1.910 +				emsg "$(_n '<b>Bluetooth</b> interfaces')"
   1.911 +				newline
   1.912  				lsusb | grep Bluetooth
   1.913  				# udev should run bluetoothd automatically
   1.914  				bluetoothd
   1.915  				sleep 1
   1.916  				if hcitool dev | grep -q hci ; then
   1.917 -					echo "========================================"
   1.918 -					echo -e "Following \033[1m Bluetooth commands \033[0m  may be of help "
   1.919 -					echo ""
   1.920 -					#echo " modprobe btusb"
   1.921 -					#echo " /usr/sbin/bluetoothd -nd #for starting bluetooth daemon"
   1.922 -					echo " hciconfig -a"
   1.923 -					echo " \"hcitool dev\" : checking local bluetooth devices..."
   1.924 -		 			echo " \"hcitool scan\" : scanning remote bluetooth devices..."
   1.925 -		 			echo " \"bluez-simple-agent\" : pairing with remote bluetooth devices..."
   1.926 -		 			echo -e " You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
   1.927 -					echo "========================================"
   1.928 +					newline; separator
   1.929 +					emsg "$(_n 'Following <b>Bluetooth commands</b> may be of help')"
   1.930 +					newline
   1.931 +					optlist "\
   1.932 +modprobe btusb	
   1.933 +hciconfig -a	
   1.934 +hcitool dev		$(_n 'checking local bluetooth devices...')
   1.935 +hcitool scan	$(_n 'scanning remote bluetooth devices...')
   1.936 +bluez-simple-agent	$(_n 'pairing with remote bluetooth devices...')"
   1.937 +					newline
   1.938 +					bt=$(emsg '<b>/etc/bluetooth</b>')
   1.939 +					longline $(_ "You can manually edit the configuration \
   1.940 +files in \$bt if need be")
   1.941 +					separator; newline
   1.942  				fi
   1.943  			else
   1.944 -				echo ""
   1.945 -				echo "========================================"
   1.946 -				echo -e "Following \033[1m Bluetooth commands \033[0m  may be of help"
   1.947 -				echo ""
   1.948 -				echo " modprobe btusb"
   1.949 -				echo " lsusb | grep Bluetooth"
   1.950 -				echo " /usr/sbin/bluetoothd -nd # for starting bluetooth daemon"
   1.951 -				echo " hciconfig -a"
   1.952  				# Show if the bluetooth is detected
   1.953 -		 		echo " hcitool dev # for checking local devices"
   1.954 -		 		echo " hcitool scan # for scanning remote devices"
   1.955 -		 		echo " bluez-simple-agent # pairing with remote bluetooth devices"
   1.956 -		 		echo ""
   1.957 -		 		echo -e "You can manually edit the configuration files in \033[1m /etc/bluetooth \033[0m if need be"
   1.958 -				echo ""
   1.959 -		    	echo "========================================"
   1.960 -		    fi
   1.961 -		    ;;
   1.962 +				newline; separator
   1.963 +				emsg "$(_n 'Following <b>Bluetooth commands</b> may be of help')"
   1.964 +				newline
   1.965 +				cat << EOT
   1.966 +  modprobe btusb
   1.967 +  lsusb | grep Bluetooth
   1.968 +EOT
   1.969 +				optlist "\
   1.970 +/usr/sbin/bluetoothd -nd	$(_n 'for starting bluetooth daemon')
   1.971 +hciconfig -a	
   1.972 +hcitool dev		$(_n 'for checking local devices')
   1.973 +hcitool scan	$(_n 'for scanning remote devices')
   1.974 +bluez-simple-agent	$(_n 'pairing with remote bluetooth devices')"
   1.975 +				newline
   1.976 +				bt=$(emsg '<b>/etc/bluetooth</b>')
   1.977 +				longline $(_ "You can manually edit the configuration files \
   1.978 +in \$bt if need be")
   1.979 +				newline; separator
   1.980 +			fi
   1.981 +			;;
   1.982 +
   1.983  		3g-modem)
   1.984 -				untested
   1.985 -				load_modules
   1.986 -				udev
   1.987 -				echo ""
   1.988 -		       	echo "===================================="
   1.989 -		       	echo "List detected devices"
   1.990 -		       	# ls /dev/ttyUSB* /dev/ttyACM* /dev/modem
   1.991 +			untested
   1.992 +			load_modules
   1.993 +			udev
   1.994 +			newline; separator
   1.995 +			_ 'List detected devices'
   1.996 +			# ls /dev/ttyUSB* /dev/ttyACM* /dev/modem
   1.997  
   1.998 -		       	if [ -n "`ls /dev/ttyUSB*`" -o -n "`ls /dev/ttyACM*`" ] ; then
   1.999 -				    echo "Detected Modem at:"
  1.1000 -				    echo "`ls /dev/ttyUSB*`"
  1.1001 -					echo -n "Do you want to configure wvdial (y/N) ? "; read anser
  1.1002 -					echo ""
  1.1003 -					if [ "$anser" == "y" ]; then
  1.1004 -						wvdialbox
  1.1005 -					else
  1.1006 -						echo "===================================="
  1.1007 -						echo "wvdialconf"
  1.1008 -						echo -e "Edit \033[1m /etc/wvdial.conf \033[0m  for phone number, login name, password and pin"
  1.1009 -						echo "wvdial dialername"
  1.1010 -						#nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf
  1.1011 -						echo -e "Add DNS adress of your provider in : \033[1m /etc/resolv.conf  \033[0m "
  1.1012 -						echo "===================================="
  1.1013 -					 fi
  1.1014 -		       	 else
  1.1015 -		       	    failed
  1.1016 -				 fi
  1.1017 -		       ;;
  1.1018 -		firewall) echo "Setting IPTABLES_RULES to yes in /etc/slitaz/firewall.conf"
  1.1019 -				  sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/slitaz/firewall.conf
  1.1020 -		          # default is "start"
  1.1021 -				 if [ "$STOP" == "yes" ] ; then
  1.1022 -				 	/etc/init.d/firewall stop
  1.1023 -				 else
  1.1024 -				 	/etc/init.d/firewall start
  1.1025 -				 	if [ -d /var/lib/tazpkg/installed/nmap ]; then
  1.1026 -				 		echo "===================================="
  1.1027 -				 	    echo "Probing for open ports..."
  1.1028 -				 		nmap localhost
  1.1029 -				 		echo "===================================="
  1.1030 -				 	fi
  1.1031 -				 	echo "Adding firewall daemon to start automatically at boot"
  1.1032 -				 	run_daemon_startup "firewall"
  1.1033 -				 	echo "===================================="
  1.1034 -				 fi
  1.1035 +			if [ -n "$(ls /dev/ttyUSB*)" -o -n "$(ls /dev/ttyACM*)" ] ; then
  1.1036 +				_ 'Detected Modem at:'
  1.1037 +				ls /dev/ttyUSB* /dev/ttyACM* 2> /dev/null
  1.1038 +				_n 'Do you want to configure wvdial'; confirm
  1.1039 +				if [ $? == 0 ]; then
  1.1040 +					wvdialbox
  1.1041 +				else
  1.1042 +					#nameserver `tail -30 /var/log/messages| grep DNS| sed 's/*\([.0-9]*\)$/\1/'` >/etc/resolv.conf
  1.1043 +					newline; separator
  1.1044 +					wc=$(boldify '/etc/wvdial.conf')
  1.1045 +					rc=$(boldify '/etc/resolv.conf')
  1.1046 +					optlist "\
  1.1047 +wvdialconf	$(_ 'Edit $wc for phone number, login name, password and pin')
  1.1048 +wvdial		$(_ 'Add DNS adress of your provider in $rc')"
  1.1049 +					separator
  1.1050 +				fi
  1.1051 +			else
  1.1052 +				failed
  1.1053 +			fi
  1.1054 +			;;
  1.1055  
  1.1056 -			   ;;
  1.1057 +		firewall)
  1.1058 +			_ 'Setting IPTABLES_RULES to yes in /etc/slitaz/firewall.conf'
  1.1059 +			sed -i 's/^IPTABLES_RULES="no"/IPTABLES_RULES="yes"/' /etc/slitaz/firewall.conf
  1.1060 +			# default is "start"
  1.1061 +			if [ "$STOP" == "yes" ] ; then
  1.1062 +				/etc/init.d/firewall stop
  1.1063 +			else
  1.1064 +				/etc/init.d/firewall start
  1.1065 +				if [ -d $INSTALLED/nmap ]; then
  1.1066 +					separator
  1.1067 +					_ "Probing for open ports..."
  1.1068 +					nmap localhost
  1.1069 +					separator
  1.1070 +				fi
  1.1071 +				_ "Adding firewall daemon to start automatically at boot"
  1.1072 +				run_daemon_startup "firewall"
  1.1073 +				separator
  1.1074 +			fi
  1.1075 +			;;
  1.1076 +
  1.1077  		nvidia)
  1.1078 +			xorg55=/etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1079 +			xorg60=/etc/X11/xorg.conf.d/60-Device.conf
  1.1080 +			xorg55short=55-DeviceTweaks.conf
  1.1081  			if [ "$NON_FREE" == "yes" ] ; then
  1.1082 -				if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-nv ]; then
  1.1083 -					rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1084 +				if [ -d $INSTALLED/xorg-xf86-video-nv ]; then
  1.1085 +					rm $xorg55
  1.1086  					tazpkg remove xorg-xf86-video-nv
  1.1087  				fi
  1.1088  				load_modules
  1.1089  				#xorg
  1.1090 -				echo -n "Do you want to configure X using non-free nvidia driver (y/N) ? "; read anser
  1.1091 -				echo ""
  1.1092 -				if [ "$anser" == "y" ]; then
  1.1093 -					echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
  1.1094 -					echo "If nvidia fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
  1.1095 +				_n 'Do you want to configure X using non-free nvidia driver'; confirm
  1.1096 +				if [ $? == 0 ]; then
  1.1097 +					newline
  1.1098 +					_ 'Your previous config is in $xorg60'
  1.1099 +					_ 'If nvidia fails, you can remove $xorg55 to restore previous config.'
  1.1100  					Xorg -configure :1 > /dev/null
  1.1101  					nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia
  1.1102 -					sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.nvidia > /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1103 +					sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.nvidia > $xorg55
  1.1104  					rm /tmp/xorg.conf.nvidia /root/xorg.conf.new
  1.1105  
  1.1106 -					if ! grep -q "NoLogo" /etc/X11/xorg.conf.d/55-DeviceTweaks.conf ; then
  1.1107 -						echo "Adding to xorg.conf: Option \"NoLogo\" \"True\""
  1.1108 -						sed -i 's/BoardName\(.*\)/Boardname \1 \n  Option "NoLogo" "True" /' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1109 +					if ! grep -q "NoLogo" $xorg55 ; then
  1.1110 +						_n 'Adding to xorg.conf:'; echo ' Option "NoLogo" "True"'
  1.1111 +						sed -i 's/BoardName\(.*\)/Boardname \1 \n  Option "NoLogo" "True" /' $xorg55
  1.1112  					fi
  1.1113  
  1.1114  					# mesa-demos to check if acceleration is working
  1.1115 -					echo "Checking if nvidia is working ..."
  1.1116 -					glxinfo |grep rendering
  1.1117 +					_ 'Checking if nvidia is working...'
  1.1118 +					glxinfo | grep rendering
  1.1119  
  1.1120 -					echo "================================"
  1.1121 -					echo -e "\033[1m Configure nvidia settings :\033[0m  "
  1.1122 +					newline; separator
  1.1123 +					boldify "$(_n 'Configure nvidia settings:')"
  1.1124  					nvidia-settings
  1.1125 -					echo "================================"
  1.1126 +					separator; newline
  1.1127  				else
  1.1128 -					echo ""
  1.1129 -					echo "================================"
  1.1130 -					echo "Use 'Xorg -configure :1 && nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia' to generate a template configuration file."
  1.1131 -					echo "glxinfo |grep rendering # test nvidia"
  1.1132 -					echo "Use: nvidia-settings utility to configure your settings if necessary"
  1.1133 -					echo "Option \"NoLogo\" \"True\""
  1.1134 -					echo "================================"
  1.1135 +					newline; separator
  1.1136 +					xcmd='Xorg -configure :1 && nvidia-xconfig -c /root/xorg.conf.new -o /tmp/xorg.conf.nvidia'
  1.1137 +					_ "Use '$xcmd' to generate a template configuration file."
  1.1138 +					echo 'glxinfo | grep rendering #' $(_n 'test nvidia')
  1.1139 +					_ 'Use: nvidia-settings utility to configure your settings if necessary'
  1.1140 +					echo 'Option "NoLogo" "True"'
  1.1141 +					separator; newline
  1.1142  				fi
  1.1143  			else
  1.1144 -				if [ -d /var/lib/tazpkg/installed/nvidia ]; then
  1.1145 -					rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1146 +				if [ -d $INSTALLED/nvidia ]; then
  1.1147 +					rm $xorg55
  1.1148  					tazpkg remove nvidia
  1.1149  				fi
  1.1150  				load_modules
  1.1151  				#xorg
  1.1152 -				echo -n "Do you want to configure X using free nvidia driver (y/N) ? "; read anser
  1.1153 -				echo ""
  1.1154 -				if [ "$anser" == "y" ]; then
  1.1155 -					echo ""
  1.1156 -					echo "================================"
  1.1157 -					echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
  1.1158 -					echo "If nvidia fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
  1.1159 -					echo ""
  1.1160 -					echo "Create 55-DeviceTweaks.conf configured with nv driver."
  1.1161 +				_n 'Do you want to configure X using free nvidia driver'; confirm
  1.1162 +				if [ $? == 0 ]; then
  1.1163 +					newline; separator
  1.1164 +					_ 'Your previous config is in $xorg60'
  1.1165 +					_ 'If nvidia fails, you can remove $xorg55 to restore previous config.'
  1.1166 +					newline
  1.1167 +					_ 'Create $xorg55short configured with nv driver.'
  1.1168  
  1.1169  					# free nvidia driver is called nv
  1.1170 -					cp -a /etc/X11/xorg.conf.d/60-Device.conf /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1171 -					sed -i 's/vesa/nv/' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1172 +					cp -a $xorg60 $xorg55
  1.1173 +					sed -i 's/vesa/nv/' $xorg55
  1.1174  
  1.1175  					# mesa-demos to check if acceleration is working
  1.1176 -					echo "Checking if nvidia is working ..."
  1.1177 -					glxinfo |grep rendering
  1.1178 -					echo "================================"
  1.1179 +					_ 'Checking if nvidia is working...'
  1.1180 +					glxinfo | grep rendering
  1.1181 +					separator
  1.1182  				fi
  1.1183  			fi
  1.1184  		;;
  1.1185 -		ati)	untested
  1.1186 +
  1.1187 +		ati)
  1.1188 +			xorg55=/etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1189 +			xorg60=/etc/X11/xorg.conf.d/60-Device.conf
  1.1190 +			xorg55short=55-DeviceTweaks.conf
  1.1191 +			untested
  1.1192  			if [ "$NON_FREE" == "yes" ] ; then
  1.1193 -				if [ -d /var/lib/tazpkg/installed/xorg-xf86-video-ati ]; then
  1.1194 -					rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1195 +				if [ -d $INSTALLED/xorg-xf86-video-ati ]; then
  1.1196 +					rm $xorg55
  1.1197  					tazpkg remove xorg-xf86-video-ati
  1.1198  				fi
  1.1199  				load_modules
  1.1200  				#xorg
  1.1201 -				echo -n "Do you want to configure X using non-free catalyst ati(radeon) driver (y/N) ? "; read anser
  1.1202 -				echo ""
  1.1203 -				if [ "$anser" == "y" ]; then
  1.1204 -					echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
  1.1205 -					echo "If ati fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
  1.1206 +				_n 'Do you want to configure X using non-free catalyst ATI (radeon) driver'; confirm
  1.1207 +				if [ $? == 0 ]; then
  1.1208 +					newline
  1.1209 +					_ 'Your previous config is in $xorg60'
  1.1210 +					_ 'If ati fails, you can remove $xorg55 to restore previous config.'
  1.1211  
  1.1212  					# add fglrx driver to xorg.conf
  1.1213  					Xorg -configure :1 > /dev/null
  1.1214  					aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati
  1.1215 -					sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.ati > /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1216 +					sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" /tmp/xorg.conf.ati > $xorg55
  1.1217  					rm /tmp/xorg.conf.ati /root/xorg.conf.new
  1.1218  
  1.1219  					# mesa-demos to check if acceleration is working
  1.1220 -					echo "Checking if ati catalyst is working ..."
  1.1221 -					glxinfo |grep rendering
  1.1222 +					_ 'Checking if ati catalyst is working...'
  1.1223 +					glxinfo | grep rendering
  1.1224  				else
  1.1225 -					echo ""
  1.1226 -					echo "================================"
  1.1227 -					echo -e "\033[1m Configuration :\033[0m  "
  1.1228 -					echo "Use: aticonfig utility to generate a template configuration file if necessary"
  1.1229 -					echo "Xorg -configure :1 &&	aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati"
  1.1230 -					echo "restart xorg"
  1.1231 -					echo "glxinfo |grep rendering"
  1.1232 -					echo "================================"
  1.1233 +					newline; separator
  1.1234 +					boldify "$(_n 'Configuration:')"
  1.1235 +					_ 'Use: aticonfig utility to generate a template configuration file if necessary'
  1.1236 +					cat << EOT
  1.1237 +Xorg -configure :1 && aticonfig --initial --input=/root/xorg.conf.new --output=/tmp/xorg.conf.ati
  1.1238 +restart xorg
  1.1239 +glxinfo | grep rendering
  1.1240 +EOT
  1.1241 +					separator; newline
  1.1242  				fi
  1.1243  			else
  1.1244 -				if [ -d /var/lib/tazpkg/installed/catalyst ]; then
  1.1245 -					rm /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1246 +				if [ -d $INSTALLED/catalyst ]; then
  1.1247 +					rm $xorg55
  1.1248  					tazpkg remove catalyst
  1.1249  				fi
  1.1250  				load_modules
  1.1251  				#xorg
  1.1252 -				echo -n "Do you want to configure X using free ati (radeon) driver (y/N) ? "; read anser
  1.1253 -				echo ""
  1.1254 -				if [ "$anser" == "y" ]; then
  1.1255 -					echo ""
  1.1256 -					echo "================================"
  1.1257 -					echo "Your previous config is in /etc/X11/xorg.conf.d/60-Device.conf"
  1.1258 -					echo "If ati fails, you can remove /etc/X11/xorg.conf.d/55-DeviceTweaks.conf to restore previous config."
  1.1259 -					echo ""
  1.1260 -					echo "Create 55-DeviceTweaks.conf configured with radeon driver."
  1.1261 +				_n 'Do you want to configure X using free ATI (radeon) driver'; confirm
  1.1262 +				if [ $? == 0 ]; then
  1.1263 +					newline; separator
  1.1264 +					_ 'Your previous config is in $xorg60'
  1.1265 +					_ 'If ATI fails, you can remove $xorg55 to restore previous config.'
  1.1266 +					newline
  1.1267 +					_ 'Create $xorg55short configured with radeon driver.'
  1.1268  
  1.1269  					# free ati driver is called radeon
  1.1270  					cp -a /etc/X11/xorg.conf.d/60-Device.conf /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1271  					sed -i 's/vesa/nv/' /etc/X11/xorg.conf.d/55-DeviceTweaks.conf
  1.1272  					# mesa-demos to check if acceleration is working
  1.1273 -					echo "Checking if ati radeon is working ..."
  1.1274 +					_ 'Checking if ATI radeon is working...'
  1.1275  					glxinfo |grep rendering
  1.1276 -					echo "================================"
  1.1277 +					separator
  1.1278  				fi
  1.1279  			fi
  1.1280  		;;
  1.1281 @@ -816,46 +731,52 @@
  1.1282  
  1.1283  # What to do.
  1.1284  case "$1" in
  1.1285 -	help|usage ) 	usage ;;
  1.1286 -	wvdial) 		wvdialbox ;;
  1.1287 -	xorg)  			xorg;;
  1.1288 +	-h|--help|help|usage)	usage ;;
  1.1289 +	wvdial)		wvdialbox ;;
  1.1290 +	xorg)		xorg ;;
  1.1291  
  1.1292 -	*) 		check_root
  1.1293 -			echo "COMMAND OPTIONS: $@"
  1.1294 -			for i in "$@"; do
  1.1295 -	   			if [ "$i" == "--non-free" ] ;  then 	NON_FREE="yes"; 				fi
  1.1296 -				if [ "$i" == "--suggested" ] ; then 	AUTO_INSTALL_SUGGESTED="yes"; 	fi
  1.1297 -				if [ "$i" == "--confirm" ] ;   then 	CONFIRM_SUGGESTED="yes"; 		fi
  1.1298 -				if [ "$i" == "stop" ] ;        then 	STOP="yes"; 					fi
  1.1299 -			done
  1.1300 +	dial)
  1.1301 +		_ 'Bringing eth0 down...'; ifconfig eth0 down; ifconfig eth1 down
  1.1302 +		_ 'Dialing...'; wvdial $2
  1.1303 +		sleep 5 ;;
  1.1304  
  1.1305 -			device
  1.1306 -			#untested
  1.1307 -			if [ ! "$NON_FREE_DEPENDS" == "" -a "$NON_FREE" == "yes" ]; then
  1.1308 -			     DEPENDS="$NON_FREE_DEPENDS"
  1.1309 -			fi
  1.1310 +	*)
  1.1311 +		check_root $@
  1.1312 +		echo "COMMAND OPTIONS: $@"
  1.1313 +		NON_FREE="$nonfree"
  1.1314 +		AUTO_INSTALL_SUGGESTED="$suggested"
  1.1315 +		CONFIRM_SUGGESTED="$confirm"
  1.1316 +		for i in "$@"; do
  1.1317 +#			if [ "$i" == "--non-free" ] ;  then NON_FREE="yes"; 				fi
  1.1318 +#			if [ "$i" == "--suggested" ] ; then AUTO_INSTALL_SUGGESTED="yes"; 	fi
  1.1319 +#			if [ "$i" == "--confirm" ] ;   then CONFIRM_SUGGESTED="yes"; 		fi
  1.1320 +			if [ "$i" == "stop" ] ;        then STOP="yes"; 					fi
  1.1321 +		done
  1.1322  
  1.1323 -			if [ "$AUTO_INSTALL_SUGGESTED" == "yes" ]; then
  1.1324 -				anser="all"
  1.1325 -			elif [ "$CONFIRM_SUGGESTED" == "yes" ]; then
  1.1326 -				echo ""
  1.1327 -				echo "===================================="
  1.1328 -				echo "The following optional packages can be installed:"
  1.1329 -				echo ""
  1.1330 -				echo "$SUGGESTED"
  1.1331 -				echo "===================================="
  1.1332 -				echo -n "Do you want to install all/few/no optional dependencies (all|few|N) ? "; read anser
  1.1333 -			fi
  1.1334 +		device
  1.1335 +		#untested
  1.1336 +		if [ ! "$NON_FREE_DEPENDS" == "" -a "$NON_FREE" == "yes" ]; then
  1.1337 +			DEPENDS="$NON_FREE_DEPENDS"
  1.1338 +		fi
  1.1339  
  1.1340 -			install "$DEPENDS"
  1.1341 -			case $anser in
  1.1342 -				[aA]*|[yY]|1) 	install "$SUGGESTED" ;;
  1.1343 -				[fF]*|2) 		confirm_install "$SUGGESTED" ;;
  1.1344 -				*) ;;
  1.1345 -			esac
  1.1346 +		if [ "$AUTO_INSTALL_SUGGESTED" == "yes" ]; then
  1.1347 +			anser="all"
  1.1348 +		elif [ "$CONFIRM_SUGGESTED" == "yes" ]; then
  1.1349 +			newline; separator
  1.1350 +			_ 'The following optional packages can be installed:'
  1.1351 +			newline
  1.1352 +			echo $SUGGESTED
  1.1353 +			separator; newline
  1.1354 +			_n 'Do you want to install all/few/no optional dependencies (all|few|N)? '; read anser
  1.1355 +		fi
  1.1356  
  1.1357 -			add_all_user_to_group
  1.1358 -			setup ;;
  1.1359 +		install "$DEPENDS"
  1.1360 +		case $anser in
  1.1361 +			[aA]*|[yY]|1)	install "$SUGGESTED" ;;
  1.1362 +			[fF]*|2)		confirm_install "$SUGGESTED" ;;
  1.1363 +			*) ;;
  1.1364 +		esac
  1.1365 +
  1.1366 +		add_all_user_to_group
  1.1367 +		setup ;;
  1.1368  esac
  1.1369 -
  1.1370 -