From 6a1c90a260c44cb27ba14a70cc5dd23189822832 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Wed, 30 Sep 2020 14:37:50 +0200 Subject: [feat] make vendor_init to create independent repo this starts a stub for refactoring the authentication process, leading to keep an external repo. --- branding/scripts/ASSETS_LIST | 2 + branding/scripts/check | 4 ++ branding/scripts/init | 108 +++++++++++++++++++++++++++++++++++++++++++ branding/scripts/provider.py | 1 - 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 branding/scripts/ASSETS_LIST create mode 100755 branding/scripts/check create mode 100755 branding/scripts/init (limited to 'branding/scripts') diff --git a/branding/scripts/ASSETS_LIST b/branding/scripts/ASSETS_LIST new file mode 100644 index 0000000..71c89e3 --- /dev/null +++ b/branding/scripts/ASSETS_LIST @@ -0,0 +1,2 @@ +svg/icon.svg +ico/logo.ico diff --git a/branding/scripts/check b/branding/scripts/check new file mode 100755 index 0000000..07b2a71 --- /dev/null +++ b/branding/scripts/check @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + +if __name__ == "__main__": + print("[+] Checking your provider config... (WIP)") diff --git a/branding/scripts/init b/branding/scripts/init new file mode 100755 index 0000000..ba9ce52 --- /dev/null +++ b/branding/scripts/init @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +# (c) LEAP Encryption Access Project 2020 +# License: GPL + +import subprocess +import sys +import os + +VENDOR_PATH = None +SCRIPT_NAME = sys.argv[0] +CA_README = "config/CERT.Readme" +ASSETS_README = "assets/FILES.Readme" + +def initVendor(): + global VENDOR_PATH + if not VENDOR_PATH: + bail("ERROR: Please set VENDOR_PATH environment variable.") + VENDOR_PATH = os.path.abspath(VENDOR_PATH) + if os.path.isdir(VENDOR_PATH): + bail("ERROR: VENDOR_PATH folder already exists") + + for d in ["config", "assets", "pkg"]: + os.makedirs(os.path.join(VENDOR_PATH, d)) + + initVendorConfig() + initGitRepo() + displayRepoInfo() + +def displayRepoInfo(): + print("[+] Initialized repo in", VENDOR_PATH) + print(f"[ ] - Add the assets in the assets/ folder, see {ASSETS_README}.") + print(f"[ ] - Add the CA certificate in the config/ folder, see {CA_README}.") + print("[ ] - Remember to commit your changes.") + print() + print("[+] After doing that, you can run 'make vendor_check' to validate the configuration for your provider.") + +def bail(msg=None): + if not msg: + print("ERROR: no arguments supported!") + print('Usage: {scriptname}'.format( + scriptname=SCRIPT_NAME)) + else: + print(msg) + sys.exit(1) + +def getVendorPath(): + return os.environ.get('VENDOR_PATH') + +def initVendorConfig(): + + with open(os.path.join(VENDOR_PATH, "config", "vendor.conf"), "w") as f: + f.write(CONF_TEMPLATE) + + with open(os.path.join(VENDOR_PATH, CA_README), "w") as f: + f.write(CA_INFO) + + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ASSETS_LIST")) as f: + allAssets = f.read() + + with open(os.path.join(VENDOR_PATH, ASSETS_README), "w") as f: + f.write(ASSETS_INFO) + f.write(allAssets) + +def initGitRepo(): + out = subprocess.run(['git', 'init'], cwd=VENDOR_PATH) + if out.returncode != 0: + print(f'ERROR: cannot initialize git repo in {VENDOR_PATH}') + + +CONF_TEMPLATE = """[default] + +provider = myprovider + +[myprovider] + +name = MyProvider +applicationName = MyProviderVPN +binaryName = myprovider-vpn + +providerURL = example.org +auth = anon +apiURL = https://api.myprovider.net/ +caURL = https://myprovider.net/ca.crt + +infoURL = https://myprovider.net/vpn +tosURL = https://myprovider.net/tos +helpURL = https://myprovider.net/support + +geolocationAPI = https://myprovider.net:9001/json + +askForDonations = true +donateURL = https://myprovider.net/vpn/donate +""" + +CA_INFO = """Place in this folder your provider's CA certificate, with the name: + + -ca.crt +""" + +ASSETS_INFO = """This is the list of assets that you MUST place in this folder for your provider: + +""" + +if __name__ == "__main__": + if len(sys.argv) != 1: + bail() + VENDOR_PATH = getVendorPath() + initVendor() diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py index 619382b..ec8c80a 100644 --- a/branding/scripts/provider.py +++ b/branding/scripts/provider.py @@ -32,4 +32,3 @@ def getProviderData(provider, config): datetime.datetime.now()) return d - -- cgit v1.2.3