#!/bin/bash # Contributed by: 161211 sfs
export DISPLAY=":0"

. "$SUBR_DIR/ip"
Interface=ppp0
# Make sure BindsToInterfaces is set
BindsToInterfaces=("${BindsToInterfaces[@]}")

wvdial_up() {
    if is_interface "$Interface"; then
        report_error "Interface '$Interface' already exists"
        return 1
    fi

    #ntf -i "prov=$Prov  pin=$Pin "$Interface"" &
    wvdialconf 1>/dev/null 2>/dev/null
    if [ "$Pin" ] ;then
	sed -i 's/^Init1 = AT+CPIN=.*/Init1 = AT+CPIN="'$Pin'"/' /etc/wvdial.conf && wvdial pin
    fi
    wvdial "$Prov" 1>/dev/null 2>/dev/null &
#    [ "`pgrep -f traygsm |wc -l`" -gt "2" ] || (sleep 5 && traygsm) &
##    [ "`pgrep -f traygsm`" ] || (sleep 5 && `which sudo` traygsm) &
#    interface_add dummy "$Interface"
#    bring_interface_up "$Interface"
#    ip_set
}

wvdial_down() {
    #ip_unset
    [ "`ifconfig | egrep "^$Interface: "`" ] || exit 0
    interface_delete "$Interface"
    killall wvdial 1>/dev/null  2>/dev/null
    #ntf -i "down $Prov" &
}


# vim: ft=sh ts=4 et sw=4:
