Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > 4aadd45f221424a24a93e5fc1e8faba3 > files > 70

diald-1.0-12mdv2010.0.x86_64.rpm

#!/bin/sh
#
# (C) Copyright 1995-1999  Mike Jagdis <jaggy@purplet.demon.co.uk>
#
#
# Configure the managed interfaces.
#
# This script would normally be installed as /etc/rc.ddiface,
# /etc/init.d/ddiface, /etc/rc[1-5].d/SXXddiface or similar
# depending on your system religion.


# CONFIGURABLE STUFF

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

config_dir=/etc/diald

# END OF CONFIGURABLE STUFF


action="$1"
shift
interfaces="$*"


if [ -n "$BASH_VERSION" ]; then
	enable echo
	enable kill
	use_escapes='-e'
else
	use_escapes=''
fi


case "${action}" in
	start)
		# Try and load compression modules before doing
		# anything that might load SLIP/PPP modules.
		modprobe bsd_comp ppp_deflate > /dev/null 2>&1

		echo $use_escapes "Configuring managed interfaces:\c"

		cd "$config_dir"
		for link in ${interfaces:-*}
		do
			if [ -d "$link" -a -r "$link/config" ]; then
				echo $use_escapes " $link\c"
				diald -f "$config_dir/$link/config" \
					pidfile "diald.$link"
			fi
		done

		echo
		;;

	stop)
		if [ -z "$interfaces" ]; then
			pids=`cat /var/run/diald.* 2> /dev/null`
		else
			# FIXME: If we take down all the interfaces using
			# a single, generic ipppd we ought to take that
			# down too. But how do we know?
			pids=`for link in $interfaces; do
				cat "/var/run/diald.$link"
			done 2> /dev/null`
		fi

		if [ -z "$pids" ]; then
			echo "No managed interfaces to stop"
			exit 0
		fi

		kill $pids > /dev/null 2>&1
		sleep 1
		for retry in 1 2 3; do
			if kill $pids > /dev/null 2>&1; then
				: some still exist
				sleep 2
			else
				echo "Managed interfaces stopped"
				break
			fi
		done
		;;

	*)	echo "usage: diald start|stop [link ...]"
		exit 1
		;;
esac