[pptp-server] linux pptp client: how to stop it?

Ronnie F. Moller, Jr. support at redware.net
Sat Jul 29 23:59:18 CDT 2000


I have a series of three scripts that I have written. The purpose is to
ensure that a pptp connection is always up. While I was doing this, I
noticed that it was possible that pptp could create several connections if
it was not watched. The servers that this runs on are Linux RH6.2, and use
an ISDN dialup on ppp0.

Hope these help, and I am open for any new ideas

Ronnie

****** file: pptp
****** location: /etc/rc.d/init.d
****** purpose: Start & Stop the PPTP client
#!/bin/sh
#
# pptp         This shell script takes care of starting and stopping
#               pptp.
#
# description: pptp provides VPN access to remote server
#
# Scipt provided by:	Ronnie F. Moller, Jr.
#			RedBaron Software Company
#			Web:   http://www.redware.net
#			EMail: linux.support at redware.net

# 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/pptp ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
	# Start daemons.
	echo -n "Starting pptp: "
	daemon /usr/sbin/pptp linux1 ipparam poptop debug \
				name USER remotename linux1 \
				+chapms-v2 mppe-128 mppe-stateless \
				deflate 0 noauth
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pptp
	;;
  stop)
	# Stop daemons.
	echo -n "Shutting down pptp: "
	killproc pptp
	RETVAL=$?
	echo
	rm -f /var/run/pptp/*
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pptp
	# Shutdown the PPP interfaces
	/etc/rc.d/init.d/redppp stop
	;;

  restart|reload)
	/etc/rc.d/init.d/redppp stop
	$0 stop
	sleep 5
	$0 start
	RETVAL=$?
	;;
  status)
	status pptp
	RETVAL=$?
	;;
  *)
	echo "Usage: pptp {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL

****** file: pptp-keepalive
****** location: /etc/ppp
****** purpose: Ping the server. If failed, then restart the connection
****** Installation: call this script from CRON
#!/bin/bash
#
# Check for the server. If not reachable, redial
#
# Scipt provided by:	Ronnie F. Moller, Jr.
#			RedBaron Software Company
#			Web:   http://www.redware.net
#			EMail: linux.support at redware.net


ping -c 1 172.16.1.4 ||	/etc/rc.d/init.d/pptp restart


****** file: redppp
****** location: /etc/rc.d/init.d
****** purpose: Close all PPP sessions except for ppp0.
#!/bin/sh
#
# redppp	Shutdown all ppp interfaces
#
# chkconfig: 2345 10 90
# description: Deactivates all ppp interfaces except ppp0
#
# Scipt provided by:	Ronnie F. Moller, Jr.
#			RedBaron Software Company
#			Web:   http://www.redware.net
#			EMail: linux.support at redware.net
# Source function library.
. /etc/rc.d/init.d/functions

. /etc/sysconfig/network

 find all the ppp interfaces besides ppp0
interfaces=`ifconfig -a | egrep '(ppp)' | \
		egrep -v '(ppp0)' | cut -d ' ' -f 1`

# See how we were called.
case "$1" in
  start)
	echo "Start Not supported"
        ;;
  stop)
	for i in $interfaces ; do
		action "Shutting down interface $i" /etc/ppp/ppp-off $i
	done
        ;;
  status)
	echo "Configured devices:"
	echo lo $interfaces
	;;
  restart)
        cd $CWD
	$0 stop
	$0 start
	;;
  *)
        echo "Usage: redppp {stop|status}"
        exit 1
esac

exit 0

****** file: ip-up.local
****** location: /etc/ppp
****** purpose: If the protocol that just came up is one established by
poptop,
			add a route
#!/bin/bash
#
# Scipt provided by:	Ronnie F. Moller, Jr.
#			RedBaron Software Company
#			Web:   http://www.redware.net
#			EMail: linux.support at redware.net
#
# Purpose: Automatically add route to network upon
#		VPN connection
#

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

case "$6" in
	poptop)
		#need to add route
		exec /sbin/route add -net 172.16.1.0/24 gw $4
		;;
esac

exit 0

****** file: ip-down.local
****** location: /etc/ppp
****** purpose: If the protocol that just went down is one established by
poptop,
		perform custom actions
#!/bin/bash
#
# Scipt provided by:	Ronnie F. Moller, Jr.
#			RedBaron Software Company
#			Web:   http://www.redware.net
#			EMail: linux.support at redware.net

LOGDEVICE=$6
REALDEVICE=$1

case "$6" in
	poptop)

		;;
esac

exit 0




More information about the pptp-server mailing list