#!/bin/sh -e

# Author: Benoit PAPILLAULT <benoit.papillault@free.fr>
# Creation: 13/05/2005

# Ensure to have a working PATH
prefix=/usr
exec_prefix=/usr
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/bin

setup_remover() {
  [ "$REMOVER" ] && [ ! -d "$REMOVER" ] || return 0

cat > "${REMOVER}" <<EOF
#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin:/usr/sbin

speedtouch-stop -d "${DEVICE}"

# remove the file used by speedtouch-start to indicate that the modem
# has been initialized

rm -f /var/run/speedtouch-up

EOF

  chmod +x "${REMOVER}"
  return 0
}

########################################################

######################
case "$ACTION" in
  add)
    while ! touch "${REMOVER}"; do
	sleep 2;
    done
    speedtouch-start -d "${DEVICE}" --boot
    setup_remover
    ;;
esac

exit 0

