#!/bin/sh
# This script is run from /etc/mdev.conf when hotplugging USB devices
# When mdev creates /dev/ttyUSBx each node gets created twice, which makes
# this script also run twice. The lock is to prevent ifup to run twice.
# (not activated)
#
# Robin Stridh <robin.stridh@acte.se>

MODEM=$(readlink /etc/ppp/peers/provider)
LOCK=/var/lock/$MDEV
UP_DOWN=$1

# If another pppd is running on this port we give up
[ -e $LOCK ] && exit
# PH8 creates both ttyUSB0 and ttyUSB3. We only wan't ttyUSB3
[ MODEM == "ph8" -a $MDEV == ttyUSB0 ] && exit

touch $LOCK
if${UP_DOWN} -f ppp0
rm $LOCK
