openbsd-ports/net/pptp/files/pptp_reconnect

37 lines
979 B
Bash

#!/bin/sh
# $OpenBSD: pptp_reconnect,v 1.3 2001/06/08 17:59:19 fgsch Exp $
#
# PPTP reconnect script
#
# sample crontab entry:
# 0,30 * * * * /sbin/ping -c 2 MY_REMOTE_PEER_IP >/dev/null || PREFIX/sbin/pptp-reconnect
#
#
# INSTALL-INSTRUCTIONS: edit following IP and uncomment the line
#MODEMIP=10.0.0.138
PATH=/bin:/usr/bin:/sbin:/usr/sbin:PREFIX/sbin
if [ "$MODEMIP" = "" ]; then
echo "You have to edit the pptp-reconnect script."
exit
fi
echo "Killing pppd."
kill -9 `ps -ax|grep pppd|grep -v grep|awk '{print $1}'`
/bin/sleep 3
echo "Killing pptp."
kill -9 `ps -ax|grep pptp|grep -v pptp-reconnect|grep -v grep|awk '{print $1}'`
/bin/sleep 3
if [ -S /var/run/pptp/$MODEMIP ]; then
/bin/rm -f /var/run/pptp/$MODEMIP
fi
echo "Establishing connection."
echo "=========================================================" >> /var/log/ppp.log
echo "Establishing connection at `date`." >> /var/log/ppp.log
PREFIX/sbin/pptp $MODEMIP >> /var/log/ppp.log 2>&1
/bin/sleep 7