This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
guides:virtual_modem:script [2020-02-27 23:20] omolini [3.sh] |
guides:virtual_modem:script [2021-01-24 23:39] omolini |
||
---|---|---|---|
Line 17: | Line 17: | ||
# VMODEM - Virtual Modem bootstrap | # VMODEM - Virtual Modem bootstrap | ||
# -------------------------------- | # -------------------------------- | ||
- | # Oliver Molini 2019 | + | # Oliver Molini 2021 |
# | # | ||
# Billy Stoughton II for bug fixes and contributions | # Billy Stoughton II for bug fixes and contributions | ||
Line 24: | Line 24: | ||
# https://creativecommons.org/licenses/by-nc-sa/4.0/ | # https://creativecommons.org/licenses/by-nc-sa/4.0/ | ||
- | # Tested working out of box with the following host configurations: | + | # Tested working out of box with the following client configurations: |
# | # | ||
# o Standard VT100 terminal | # o Standard VT100 terminal | ||
Line 35: | Line 35: | ||
# - Trumpet Winsock | # - Trumpet Winsock | ||
# | # | ||
- | # o Microsoft Windows 95 | + | # o Microsoft Windows 95 OSR 2.5 + DUN 1.4 |
# - Generic | # - Generic | ||
# - Standard 28800 bps Modem | # - Standard 28800 bps Modem | ||
Line 49: | Line 49: | ||
# Script version | # Script version | ||
- | vmodver=1.4.1 | + | vmodver=1.5.3 |
# CONFIGURATION | # CONFIGURATION | ||
Line 55: | Line 55: | ||
# Variable: serport | # Variable: serport | ||
# serport specifies which local serial device to use. | # serport specifies which local serial device to use. | ||
- | # For example, using "ttyAMA0" will tell the script | + | # For example, "ttyUSB0" will tell the script to use |
- | # to use /dev/ttyAMA0 for communication. | + | # to use /dev/ttyUSB0 for communication. |
+ | # Common values: ttyUSB0 or ttyAMA0 | ||
# | # | ||
- | # Default: | + | serport=ttyUSB0 |
- | # serport=ttyAMA0 | + | |
- | # | + | |
- | serport=ttyAMA0 | + | |
# Variable: baud | # Variable: baud | ||
Line 76: | Line 74: | ||
#baud=38400 | #baud=38400 | ||
baud=57600 | baud=57600 | ||
+ | |||
+ | # Variable: etherp | ||
+ | # Sets the name of the ethernet device for PPP connections. | ||
+ | # Usually eth0 for wired and wlan0 for wireless. | ||
+ | # | ||
+ | etherp=eth0 | ||
# Variable: echoser | # Variable: echoser | ||
Line 103: | Line 107: | ||
export serport | export serport | ||
export baud | export baud | ||
+ | export etherp | ||
export TERM | export TERM | ||
Line 122: | Line 127: | ||
echo -en "$1\x0d\x0a" >/dev/$serport | echo -en "$1\x0d\x0a" >/dev/$serport | ||
} | } | ||
+ | |||
+ | export -f sendtty | ||
+ | export -f ttyinit | ||
# Open serial port for use. Allocate file descriptor | # Open serial port for use. Allocate file descriptor | ||
Line 228: | Line 236: | ||
number=`echo $seq |tr -dc '0-9'` | number=`echo $seq |tr -dc '0-9'` | ||
if [ ! -z "$number" ]; then | if [ ! -z "$number" ]; then | ||
- | if [[ $resultverbose == 1 ]]; then sendtty "RINGING"; fi | + | if [[ $resultverbose == 1 ]]; then sendtty "RINGING"; sleep 1; fi |
if [ -f "$number.sh" ]; then | if [ -f "$number.sh" ]; then | ||
if [[ $resultverbose == 1 ]]; then sendtty "CONNECT $baud"; else sendtty "1"; fi | if [[ $resultverbose == 1 ]]; then sendtty "CONNECT $baud"; else sendtty "1"; fi | ||
- | # Close serial port | + | # Execute dialed script! |
- | exec 99>&- | + | |
- | # Execute dialed script | + | # For compatibility, explicitly tell the terminal to default to CR/LF |
+ | # when pressing enter, to avoid cases where the terminal just sends CR. | ||
+ | echo -en "\x1b[20h" > /dev/$serport | ||
+ | |||
+ | # Run script with getty | ||
/sbin/getty -8 -L $serport $baud $TERM -n -l "./$number.sh" | /sbin/getty -8 -L $serport $baud $TERM -n -l "./$number.sh" | ||
+ | | ||
# Reset serial settings | # Reset serial settings | ||
ttyinit | ttyinit | ||
- | # Reopen serial port | ||
- | exec 99<>/dev/$serport | ||
result=3 | result=3 | ||
else | else | ||
Line 289: | Line 300: | ||
if [[ $cmd == LOGIN ]]; then | if [[ $cmd == LOGIN ]]; then | ||
exec 99>&- | exec 99>&- | ||
- | /sbin/getty -8 -L ttyAMA0 $baud vt100 | + | /sbin/getty -8 -L $serport $baud $TERM |
ttyinit | ttyinit | ||
exec 99<>/dev/$serport | exec 99<>/dev/$serport | ||
Line 318: | Line 329: | ||
When Trumpet Winsock is in PPP mode, by default it will expect the following output after dialing the ISP's number and establishing a connection: | When Trumpet Winsock is in PPP mode, by default it will expect the following output after dialing the ISP's number and establishing a connection: | ||
- | * A username prompt, matched by the text "sername:" | + | * A username prompt, matched by Trumpet with the text "sername:" |
- | * A password prompt, matched by the text "ssword:" | + | * A password prompt, matched by Trumpet with the text "ssword:" |
- | * A command prompt, matched by the text ">" | + | * A command prompt, matched by Trumpet with the character ">" |
This script has been tested with the default installation of Trumpet Winsock 3.0 revision D with PPP mode switched on. This script has also been tested with the default dial-up utility of Windows 95 and Windows 98 with PPP enabled. | This script has been tested with the default installation of Trumpet Winsock 3.0 revision D with PPP mode switched on. This script has also been tested with the default dial-up utility of Windows 95 and Windows 98 with PPP enabled. | ||
Line 330: | Line 341: | ||
# RUN PPPD DAEMON | # RUN PPPD DAEMON | ||
# | # | ||
- | # Oliver Molini 2019 | + | # Oliver Molini 2020 |
# | # | ||
# Billy Stoughton II for bug fixes and contributions | # Billy Stoughton II for bug fixes and contributions | ||
Line 343: | Line 354: | ||
# Variable: etherp | # Variable: etherp | ||
- | # Specify the ethernet device to use to connect to your network. | + | # Override the ethernet device to use to connect to your network. |
- | # | + | # This is set in vmodem.sh, but can be overridden here. |
- | # Default: etherp=eth0 | + | # |
- | etherp=eth0 | + | # Default: #etherp=eth0 (commented out) |
+ | #etherp=eth0 | ||
# Variable: lcpidle | # Variable: lcpidle | ||
Line 401: | Line 413: | ||
echo | echo | ||
echo "Please enter your name: " | echo "Please enter your name: " | ||
- | read username | + | read -e -p "User? " username |
echo | echo | ||
echo "Hello, $username!" | echo "Hello, $username!" | ||
Line 407: | Line 419: | ||
echo "Thank you for visiting! Bye!" | echo "Thank you for visiting! Bye!" | ||
sleep 2 | sleep 2 | ||
+ | |||
</code> | </code> | ||
Line 415: | Line 428: | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
- | echo "Terminal type set to $TERM. Running Lynx ..." | + | sendtty "Terminal type set to $TERM. Running Lynx ..." |
lynx | lynx | ||
</code> | </code> | ||