Ah, this works:

"""
#!/bin/bash

REQUIRED_CONNECTION_NAME="Example"
VPN_CONNECTION_NAME="Example VPN"
OWNER_OF_VPN_SECRET="exampleuser" # Username of the owner of the keyring with 
the VPN credentials

activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")

if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
    su ${OWNER_OF_VPN_SECRET} -c "nmcli con up id \"${VPN_CONNECTION_NAME}\""
fi
"""

So it is an access rights issue.

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to network-manager-pptp in Ubuntu.
https://bugs.launchpad.net/bugs/906290

Title:
  PPTP: Connecting from GUI works, but not automatically from command-
  line dispatcher script

Status in “network-manager-pptp” package in Ubuntu:
  New

Bug description:
  I'm duplicating my comment from
  https://bugs.launchpad.net/ubuntu/+source/network-manager-
  openconnect/+bug/824255/comments/17 since that bug seems to be closed
  while my problem remains, so I guess I hit a different bug or
  something. I'm using Ubuntu 11.10, fully updated (network-manager
  0.9.1.90-0ubuntu5.1, network-manager-pptp 0.9.0-0ubuntu2).

  I'm using the dispatcher script from 
http://wiki.ubuntuusers.de/NetworkManager/Dispatcher, at the bottom:
  ------------------------------
  #!/bin/bash

  REQUIRED_CONNECTION_NAME="specific_WLAN_network"
  VPN_CONNECTION_NAME="given_VPN_connection"

  activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
  activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")
  if [ "${activ_con}" -a ! "${activ_vpn}" ];
  then
      nmcli con up id "${VPN_CONNECTION_NAME}"
  fi
  ------------------------------

  WHAT I EXPECT: 
  The dispatcher script should trigger when the system boots up, when I wake it 
up from sleeping and when the VPN connection breaks off and establish the given 
VPN connection automatically as soon as I'm connected to a specific WLAN 
network.

  WHAT I GET:
  Oct 24 00:18:34 nikolaus-desktop NetworkManager[1040]: <info> Policy set 
'WLAN_NETWORK' (wlan0) as default for IPv4 routing and DNS.
  Oct 24 00:18:34 nikolaus-desktop NetworkManager[1040]: <info> Activation 
(wlan0) successful, device activated.
  Oct 24 00:18:34 nikolaus-desktop NetworkManager[1040]: <info> Activation 
(wlan0) Stage 5 of 5 (IP Configure Commit) complete.
  Oct 24 00:18:34 nikolaus-desktop NetworkManager[1040]: <info> Activation 
(wlan0) Stage 4 of 5 (IP4 Configure Get) complete.
  Oct 24 00:18:34 nikolaus-desktop NetworkManager[1040]: <info> VPN service 
'pptp' disappeared
  Oct 24 00:18:35 nikolaus-desktop NetworkManager[1040]: <info> Starting VPN 
service 'pptp'...
  Oct 24 00:18:35 nikolaus-desktop NetworkManager[1040]: <info> VPN service 
'pptp' started (org.freedesktop.NetworkManager.pptp), PID 5071
  Oct 24 00:18:35 nikolaus-desktop NetworkManager[1040]: <info> VPN service 
'pptp' appeared; activating connections
  Oct 24 00:18:35 nikolaus-desktop NetworkManager[1040]: <error> 
[1319408315.274270] [nm-vpn-connection.c:882] get_secrets_cb(): Failed to 
request VPN secrets #2: (6) No agents were available for this request.
  Oct 24 00:18:35 nikolaus-desktop NetworkManager[1040]: <info> Policy set 
'WLAN_NETWORK' (wlan0) as default for IPv4 routing and DNS.
  Oct 24 00:18:35 nikolaus-desktop nm-dispatcher.action: Script 
'/etc/NetworkManager/dispatcher.d/20-WLAN_NETWORK' exited with error status 4.
  Oct 24 00:18:40 nikolaus-desktop NetworkManager[1040]: <info> VPN service 
'pptp' disappeared

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/network-manager-pptp/+bug/906290/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to