# $Id: synce-serial-common.in,v 1.4 2005/07/08 19:04:42 twogood Exp $
#
# vim: syntax=sh
#
# Common functions and declarations for the synce-serial scripts
#

LOGGER="logger -t ${THIS}"
FACILITY=user
ERROR="${LOGGER} -p ${FACILITY}.err"
WARNING="${LOGGER} -p ${FACILITY}.warning"
NOTICE="${LOGGER} -p ${FACILITY}.notice"
INFO="${LOGGER} -p ${FACILITY}.info"
DEBUG="${LOGGER} -p ${FACILITY}.debug"

PPP_OPTIONS=/etc/ppp/options
PPP_PEERS=/etc/ppp/peers
PPPD=/usr/sbin/pppd

PEER=synce-device
PEER_FILE=${PPP_PEERS}/${PEER}

COMMAND="${PPPD} call ${PEER}"

# see the "linkname" option in the man page for pppd
PID_FILE=/var/run/ppp-synce-device.pid

DEFAULT_IPS=192.168.131.102:192.168.131.201

exit_if_not_root()
{
	if [ "`id -u`" -ne "0" ]; then
		echo "Sorry, you need root privileges to run ${THIS}."
		exit 1
	fi
}

get_pid()
{
	if [ -f "${PID_FILE}" ]; then
		PID=`head -1 ${PID_FILE}`
	else
		PID=
	fi

	# pid empty?
	if [ -z "${PID}" ]; then
		return
	fi

	# pid invalid somehow?
	if ! kill -0 "${PID}"; then
		PID=
	fi

}

