home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #(c)copyright Barry Kauler modem wizard 2003,2004,2005. www.puppylinux.org
-
- KERNVER="`uname -r`"
-
- MODTYPE="ko"
- MODCONF="modprobe.conf"
- #k2.6, need to load core serial modules...
- #modprobe 8250_pci 2> /dev/null
- #...no, i changed config so built-in the kernel. but, still need for 2.6.11.7 build.
-
- PCISUMMARY="`lspci -b`"
- MODEMINFOx="`cat /proc/pci | grep -i "modem" | head -n 1`"
- #outputs a leading line number...
- MODEMINFO2="`cat /proc/pci | grep -ni "modem" | head -n 1`"
- if [ "$MODEMINFO2" ];then
- MODEMLINE2=`echo -n $MODEMINFO2 | cut -f 1 -d ':'`
- MODEMLINE1=`expr $MODEMLINE2 - 1`
- MODEMINFO1="`cat /proc/pci | head -n $MODEMLINE1 | tail -n 1`"
- BUSNUMBER="`echo -n $MODEMINFO1 | tr -s ' ' | cut -f 2 -d ' ' | cut -f 1 -d ','`"
- DEVNUMBER="`echo -n $MODEMINFO1 | tr -s ' ' | cut -f 4 -d ' ' | cut -f 1 -d ','`"
- FUNCNUMBER="`echo -n $MODEMINFO1 | tr -s ' ' | cut -f 6 -d ' ' | cut -f 1 -d ':'`"
- VENDCHIPNUMS="`lspci -b | grep "$BUSNUMBER:$DEVNUMBER.$FUNCNUMBER" | tr -s ' ' | cut -f 2 -d ' '`"
- fi
-
- DEVM=""
- IRQM=""
-
- # return the IRQ that respond to a given device
- irq_from_device()
- {
- local dev=$1
- #v1.0.2 it seems that setserial may be more trouble than its worth...
- #in the case of linmodems it often doesn't work...
- set -- `setserial -v -b $dev auto_irq \
- skip_test autoconfig session_lockout`
- [ "$6" ] && echo $6 | tr -d \)
- }
-
- # kill processing attached to device
- kill_users()
- {
- [ "`which fuser`" ] && fuser -k $1 2>/dev/null
- }
-
- #talk to modem, wait for response
- chat_with()
- {
- rm -f /tmp/answer.txt
- ##note, ^M is equivalent to a carriage-return, and modem
- ## ...no, that does not work.
- ##should respond to "AT" with "OK"...
- ##(
- ## #echo -e "AT^M"
- ## echo -n -e "AT\r\n"
- ## tee > /tmp/answer.txt &
- ## sleep 1
- ## killall tee
- ##) < $1 > $1
- #dd bs=1 count=10 > /tmp/answer.txt < $1 &
- #DDID=$!
- #echo -n -e "ATC1\r\n" > $1
- #sleep 1
- ##killall dd
- #kill $DDID
-
- #the above method used to work k2.4, not k2.6. now do it like this...
- #no, with one modem at least, it hangs, also only works with atz...
- #also hangs if modem unplugged or turned off (contrary to what docs say)...
- #modem-stats -c "AT" $1 > /tmp/answer.txt
- modem-stats -c "ATZ" $1 > /tmp/answer.txt &
- sleep 2
- killall modem-stats
-
-
- if [ -e /tmp/answer.txt ];then
- if [ -s /tmp/answer.txt ];then
- #...filesize is nonzero.
- #the modem should have answered with "OK"...
- grep "^OK" /tmp/answer.txt > /dev/null 2>&1
- [ $? -eq 0 ] && return 1 #success
- fi
- fi
- return 0
- }
-
- testmodem()
- {
- dev=$1
- DEVM=$1
- local irq
- echo -n "" >/tmp/modemtest.txt
- irq=$(irq_from_device $dev)
- if [ -z "$irq" ];then
- #wavplay -q /usr/share/audio/error.wav &
- echo "FAIL, $dev does not seem to have an irq assigned" >>/tmp/modemtest.txt
- echo "There is probably nothing on that port so try another..." >>/tmp/modemtest.txt
- echo "HOWEVER, for linmodems, maybe some other types, this irq" >>/tmp/modemtest.txt
- echo "test may have failed but the modem may still work, so" >>/tmp/modemtest.txt
- echo "continuing with testing port $dev..." >>/tmp/modemtest.txt
- echo " " >>/tmp/modemtest.txt
- IRQM="unknown"
- #return 1
- fi
- IRQM="$irq"
- kill_users $dev
- chat_with $dev
- if [ $? -eq 1 ];then
- wavplay -q /usr/share/audio/generic.wav &
- #DEVM="$dev"
- echo "SUCCESS, $dev seems to be a modem, using irq=$irq" >>/tmp/modemtest.txt
- echo "however if uncertain check the others" >>/tmp/modemtest.txt
- echo -n -e "(if confident modem found, press \"SAVE\" button)" >>/tmp/modemtest.txt
- else
- wavplay -q /usr/share/audio/error.wav &
- #echo "FAIL, there is something at $dev (and irq=$IRQM) but" >/tmp/modemtest.txt
- echo -e "FAIL: $dev does not seem to be a modem. Try another \"tty*\" port..." >>/tmp/modemtest.txt
- echo -n -e "(or, if you really want to use this one, press \"SAVE\")" >>/tmp/modemtest.txt
- fi
- }
-
- TTYLT0=""
- MODLTMODEM="/lib/modules/$KERNVER/ltmodem/ltmodem.ko"
- if [ -e /lib/modules/$KERNVER/ltmodem/ltmodem.ko ];then
- TTYLT0='ttyLT0:20,'
- fi
- TTYSL0=""
- MODSLMODEM="/lib/modules/$KERNVER/slmodem/slamr.ko"
- if [ -e /lib/modules/$KERNVER/slmodem/slamr.ko ];then
- TTYSL0='ttySL0:21,'
- fi
-
- BUTTONS="ttyS0":10,"ttyS1":11,"ttyS2":12,"ttyS3":13,"ttyS4":14,${TTYLT0}${TTYSL0}"SAVE":15,"ERASE":16,"HELP":17,"EXIT":18
-
- if [ -e /etc/modemdevice ];then
- DEVM="`cat /etc/modemdevice`"
- echo "You previously selected $DEVM" >/tmp/modemtest.txt
- echo -e "...if you do not want to use a modem anymore press \"ERASE\"" >>/tmp/modemtest.txt
- echo >>/tmp/modemtest.txt
- if [ "`echo "$DEVM" | grep --extended-regexp "ttyLT0|ttySL0"`" = "" ];then
- echo "Note, $DEVM is for a true hardware modem, but Puppy does support" >>/tmp/modemtest.txt
- echo "the Lucent and Smartlink software modems. However, they are" >>/tmp/modemtest.txt
- echo "packages that you have to download with PupGet." >>/tmp/modemtest.txt
- echo "When the Lucent package is installed, you will see the ttyLT0 button." >>/tmp/modemtest.txt
- echo "When the Smartlink package is installed, you will see the ttySL0 button." >>/tmp/modemtest.txt
- echo >>/tmp/modemtest.txt
- fi
- echo -e "If uncertain, press the \"HELP\" button, otherwise" >>/tmp/modemtest.txt
- echo -n -e "Press a \"tty*\" button to test if a modem is present..." >>/tmp/modemtest.txt
- else
- DEVM=""
- echo "WELCOME! Try your luck with Puppy analog Modem Wizard" >/tmp/modemtest.txt
-
- if [ ! "$MODEMINFO2" = "" ];then
- echo " " >>/tmp/modemtest.txt
- echo "Puppy has found a PCI modem:" >>/tmp/modemtest.txt
- echo "$MODEMINFO1" >>/tmp/modemtest.txt
- echo "$MODEMINFOx" >>/tmp/modemtest.txt
- #echo "$BUSNUMBER" >>/tmp/modemtest.txt
- #echo "$DEVNUMBER" >>/tmp/modemtest.txt
- #echo "$FUNCNUMBER" >>/tmp/modemtest.txt
- echo -n "The vendor:chip numbers are (hex): " >>/tmp/modemtest.txt
- echo "$VENDCHIPNUMS" >>/tmp/modemtest.txt
- fi
-
- echo " " >>/tmp/modemtest.txt
- echo "If you think that this is a Lucent Linmodem (Linux-compatible" >>/tmp/modemtest.txt
- echo -e "software modem), press the \"ttyLT0\" button to test it." >>/tmp/modemtest.txt
- if [ ! "$TTYLT0" ];then
- echo "HOWEVER, first download the Lucent modem package from the pupget folder" >>/tmp/modemtest.txt
- echo -e "on ibiblio.org, run PupGet package manager to install." >>/tmp/modemtest.txt
- echo "Then, rerun this Wizard and will see \"ttyLT0\" button." >>/tmp/modemtest.txt
- fi
- echo " " >>/tmp/modemtest.txt
-
- echo "If you think that this is a Smart Link HAMR5600 based AMR/CNR/" >>/tmp/modemtest.txt
- echo "MDC/ACR PCI linmodem, SmartPCI56/561/562/563 based PCI linmodem," >>/tmp/modemtest.txt
- echo "or SmartUSB56 based USB linmodem, press the \"ttySL0\" button." >>/tmp/modemtest.txt
- if [ ! "$TTYSL0" ];then
- echo "HOWEVER, first download the Smartlink modem package from the pupget folder" >>/tmp/modemtest.txt
- echo -e "on ibiblio.org, run PupGet to install, then REBOOT Puppy." >>/tmp/modemtest.txt
- echo "Then, rerun this Wizard and will see \"ttySL0\" button." >>/tmp/modemtest.txt
- fi
- echo " " >>/tmp/modemtest.txt
-
- echo "If you have a hardware modem, PCI, ISA bus or external serial," >>/tmp/modemtest.txt
- echo -e "you can press one of the \"ttyS*\" buttons to find out which" >>/tmp/modemtest.txt
- echo "port it is on." >>/tmp/modemtest.txt
- echo "Note, ttyS0 is COM1, ttyS1 is COM2, etc." >>/tmp/modemtest.txt
- echo " " >>/tmp/modemtest.txt
-
- echo -e "If uncertain, press the \"HELP\" button, otherwise" >>/tmp/modemtest.txt
- echo -en "press a \"tty*\" button to test if a modem is present..." >>/tmp/modemtest.txt
-
- fi
-
- while :; do
- xmessage -bg "#c0c0ff" -center -name "xutilities" -title "Puppy Modem Wizard" -buttons \
- "$BUTTONS" -file /tmp/modemtest.txt
-
- case ${?} in
- 10)# ttyS0
- testmodem /dev/ttyS0
- ;;
- 11)#
- testmodem /dev/ttyS1
- ;;
- 12)#
- testmodem /dev/ttyS2
- ;;
- 13)#
- testmodem /dev/ttyS3
- ;;
- 14)#
- testmodem /dev/ttyS4
- ;;
- 15)# = save
- if [ ! "$DEVM" ];then
- wavplay -q /usr/share/audio/error.wav &
- xmessage -bg "#ffc0c0" -center -name "xutilities" -title "Puppy Modem Wizard" -file -<<MSG1
- Huh? You have not yet selected a modem port,
- so nothing to save.
- MSG1
- else
- echo -n "$DEVM" >/etc/modemdevice
- #note, rc.local0 will link /dev/modem to this at bootup,
- #however do it now also (not remembered next bootup)...
- rm -f /dev/modem
- ln -s $DEVM /dev/modem
- wavplay -q /usr/share/audio/ok.wav &
- echo "You have configured Puppy for $DEVM (and irq=$IRQM)" >/tmp/modemtest.txt
- #echo "Note, a dialup icon has been created on the desktop," >>/tmp/modemtest.txt
- #echo "but you need to restart the window manager to see it." >>/tmp/modemtest.txt
- echo "Note, there is a 'connect' icon on the desktop." >>/tmp/modemtest.txt
- echo -n -e "Press \"EXIT\" to get out..." >>/tmp/modemtest.txt
- BUTTONS="EXIT:18"
- echo '#!/bin/sh' > /usr/local/bin/defaultconnect
- echo 'exec gkdial' >> /usr/local/bin/defaultconnect
- ##v1.0.5 this also done in rc.local0 if not here...
- #if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep "defaultdialup"`" = "" ];then
- # if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep 'x=\"32\" y=\"512\"'`" = "" ];then
- # echo '<icon x="32" y="512" label="dialup">/usr/local/bin/defaultdialup</icon>' >> /root/Choices/ROX-Filer/PuppyPin
- # else
- # echo '<icon x="224" y="512" label="dialup">/usr/local/bin/defaultdialup</icon>' >> /root/Choices/ROX-Filer/PuppyPin
- # fi
- # cat /root/Choices/ROX-Filer/PuppyPin | grep -v '/pinboard' > /tmp/PuppyPin-CPY
- # sync
- # cp -f /tmp/PuppyPin-CPY /root/Choices/ROX-Filer/PuppyPin
- # echo '</pinboard>' >> /root/Choices/ROX-Filer/PuppyPin
- #fi
- fi
- ;;
- 16)# = erase
- echo "All configuration of the modem, if any, has been erased" >/tmp/modemtest.txt
- echo -n -e "Press \"EXIT\" to get out..." >>/tmp/modemtest.txt
- rm -f /dev/modem
- rm -f /etc/modemdevice
- grep -v --extended-regexp "ltserial|slamr|slusb" /etc/modprobe.conf > /tmp/modprobe.conf
- sync
- mv -f /tmp/modprobe.conf /etc/modprobe.conf
- BUTTONS="EXIT:18"
- ;;
- 17)# HELP
- dillo file:///usr/share/doc/HOWTO_Internet.htm &
- ;;
- 18)# = exit
- break;;
- 0)# exit
- break;;
- 1)# exit
- break;;
- 20) #Lucent Linmodem (refer rc.network)
- if [ -e /lib/modules/2.4 ];then
- lsmod | grep "lt_serial" > /dev/null 2>&1
- if [ ! $? -eq 0 ];then #=0 found.
- if [ "`cat /etc/$MODCONF | grep "lt_serial"`" = "" ];then
- #rc.network will do this properly at next boot...
- echo "#Needed for Lucent Linmodem..." >> /etc/$MODCONF
- echo "alias char-major-62 lt_serial" >> /etc/$MODCONF
- echo "alias /dev/ttyLT0 lt_serial" >> /etc/$MODCONF
- echo "alias /dev/modem lt_serial" >> /etc/$MODCONF
- fi
- modprobe lt_serial #also loads lt_modem
- if [ ! $? -eq 0 ];then
- xmessage -center "Failed to load module. Did you remember to reboot Puppy
- after installing the Lucent driver PupGet package?
- Click OK button to continue..."
- fi
- sleep 1
- fi
- else
- lsmod | grep "ltserial" > /dev/null 2>&1
- if [ ! $? -eq 0 ];then #=0 found.
- if [ "`cat /etc/$MODCONF | grep "ltserial"`" = "" ];then
- #rc.network will do this properly at next boot...
- echo "alias char-major-62 ltserial" >> /etc/$MODCONF
- echo "alias /dev/ttyLT0 ltserial" >> /etc/$MODCONF
- echo "alias /dev/modem ltserial" >> /etc/$MODCONF
- fi
- modprobe serial_core 2> /dev/null
- ##cannot use modprobe...
- ##this k2.6 version of insmod cannot handle compressed modules...
- #gunzip -c /usr/lib/modules/ltmodem/ltmodem.ko.gz | insmod -
- #gunzip -c /usr/lib/modules/ltmodem/ltserial.ko.gz | insmod -
- modprobe ltmodem
- modprobe ltserial
- sleep 1
- fi
- fi
- testmodem /dev/ttyLT0
- ;;
- 21) #smartlink linmodem (refer rc.network)
- #v2.02 rerwin, remove lsmod and if...
- #lsmod | grep "slamr" > /dev/null 2>&1
- #if [ ! $? -eq 0 ];then #=0 found.
- #v2.02 rerwin, code block moved down below else...
- #fi
- #need to choose country...
- SLCOUNTRY="`Xdialog --wmclass "smartlinkwizard" --title "Smart-Link Modem Wizard" --stdout --no-tags \
- --menubox "Please choose your country:" 0 0 0 \
- ALGERIA Algeria \
- ARGENTINA Argentina \
- AUSTRALIA Australia \
- AUSTRIA Austria \
- BAHREIN Bahrein \
- BELGIUM Belgium \
- BRAZIL Brazil \
- BRUNEI Brunei \
- BULGARIA Bulgaria \
- CANADA Canada \
- CHILE Chile \
- CHINA China \
- CTR21EUROPE CTR21_Europe \
- CYPRUS Cyprus \
- CZECH_REPUBLIC Czech_Replublic \
- DENMARK Denmark \
- EGYPT Egypt \
- ESTONIA Estonia \
- FINLAND Finland \
- FRANCE France \
- GERMANY Germany \
- GREECE Greece \
- HONG_KONG Hong_Kong \
- HUNGARY Hungary \
- ICELAND Iceland \
- INDIA India \
- INDONESIA Indonesia \
- IRELAND Ireland \
- ISRAEL Israel \
- ITALY Italy \
- JAPAN Japan \
- JORDAN Jordan \
- KOREA Korea \
- KUWAIT Kuwait \
- LATVIA Latvia \
- LEBANON Lebanon \
- LITHUANIA Lithuania \
- LUXEMBOURG Luxembourg \
- MALAYSIA Malaysia \
- MALTA Malta \
- MEXICO Mexico \
- MOROCCO Morocco \
- NETHERLANDS Netherlands \
- NEW_ZEALAND New_Zealand \
- NORWAY Norway \
- OMAN Oman \
- PAKISTAN Pakistan \
- PERU Peru \
- PHILIPPINES Philippines \
- POLAND Poland \
- PORTUGAL Portugal \
- ROMANIA Romania \
- RUSSIA Russia \
- SAUDIARABIA Saudi_Arabia \
- SINGAPORE Singapore \
- SLOVAKIA Slovakia \
- SLOVENIA Slovenia \
- SOUTHAFRICA South_Africa \
- SOUTHKOREA South_Korea \
- SPAIN Spain \
- SRILANKA Sr_Lanka \
- SWEDEN Sweden \
- SWITZERLAND Switzerland \
- TAIWAN Taiwan \
- THAILAND Thailand \
- TUNISIA Tunisia \
- TURKEY Turkey \
- UAE UAE \
- UK UK \
- URUGUAY Uruguay \
- USA USA \
- VIETNAM Vietnam 2> /dev/null`"
-
- if [ ! $? -eq 0 ];then
- xmessage "ABORT: You did not select a country!!!"
- else
- #v2.02 rerwin, code block moved down...
- if [ "`cat /etc/$MODCONF | grep "slamr"`" = "" ];then
- #rc.network will do this properly at next boot...
- #echo "#Needed for Smartlink Linmodem..." >> /etc/$MODCONF
- #v2.01 rerwin found 212,213 need to be changed to 242,243...
- echo "alias char-major-242 slamr" >> /etc/$MODCONF
- #v2.02 rerwin...
- echo 'install slamr modprobe --ignore-install ungrab-winmodem ; modprobe --ignore-install slamr' >> /etc/modprobe.conf
- echo "alias char-major-243 slusb" >> /etc/$MODCONF
- fi
- #v2.01 modprobe usbcore 2> /dev/null
- #v2.01 bug, rerwin found needs ungrab-winmodem before load slamr...
- #v2.02 rerwin, rmmod...
- rmmod slamr #unload for ungrab, in case slamr misloaded as serial driver.
- modprobe ungrab-winmodem
- modprobe slamr
- [ ! $? -eq 0 ] && xmessage -center "Failed to load slamr module."
- if [ ! "`lsmod | grep '^usbcore'`" = "" ];then #v2.01
- modprobe slusb
- [ ! $? -eq 0 ] && xmessage -center "Failed to load slusb module."
- fi
-
- #choose usb or pci modem...
- MYSLMODEM="`Xdialog --wmclass "smartlinkwizard" --title "Smart Link Modem Wizard" --stdout --no-tags \
- --menubox "Please choose type of Smart-Link modem:" 0 0 0 \
- slusb "USB" \
- slamr "PCI (internal card)" 2> /dev/null`"
- if [ ! $? -eq 0 ];then
- xmessage "ABORT: You did not choose modem type!!!"
- else
- #start slmodemd...
- echo "#/bin/sh" > /usr/sbin/slmodemdshell
- echo "/usr/sbin/slmodemd --country=$SLCOUNTRY /dev/${MYSLMODEM}0" >> /usr/sbin/slmodemdshell
- sync
- chmod 755 /usr/sbin/slmodemdshell
- /usr/sbin/slmodemdshell &
- sleep 1
- #test modem...
- testmodem /dev/ttySL0
- fi
- fi
-
- ;;
- esac
- done
- rm -f /tmp/modemtest.txt
- rm -f /tmp/answer.txt
-
- #END#
-