agentmoose

Q: Pause Transmission on OSX Server when User Connects to VPN

I am using the Server app (version 5.1.5) on 10.11.5, and use the VPN functionality for my own personal use to have a secure internet connection to my home network when I am out and about at coffee shops. I also run Transmission on the same Mac, and would like to automatically pause Transmission when I connect to the VPN service and then resume when I disconnect. I have searched for help on this issue but all results I can find are for controlling Transmission on the computer with the outgoing VPN connection.

 

Is there a way to detect the incoming VPN connection on the Mac with the Server app to pause Transmission, then resume Transmission when I disconnect from the VPN?

 

Thanks!

MacBook Pro, Mac OS X (10.7)

Posted on Jun 27, 2016 3:24 PM

Close

Q: Pause Transmission on OSX Server when User Connects to VPN

  • All replies
  • Helpful answers

  • by John Lockwood,

    John Lockwood John Lockwood Jun 28, 2016 2:47 AM in response to agentmoose
    Level 6 (9,230 points)
    Servers Enterprise
    Jun 28, 2016 2:47 AM in response to agentmoose

    You could try writing a script that checks the results of

     

    sudo serveradmin fullstatus vpn

     

    One of the lines in the information returned is the number of active PPTP or L2TP connections so the following would return just the number of L2TP connections.

     

    numL2TPconnections=`serveradmin fullstatus vpn | grep l2tp:CurrentConnections | awk '{print $3}'`

     

    Your script could then send a command to Transmission to pause it if the value is greater than zero. You could use launchctl to run a launchdaemon every 10 seconds and then run your script.