summaryrefslogtreecommitdiff
path: root/branding/scripts
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-09-08 19:55:48 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-09-08 20:10:19 +0200
commit10b8c5e0a3fe882d34474f80571172e089fc4df1 (patch)
treeaa81fd5402faa8df62020f096486c91298ff2686 /branding/scripts
parent68a49f353954bb32289f6e80281b2ed14312f679 (diff)
[refactor] remove unused script
Diffstat (limited to 'branding/scripts')
-rwxr-xr-xbranding/scripts/vendorize.py95
1 files changed, 0 insertions, 95 deletions
diff --git a/branding/scripts/vendorize.py b/branding/scripts/vendorize.py
deleted file mode 100755
index 28c5d2a..0000000
--- a/branding/scripts/vendorize.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python3
-
-# TODO: to be deprecated! use gen-providers-json.py instead
-
-import os
-import sys
-
-from string import Template
-import configparser
-
-from provider import getDefaultProvider
-from provider import getProviderData
-
-OUTFILE = 'config.go'
-INFILE = '../templates/bitmaskvpn/config.go'
-CONFIGFILE = '../config/vendor.conf'
-SCRIPT_NAME = 'vendorize'
-
-
-def addCaData(data, configfile):
- provider = data.get('name').lower()
- folder, f = os.path.split(configfile)
- caFile = os.path.join(folder, provider + '-ca.crt')
- if not os.path.isfile(caFile):
- bail('[!] Cannot find CA file in {path}'.format(path=caFile))
- with open(caFile) as ca:
- data['caCertString'] = ca.read().strip()
-
-
-def writeOutput(data, infile, outfile):
-
- with open(infile) as infile:
- s = Template(infile.read())
-
- with open(outfile, 'w') as outf:
- outf.write(s.substitute(data))
-
-
-def bail(msg=None):
- if not msg:
- print('Usage: {scriptname}.py <template> <config> <output>'.format(
- scriptname=SCRIPT_NAME))
- else:
- print(msg)
- sys.exit(1)
-
-
-if __name__ == "__main__":
- infile = outfile = ""
-
- if len(sys.argv) > 4:
- bail()
-
- elif len(sys.argv) == 1:
- infile = INFILE
- outfile = OUTFILE
- configfile = CONFIGFILE
- else:
- try:
- infile = sys.argv[1]
- configfile = sys.argv[2]
- outfile = sys.argv[3]
- except IndexError:
- bail()
-
- env_provider_conf = os.environ.get('PROVIDER_CONFIG')
- if env_provider_conf:
- if os.path.isfile(env_provider_conf):
- print("[+] Overriding provider config per "
- "PROVIDER_CONFIG variable")
- configfile = env_provider_conf
-
- if not os.path.isfile(infile):
- bail('[!] Cannot find template in {path}'.format(
- path=os.path.abspath(infile)))
- elif not os.path.isfile(configfile):
- bail('[!] Cannot find config in {path}'.format(
- path=os.path.abspath(configfile)))
- else:
- print('[+] Using {path} as template'.format(
- path=os.path.abspath(infile)))
- print('[+] Using {path} as config'.format(
- path=os.path.abspath(configfile)))
-
- config = configparser.ConfigParser()
- config.read(configfile)
-
- provider = getDefaultProvider(config)
- data = getProviderData(provider, config)
- addCaData(data, configfile)
- writeOutput(data, infile, outfile)
-
- print('[+] Wrote configuration for {provider} to {outf}'.format(
- provider=data.get('name'),
- outf=os.path.abspath(outfile)))