# pptp timeout requires script zapping

## Letharion

I connect to work via pptp.

My initial attempt works fine, but after 15-30 minutes of inactivity, the connection drops.

```
# /etc/init.d/QSAB stop

QSAB              | * Caching service dependencies ...                                                                                                                                                       [ ok ]

QSAB              | * Disconnecting from QSAB VPN ...

QSAB              |/usr/sbin/poff: No pppd is running.  None stopped.                                                                                                                                        [ !! ]

QSAB              | * ERROR: QSAB failed to stop

# /etc/init.d/QSAB start

QSAB              | * WARNING: QSAB has already been started

# /etc/init.d/QSAB zap

QSAB              | * Manually resetting QSAB to stopped state

# /etc/init.d/QSAB start

QSAB              | * Connecting to QSAB VPN ...
```

I'm guessing I've done something wrong since I need to zap the script before I can reconnect.

/etc/init.d/QSAB:

```
#!/sbin/runscript

# Copyright 2007-2008 Roy Marples <roy@marples.name>

# All rights reserved. Released under the 2-clause BSD license.

name="VPN"

depend() {

   need net

}

start() {

   ebegin "Connecting to QSAB VPN"

   /usr/sbin/pon QSAB

   sleep 5 #Give pon a chance to get an ip

   /sbin/route add -net 192.168.175.0 netmask 255.255.255.0 dev ppp0

   eend $?

}

stop() {

   ebegin "Disconnecting from QSAB VPN"

   /usr/sbin/poff QSAB

   eend $?

}
```

----------

## Letharion

Bump

----------

## mv

 *Letharion wrote:*   

> I connect to work via pptp.
> 
> My initial attempt works fine, but after 15-30 minutes of inactivity, the connection drops.

 

Probably you configured pppd somehow with the "idle" option (I didn't check how pon determines the pppd options).

If you would have named your script appropriately /etc/init.d/net.$INTERFACE (I have no idea what QSAB is - does it have an interface?), the script /etc/ppp/ip-down.d/50-initd.sh (which is executed when pppd terminates) would have automatically attempted to stop your init-script so that you do not have to stop it later manually. (You could also write your own corresponding rule in your own /etc/ppp/ip-down.d/* file).

However, the stop function of your script is not appropriate:

 *Quote:*   

> 
> 
> ```
> stop() {
> 
> ...

 

This function returns a nonzero exit status if poff failed; a nonzero exit status means that exiting of the script failed, i.e. it was not really stopped. However, this is not the case: Even if poff returns a nonzero exit status, it is likely that the exit was actually successful. So as an easy workaround you can just lie about the exit status: 

```
stop() {

   ebegin "Disconnecting from QSAB VPN"

   /usr/sbin/poff QSAB

   eend $?

   :

}
```

Of course, you can also do more care and test in case of a nonzero exit status really no pppd is running...

----------

## aCOSwt

 *Letharion wrote:*   

> I connect to work via pptp. My initial attempt works fine, but after 15-30 minutes of inactivity

 

<joking>

So... you... are connecting to work for... not working ?

</joking>

As it seems being a private network, Would not it be the remote server which ends the connection ?

----------

