#!/bin/bash
# Network Interface Configuration System
# Copyright (c) 1996-2002 Red Hat, Inc. all rights reserved.
#
# This software may be freely redistributed under the terms of the GNU
# public license.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

DEVICE=${1}

[ -z "${DEVICE}" ] && {
    echo $"Usage: isdnup <ISDN device name>" >&2
    exit 1
}

if [ -x /sbin/ifup ] ; then
    /sbin/ifup ${DEVICE} || exit 1
    sleep 2
else
    echo $"/sbin/ifup does not exist"
    exit 1
fi

if [ ${UID} != 0 ]; then
    if [ -x /usr/sbin/userisdnctl ]; then
        /usr/sbin/userisdnctl dial ${DEVICE} >& /dev/null
        sleep 4
    else
        echo $"Users cannot control this device." >&2
        exit 1
    fi
else
    if [ -x /sbin/isdnctrl ]; then
        /sbin/isdnctrl dial ${DEVICE} >& /dev/null
        sleep 4
    else
        echo $"/sbin/isdnctrl does not exist." >&2
        exit 1
    fi
fi

exit $?
