#! /bin/sh # # chkconfig: 2345 11 89 # description: Starts and stops PPTP connection. # processname: pptpinit # Source function library. . /etc/rc.d/init.d/functions # Get config. SourceIfNotEmpty /etc/sysconfig/network SourceIfNotEmpty /etc/sysconfig/pptp # Check that networking is up. [ "$NETWORKING" != "no" ] || exit [ "$PPTP_ONBOOT" != "no" ] || exit LOCKFILE=/var/lock/subsys/pptp RETVAL=0 pptp_command=/usr/local/bin/pptp-command start() { echo -n "Starting PPTP connection: " if [ $PPTP_SET_HOSTNAME = "yes" ]; then TMPFILE=`mktemp /tmp/pptp.XXXXXX` if [ -f $TMPFILE ]; then $pptp_command start $PPTP_TUNNEL > $TMPFILE RETVAL=$? IPADDR=`cat $TMPFILE | awk -F"IP Address: " '/IP Address/ {print $2}'` rm -f $TMPFILE if [ $RETVAL -eq 0 ]; then echo echo "IP Address: $IPADDR" HOSTNAME=`nslookup $IPADDR | grep Name | awk '{print $2}'` if [ "x$HOSTNAME" != "x" ]; then echo -n "Name: $HOSTNAME" hostname $HOSTNAME success echo else echo -n "Hostname lookup failed" failure echo exit 1; fi fi touch "$LOCKFILE" fi else $pptp_command start $PPTP_TUNNEL RETVAL=$? if [ $RETVAL -eq 0 ]; then success echo else failure echo fi fi } stop() { echo -n "Shutting down PPTP connection: " $pptp_command stop &>/dev/null RETVAL=$? if [ $RETVAL -eq 0 ]; then rm -f "$LOCKFILE" success echo fi } restart() { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status pptp RETVAL=$? ;; restart) restart ;; *) echo "Usage: ${0##*/} {start|stop|status|restart}" RETVAL=1 esac exit $RETVAL