#!/bin/sh
#
# diald         This shell script takes care of starting and stopping
#               diald (demand dialing daemon).
#
# Modifications to the to the diald distribution's "diald.init" file
# are distributed under the GNU copyright (c) 1997 The Meme Factory,
# Inc.  http://www.meme.com
#
# March 27, 1997 Karl O. Pinc  Remove dynamic m4 config files
#

# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/sbin/diald ] || exit 0

[ -f /etc/diald.conf ] || exit 0

cd /etc/sysconfig/network-scripts/

IFPREFIX="dialdcfg-"

# See how we were called.
case "$1" in
  start)
	# Start a diald daemon for each interface.
        echo -n "Starting diald: "
	for ifile in $(ls /etc/sysconfig/network-scripts/${IFPREFIX}*) ; do
          ifile="$(basename $ifile)"
          iname=$(echo "$ifile" | sed "s/^${IFPREFIX}//")
	  ! ./diald-up "$ifile" || echo -n "$iname "
        done
        echo
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down diald: "
	for ifile in $(ls /etc/sysconfig/network-scripts/${IFPREFIX}*) ; do
          ifile="$(basename $ifile)"
          iname=$(echo "$ifile" | sed "s/^${IFPREFIX}//")
	  ! ./diald-down $ifile || echo -n "$iname "
        done
        echo
        ;;
  *)
        echo "Usage: diald {start|stop}"
        exit 1
esac

exit 0

