ovpn-client 688 Bytes
Newer Older
1
#!/usr/bin/python2 -S
2 3
import os, sys

4 5
script_type = os.environ['script_type']
if script_type == 'up':
6 7
    # OpenVPN only brings the interface up when it's called with --ifconfig
    # i.e. when IPv4 mode is enabled in re6st.
8 9 10
    # OpenVPN unsets PATH before calling hooks
    # which is equivalent to set /bin:/usr/bin
    os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin'
11 12
    os.execlp('ip', 'ip', 'link', 'set', os.environ['dev'], 'up',
              'mtu', os.environ['tun_mtu'])
13

14 15 16 17
if script_type == 'route-up':
    import time
    os.write(int(sys.argv[1]), repr((os.environ['common_name'], time.time(),
        int(os.environ['tls_serial_0']), os.environ['OPENVPN_external_ip'])))