slitaz-tools annotate tinyutils/hwsetup @ rev 856

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