[sisyphus] ifup-pptp

Yura Zotov =?iso-8859-1?q?yznews_=CE=C1_hotbox=2Eru?=
Вт Июл 8 17:40:13 MSD 2003


Я написал скрипты, которые дают возможность стартовать
PPTP-туннели так же, как и другие сетевые интерфейсы, т.е.

ifup pptp0
ifdown pptp0

соответственно и service network start|stop тоже будет их
запускать/стопить.

Посмотрите, кто заинтересован. Если проблем не будет, я включу
эти скрипты следующую сборку пакета.


--
Юрий А. Зотов
----------- следующая часть -----------
ONBOOT=yes

# Must be defined by not null values
DEVICE=pptp0
PPTP_SERVER_IP="192.168.5.2"
PAPNAME=

# Recommended
DEBUG=yes

# Other
DEFROUTE=yes
PEERDNS=no
CALL=
DISCONNECTTIMEOUT=
RETRYTIMEOUT=
IDLETIMEOUT=
ESCAPECHARS=
MRU=
MTU=
IPADDR=
REMIP=
----------- следующая часть -----------
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin

# Source function library.
. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. network-functions

# ifup-post for PPP is handled through /etc/ppp/ip-up

CONFIG=$1
[ -f "$CONFIG" ] || CONFIG="ifcfg-$1"
source_config

if [ -z "$PPTP_SERVER_IP" ]; then
  echo "ifup-pptp for $DEVICE exiting"
  logger -p daemon.info -t ifup-pptp \
    "PPTP-server IP address does not specified"
  exit 1
fi

if [ -z "$DISCONNECTTIMEOUT" ]; then
  DISCONNECTTIMEOUT=2
fi

if [ -z "$RETRYTIMEOUT" ]; then
  RETRYTIMEOUT=30
fi

if [ -z "$IDLETIMEOUT" ]; then
  IDLETIMEOUT=600
fi

if [ "$2" = "boot" -a "$ONBOOT" = "no" ]; then
  exit
fi
PPPD=/usr/sbin/pppd
[ -x "$PPPD" ] || {
  echo "$PPPD does not exist or is not executable"
  echo "ifup-pptp for $DEVICE exiting"
  logger -p daemon.info -t ifup-pptp \
    "$PPPD does not exist or is not executable for $DEVICE"
  exit 1
}


opts="lock"
if [ -n "$CALL" ]; then
	opts="$opts call $CALL"
fi
if [ "$ESCAPECHARS" != yes ] ; then
  opts="$opts asyncmap 00000000"
fi
if [ "$DEFROUTE" != no ] ; then
  # pppd will no longer delete an existing default route
  # so we have to help it out a little here.
  route del default >/dev/null 2>&1
  opts="$opts defaultroute"
fi
if [ "$PEERDNS" != no ] ; then
  opts="$opts usepeerdns"
fi
if [ -n "$MRU" ] ; then
  opts="$opts mru $MRU"
fi
if [ -n "$MTU" ] ; then
  opts="$opts mtu $MTU"
fi
if [ -n "$IPADDR$REMIP" ] ; then
  # if either IP address is set, the following will work.
  opts="$opts $IPADDR:$REMIP"
fi
if [ -n "$PAPNAME" ] ; then
  opts="$opts user $PAPNAME remotename $DEVNAME"
fi
if [ "$DEBUG" = yes ] ; then
  opts="$opts debug"
fi
if [ "$DEMAND" = yes ]; then
    opts="$opts demand ktune idle $IDLETIMEOUT holdoff $RETRYTIMEOUT"
fi

(logger -p daemon.info -t ifup-pptp \
  "PPTP tunnel to $PPTP_SERVER_IP started for $DEVICE" &)&

$PPPD $opts updetach ipparam "$DEVICE" linkname "$DEVICE" $PPPOPTIONS connect "/bin/true" pty "/usr/sbin/pptp $PPTP_SERVER_IP --nolaunchpppd $EXTRA_PPTP_OPTS" &> /dev/null
----------- следующая часть -----------
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin

cd /etc/sysconfig/network-scripts
. network-functions

CONFIG="$1"
[ -f "$CONFIG" ] || CONFIG="ifcfg-$1"
source_config

try_to_kill()
{
	local n="$1"
	shift
	local p="$1"

	local i=0
	while [ $i -lt "$n" ]; do
		[ ! -d "/proc/$p" ] && return 0
		kill -TERM "$p"
		[ ! -d "/proc/$p" ] && return 0
		sleep 1
		i=$[1+i]
	done
	[ ! -d "/proc/$p" ] && return 0 || return 1
}

if [ -s "/var/run/ppp-$DEVICE.pid" ]; then
	PID=`head -1 "/var/run/ppp-$DEVICE.pid"`
	try_to_kill 4 "$PID"
	exit
fi


Подробная информация о списке рассылки Sisyphus