/usr/share/synce/synce-serial-common is in synce-serial 0.11-5.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | # $Id: synce-serial-common.in 3078 2007-12-12 07:50:04Z mark_ellis $
#
# vim: syntax=sh
#
# Common functions and declarations for the synce-serial scripts
#
export PATH="/usr/sbin:$PATH"
BINDIR=/usr/sbin
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"
SYSFS="/sys"
PPP_OPTIONS=/etc/ppp/options
PPP_PEERS=/etc/ppp/peers
PPPD=/usr/sbin/pppd
VAR_PPP=/var/run
DEVICE_PREFIX=synce-device
PEER=$DEVICE_PREFIX
PEER_FILE=${PPP_PEERS}/${PEER}
# this is the default device file, rarely required
# see synce-serial-config
CONFIG_FILE=/etc/synce-serial.default
COMMAND="${PPPD} call ${PEER}"
# see the "linkname" option in the man page for pppd
PID_FILE=/var/run/ppp-$PEER.pid
# include alternate settings file if it exists
if [ -e "/etc/synce-serial.conf" ]; then
. /etc/synce-serial.conf
fi
DEFAULT_NETWORK=${DEFAULT_NETWORK:-"192.168.131"}
DEFAULT_LOCAL_IP=$DEFAULT_NETWORK.102
DEFAULT_REMOTE_IP=$DEFAULT_NETWORK.201
DEFAULT_IPS=$DEFAULT_LOCAL_IP:$DEFAULT_REMOTE_IP
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
}
synce_dev_setup()
{
synce_cmdline_setup "$1"
}
synce_cmdline_help()
{
echo "Usage: $THIS serial-device [localip:remoteip [dns_server]]" >&2
}
# Usage: synce_cmdline_setup /dev/path [localip:remoteip [dns_server]]
# Typically: synce_cmdline_setup "$@"
synce_cmdline_setup()
{
if [ -z "$1" -o "$1" = "--help" ]; then
synce_cmdline_help
exit 1
fi
if [ -c $1 ]; then
SYNCE_DEV=$1;
else
if [ -c /dev/$1 ]; then
SYNCE_DEV=/dev/$1
else
echo "
ERROR:
${THIS} was unable to find a character device named \"$1\"
Run \"${THIS} --help\" to get help.
" >&2
exit 1
fi
fi
SYNCE_DEVNUM="`echo "$SYNCE_DEV" |sed -e 's/^[^0-9]*\([0-9]*\)$/\1/'`"
if [ -z "$SYNCE_DEVNUM" ]; then
SYNCE_DEVNUM=0
fi
# Add 120 for /dev/ttyS*, to support both standard serial
# and USB
if echo "$SYNCE_DEV" |grep ttyS >/dev/null 2>&1; then
SYNCE_DEVNUM="`expr $SYNCE_DEVNUM + 120`"
fi
SYNCE_DEVNAME="$DEVICE_PREFIX$SYNCE_DEVNUM"
if [ "$2" ]; then
if ! (echo $2 | grep -b '^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*:[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$'); then
echo "
ERROR:
The format of \"$2\" looks incorrect.
Run \"${THIS} --help\" to get help.
" >&2
exit 1
fi
SYNCE_IPADDR="$2"
SYNCE_LOCALIP="`echo "$2" |sed -e 's/^.*://'`"
SYNCE_REMOTEIP="`echo "$2" |sed -e 's/:.*$//'`"
else
SYNCE_LOCALIP="$DEFAULT_NETWORK.`expr 1 + $SYNCE_DEVNUM`"
SYNCE_REMOTEIP="$DEFAULT_NETWORK.`expr 129 + $SYNCE_DEVNUM`"
SYNCE_IPADDR="$SYNCE_LOCALIP:$SYNCE_REMOTEIP"
fi
if [ "$3" ]; then
SYNCE_DNS="$3"
else
SYNCE_DNS="$SYNCE_LOCALIP"
fi
export SYNCE_DEV SYNCE_DEVNUM SYNCE_LOCALIP SYNCE_REMOTEIP SYNCE_DEVNAME SYNCE_IPADDR SYNCE_DNS
}
synce_dumpenv()
{
env |grep '^SYNCE' |sed -e 's/^/export /'
}
|