slitaz-tools annotate tinyutils/hwsetup @ rev 516

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