Skip to content

Commit

Permalink
allow using indicator to show the main window
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon2fly committed Dec 9, 2016
1 parent c6a9dfa commit 50f92e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ else
arg=$type
fi

# check if this os is *ubuntu and launch vpn_indicator
os_id=`lsb_release -i`
# check if this os is *buntu and launch vpn_indicator
os_id=`cat /proc/version`
target="buntu"
test "${os_id#*$target}" != "$os_id" && stdbuf -oL python vpn_indicator.py > logs/indicator.log &

sleep 0.2
sudo python vpnproxy_tui.py $arg
fi
fi
15 changes: 9 additions & 6 deletions vpnproxy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.30"
__version__ = "1.35"
__maintainer__ = "duc_tin"
__email__ = "nguyenbaduc.tin@gmail.com"

Expand All @@ -12,6 +12,7 @@
import base64
import time
import datetime
import platform
from config import *
from Queue import Queue
from threading import Thread
Expand All @@ -24,6 +25,11 @@
# os.execlpe('sudo', *args)
raise RuntimeError('Permission deny! You need to "sudo" or use "./run cli" instead')

# detect Debian based or Redhat based OS
pkg_mgr = 'apt-get'
if "generic" not in platform.platform():
pkg_mgr = 'yum' # yum or dnf; on new fedora, yum is automatically redirect to dnf

# Define some mirrors of vpngate.net
mirrors = ["http://www.vpngate.net"] # add your mirrors to config.ini file, not here

Expand Down Expand Up @@ -367,7 +373,7 @@ def vpn_manager(ovpn):
dns_fix, dns = cfg.dns.values()
verbose = cfg.openvpn.values()[0]

required = {'openvpn': 0, 'python-requests': 0, 'resolvconf': 0}
required = {'openvpn': 0, 'python-requests': 0}

try:
import requests
Expand All @@ -377,9 +383,6 @@ def vpn_manager(ovpn):
if not os.path.exists('/usr/sbin/openvpn'):
required['openvpn'] = 1

if not os.path.exists('/sbin/resolvconf'):
required['resolvconf'] = 1

need = [p for p in required if required[p]]
if need:
print ctext('\n**Lack of dependencies**', 'rB')
Expand All @@ -390,7 +393,7 @@ def vpn_manager(ovpn):
for package in need:
print '\n___Now installing', ctext(package, 'gB')
print
call(['apt-get', '-y', 'install', package], env=env)
call([pkg_mgr, '-y', 'install', package], env=env)

import requests

Expand Down
12 changes: 9 additions & 3 deletions vpnproxy_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.30"
__version__ = "1.35"
__maintainer__ = "duc_tin"
__email__ = "nguyenbaduc.tin@gmail.com"

import os, sys, signal
import base64
import time
import datetime
import platform
from copy import deepcopy
from config import *
from Queue import Queue, Empty
Expand All @@ -26,6 +27,11 @@
# os.execlpe('sudo', *args)
raise RuntimeError('Permission deny! You need to "sudo" or use "./run" instead')

# detect Debian based or Redhat based OS
pkg_mgr = 'apt-get'
if "generic" not in platform.platform():
pkg_mgr = 'yum' # yum or dnf; on new fedora, yum is automatically redirect to dnf

# Threading
ON_POSIX = 'posix' in sys.builtin_module_names

Expand Down Expand Up @@ -1004,13 +1010,13 @@ def exit(self, loop, data=None):
ctext("Have you 'sudo apt-get update' recently?", 'B') + "([yes] | no): ") else 'no'

if update_now == 'yes':
call(['apt-get', 'update'], env=env)
call([pkg_mgr, 'update'], env=env)

for package in need:
print '\n___Now installing', ctext(package, 'gB')
print
if package in ['openvpn', 'python-pip']:
call(['apt-get', '-y', 'install', package], env=env)
call([pkg_mgr, '-y', 'install', package], env=env)
else:
call(['pip', 'install', package], env=env)
globals()[package] = __import__(package)
Expand Down

0 comments on commit 50f92e8

Please sign in to comment.