The program which waits for a dial-in, answers the call and provides a login prompt is called getty. Although there are several versions of getty for Linux, the package I shall describe here is called getty_ps, after the author, Paul Sutcliffe Jr. It has the big advantage of being able to reinitialise the modem automatically after every call.
getty in turn is launched by a process called init, the "mother of all processes", which automatically starts a new getty process each time one is needed (e.g. when one person's call has finished and the system needs to wait for another call).
To tell init to do this, you add entries to /etc/inittab, and once you have made the changes, type telinit q to signal to init (which is always process number 1) that its configuration has changed. For example, you could add two lines to /etc/inittab like this:
Red Hat 4.1
d1:2345:respawn:/sbin/uugetty ttyS0 F38400 vt100 d2:2345:respawn:/sbin/uugetty ttyS1 F38400 vt100Slackware 3.1
d1:2345:respawn:/sbin/uugetty ttyS0 38400 vt100 d2:2345:respawn:/sbin/uugetty ttyS1 38400 vt100These lines set up two getty processes, one on ttyS0 and one on ttyS1. The labels 'd1' and 'd2' are arbitary. The values 2345 show which of the system "run levels" these processes will be run in. Normally the system is in run level 3 or 5. The "uu" in the name of the program refers to the uucp package; with uugetty you can have both dial-in and dial-out on the same line, and this was originally intended for use with uucp.
The next parameter (F)38400 is not actually a speed, but a reference to an entry in the file /etc/gettydefs. It is in this file that you set the speed for each line and the serial port parameters. Generally this file doesn't need to be changed. The last parameter, vt100, gives the default terminal type which will be chosen when the user logs in, stored in the TERM environment variable.
Finally, the getty program needs to know what commands to send to and expect from the modem. The file is called
/etc/conf.uugetty.[line] (Red Hat 4.1) /etc/default/uugetty.[line] (Slackware 3.1)where [line] is the name of the port - e.g. /etc/conf.uugetty.ttyS0.
A sample /etc/conf.uugetty file is shown below. It should be adequate for most modems, as long as you have disabled auto-answer (ATS0=0), enabled verbose result codes (ATV1Q0), and stored all parameters with AT&W. Note that every line needs to have a different configuration file, because of the INITLINE= parameter which needs to be the name of the dial-out device (cuax) corresponding to this line.
# After changing this file, use 'ps' to find the process number of the # uugetty process, and send it a kill 'kill <process-no>' # init will then automatically re-run the process. # Debug chat scripts to /var/log/debug. Comment this out when getty # is working properly DEBUG=010 # Line to send initialisation string on (e.g. if this is conf.uugetty.ttyS0 # then we must set INITLINE=cua0) INITLINE=cua0 # OPTIONAL: File to display when user logs in (instead of /etc/issue) ISSUE=/etc/issue.modem # How long to allow the user to type in a username TIMEOUT=60 # Don't send a clear-screen code to the user's terminal CLEAR=NO # Modem initialisation chat script INIT="" \pATZ\r \T5OK\r\n-ATZ\r-\T5OK\r\n AT\r OK\r\n # Connect script (final \p gives one second delay before # displaying the login banner) WAITFOR=RING DELAY=1 CONNECT="" ATA\r \T30CONNECT \pNote that \T30 in the chat script means "set timeout for next expect string to 30 seconds", \r\n means send (or expect) a carriage return and line feed, and \p means a 1-second pause. You also need to create a file /etc/issue.modem which is displayed when the user logs in from outside; or you can comment out this line and the default /etc/issue will be used instead. (Aside: you can also create a file "/etc/issue.net", which overrides /etc/issue for incoming telnets)
Slackware users BEWARE: uugetty will not work like this in Slackware 3.1 as installed, because it writes its lock files into /var/spool/uucp instead of /var/lock. The easiest solution, so you don't have to recompile uugetty, is to remove /var/lock and replace it with a symbolic link to /var/spool/uucp, like this:
rm -rf /var/lock ln -s /var/spool/uucp /var/lock
Red Hat users NOTE: To get debugging information logged in Red Hat 4.1, you have to add an extra line to /etc/syslog.conf
*.=debug /var/log/debugthen notify syslogd with 'killall -1 syslogd'
You can also configure uugetty to allow the modem to auto-answer the phone itself (ATS0=1); to do so, just remove the WAITFOR= and CONNECT= lines. However the problem here is that if you are talking to the modem using 'cu', and an incoming call comes in, the call will still be answered.