#!/bin/sh -e


THIS=`basename $0`

# include common stuff
. /usr/share/synce/synce-serial-common

exit_if_not_root

pppopts="nodefaultroute noauth local crtscts"
if [ -t 1 ]; then
  pppopts="$pppopts updetach"
fi

: ${SYNCE_DEV:=$DEFAULT_DEV}
if [ ! -e ${SYNCE_DEV} ]; then
  $ERROR "Device '$SYNCE_DEV' does not exist"
  exit 1
fi

# Shut off the connection in case it's running.
synce-serial-abort-device >/dev/null 2>&1

# Now bring up the connection
${SYNCE_PPP:-$PPPD} ${SYNCE_DEV} ${SYNCE_DEVSPEED:-115200} connect ${SYNCE_PPP_CONNECT:-/usr/lib/synce-serial/synce-serial-chat} ${SYNCE_IPADDR:-$DEFAULT_IPS} ms-dns ${SYNCE_DNS:-$DEFAULT_LOCAL_IP} linkname ${SYNCE_DEVNAME:-$PEER} $pppopts $SYNCE_PPP_OPTIONS
