From d67462ecfe7b6d55f686b70f78da0819ea382709 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Tue, 11 Jun 2019 22:16:48 +0100 Subject: [PATCH] Make process path dynamic --- .env | 1 + README.md | 11 +++++++++-- pyVPN.py | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..74aaa73 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PYVPN_PROCESS_PATH='/root/openvpn-install.sh' \ No newline at end of file diff --git a/README.md b/README.md index 1d95880..b907271 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ### Usage -``./pyvpn --create-client [clientname]`` +``pyvpn --create-client [clientname]`` ### Requirements @@ -35,7 +35,14 @@ You need to have Python installed for this to work. Move the script to the scripts directory: -``mv pyVPN.py /usr/local/bin/pyvpn`` +From the repository you just cloned, + +Source the path environment variable: +``source ./.env`` + +Then install the program: ``mv pyVPN.py /usr/local/bin/pyvpn`` + +Confirm that the path ``echo $PYVPN_PROCESS_PATH`` is correct. If not, adjust the env file and resource. ### Contributing diff --git a/pyVPN.py b/pyVPN.py index 4fb8d51..da52346 100644 --- a/pyVPN.py +++ b/pyVPN.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import os import sys import pexpect import os.path @@ -7,7 +8,8 @@ import base64 # This script can probably use some improvement -process = "/root/openvpn-install/openvpn-installer.sh" +process = os.environ['PYVPN_PROCESS_PATH'] + operatingDir = "/root" fScript = pexpect.spawn("/bin/bash" + process)