#!/usr/local/sbin/slipsh
#
# Sample slips script. Customize by setting the variables below
# to apropriate values. Mode can be one of SLIP, CSLIP, ADAPTIVE,
# and SLIP6.
#
# This script takes up the SLIP link, and waits until either the link
# comes down, or it is signalled to do so.
#
set device	ttyS1
set telnos	555-1234
# or: 
#set telnos	{555-1234 555-6789}
set login	joedoe
set passwd	melrose
set retries	6
set mode	CSLIP
set local	myhost.fnord.org
set remote	otherhost.foobar.com

source /usr/local/lib/slipsh/common.tcl

#
# lock and open device
#
tty lock $device
set ttyfd [tty open -user root -group tty -mode 0664 $device]

#
# dial the remote system and log in
#
set dial [dialup $device $ttyfd $telnos $login $passwd $retries]
if {$dial != ""} {
    tty close $ttyfd
    tty unlock $device
    exit 2
}

#
# Convert line to SLIP, and set up the routes
#
set iface [setslip $mode $ttyfd $local $remote]
route add $remote dev $iface
route add default gw $remote

#
# become daemon and wait forever
#
set pid [daemon $device $ttyfd]
if {$pid != 0} {
	# We're the parent process. Write the system lock and exit
	log_pid $pid $remote $iface
	exit 0
}

sys pause
