Skip to content

Commit

Permalink
path of folder containing config files can be customized in run fil…
Browse files Browse the repository at this point in the history
…e: `user_home`
  • Loading branch information
ductin committed May 3, 2017
1 parent f57a28a commit 6146ff5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions run
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash

# allow running from anywhere
# when making an alias in .bashrc or /etc/environment: vpn="path/to/./run"

dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$(dirname "$(realpath "$0")")";
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"

user_home=($HOME)
type=$1
arg=$2

if [ "$type" == "cli" ]; then
sudo python vpnproxy_cli.py $arg
sudo python vpnproxy_cli.py $user_home $arg
else
if [ "$type" != "tui" ]; then
arg=$type
Expand All @@ -21,5 +24,5 @@ else
test "${os_id#*$target}" != "$os_id" && stdbuf -oL python vpn_indicator.py > logs/indicator.log &

sleep 0.2
sudo python vpnproxy_tui.py $arg
sudo python vpnproxy_tui.py $user_home $arg
fi
7 changes: 4 additions & 3 deletions vpnproxy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,12 @@ def signal_term_handler(signal, frame):
test_timeout = 1

# get config file path
user_home = sys.argv[1]
path = os.path.realpath(sys.argv[0])
config_file = os.path.expanduser('~/.config/vpngate-with-proxy/config.ini')
user_script_file = os.path.expanduser('~/.config/vpngate-with-proxy/user_script.sh')
config_file = user_home + '/.config/vpngate-with-proxy/config.ini'
user_script_file = user_home + '/.config/vpngate-with-proxy/user_script.sh'
cfg = Setting(config_file)
args = sys.argv[1:]
args = sys.argv[2:]

# get proxy from config file
if os.path.exists(config_file):
Expand Down
6 changes: 3 additions & 3 deletions vpnproxy_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def __repr__(self):
class Connection:
def __init__(self):
self.path = os.path.realpath(sys.argv[0])
self.config_file = os.path.expanduser('~/.config/vpngate-with-proxy/config.ini')
self.user_script_file = os.path.expanduser('~/.config/vpngate-with-proxy/user_script.sh')
self.config_file = sys.argv[1] + '/.config/vpngate-with-proxy/config.ini'
self.user_script_file = sys.argv[1] + '/.config/vpngate-with-proxy/user_script.sh'
self.cfg = Setting(self.config_file)
self.args = sys.argv[1:]
self.args = sys.argv[2:]
self.debug = []
self.dropped_time = 0
self.max_retry = 3
Expand Down

0 comments on commit 6146ff5

Please sign in to comment.